OpenWalnut  1.4.0
WBatchLoader.h
1 //---------------------------------------------------------------------------
2 //
3 // Project: OpenWalnut ( http://www.openwalnut.org )
4 //
5 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6 // For more information see http://www.openwalnut.org/copying
7 //
8 // This file is part of OpenWalnut.
9 //
10 // OpenWalnut is free software: you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // OpenWalnut is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public License
21 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
22 //
23 //---------------------------------------------------------------------------
24 
25 #ifndef WBATCHLOADER_H
26 #define WBATCHLOADER_H
27 
28 #include <string>
29 #include <vector>
30 
31 #ifndef Q_MOC_RUN
32 #include <boost/enable_shared_from_this.hpp>
33 #endif
34 #ifndef Q_MOC_RUN
35 #include <boost/shared_ptr.hpp>
36 #endif
37 
38 #include "../common/WThreadedRunner.h"
39 #include "../common/WSharedSequenceContainer.h"
40 
41 #include "WDataModule.h"
42 
43 
44 
45 class WModuleContainer;
46 
47 /**
48  * Class for loading many datasets. It runs in a separate thread.
49  */
51  public boost::enable_shared_from_this< WBatchLoader >
52 {
53 public:
54  /**
55  * Shared ptr abbreviation
56  */
57  typedef boost::shared_ptr< WBatchLoader > SPtr;
58 
59  /**
60  * Const shared ptr abbreviation
61  */
62  typedef boost::shared_ptr< const WBatchLoader > ConstSPtr;
63 
64  /**
65  * The type is used to store the list of data modules
66  */
68 
69  /**
70  * Initializes the batchloader but does not start it. Use run().
71  *
72  * \param filenames the files to load.
73  * \param targetContainer the container to which the data modules should be added.
74  */
75  WBatchLoader( std::vector< std::string > filenames, boost::shared_ptr< WModuleContainer > targetContainer );
76 
77  /**
78  * Destructor.
79  */
80  virtual ~WBatchLoader();
81 
82  /**
83  * Run thread and load the data.
84  */
85  virtual void run();
86 
87  /**
88  * Returns a ticket to the list of data modules that have been added so far.
89  *
90  * \return the ticket
91  */
93 
94  /**
95  * Allows suppression of colormap registration in data modules. This can be handy if you use data modules in a container to construct more
96  * complex data sets from multiple input files.
97  *
98  * \note call this before run().
99  *
100  * \param suppress true if suppress
101  */
102  void setSuppressColormaps( bool suppress = true );
103 
104  /**
105  * Checks whether suppression of colormaps is active.
106  *
107  * \return true if colormaps are suppressed.
108  */
109  bool getSuppressColormaps() const;
110 
111 protected:
112  /**
113  * Function that has to be overwritten for execution. It gets executed in a separate thread after run()
114  * has been called.
115  */
116  virtual void threadMain();
117 
118  /**
119  * List of files to load.
120  */
121  std::vector< std::string > m_filenamesToLoad;
122 
123  /**
124  * The container which later will contain the loaded datasets.
125  */
126  boost::shared_ptr< WModuleContainer > m_targetContainer;
127 
128  /**
129  * The list of modules that have been added.
130  */
131  DataModuleList m_dataModules;
132 
133  /**
134  * If true, data modules are instructed to suppress colormap registration.
135  */
137 
138 private:
139 };
140 
141 #endif // WBATCHLOADER_H
142 
boost::shared_ptr< const WBatchLoader > ConstSPtr
Const shared ptr abbreviation.
Definition: WBatchLoader.h:62
Class for loading many datasets.
Definition: WBatchLoader.h:50
WBatchLoader(std::vector< std::string > filenames, boost::shared_ptr< WModuleContainer > targetContainer)
Initializes the batchloader but does not start it.
virtual ~WBatchLoader()
Destructor.
DataModuleList m_dataModules
The list of modules that have been added.
Definition: WBatchLoader.h:131
This class provides a common interface for thread-safe access to sequence containers (list...
void setSuppressColormaps(bool suppress=true)
Allows suppression of colormap registration in data modules.
Base class for all classes needing to be executed in a separate thread.
DataModuleList::ReadTicket getDataModuleList() const
Returns a ticket to the list of data modules that have been added so far.
WSharedSequenceContainer< std::vector< WDataModule::SPtr > > DataModuleList
The type is used to store the list of data modules.
Definition: WBatchLoader.h:67
virtual void threadMain()
Function that has to be overwritten for execution.
bool m_suppressColormaps
If true, data modules are instructed to suppress colormap registration.
Definition: WBatchLoader.h:136
std::vector< std::string > m_filenamesToLoad
List of files to load.
Definition: WBatchLoader.h:121
boost::shared_ptr< WBatchLoader > SPtr
Shared ptr abbreviation.
Definition: WBatchLoader.h:57
bool getSuppressColormaps() const
Checks whether suppression of colormaps is active.
Class able to contain other modules.
virtual void run()
Run thread and load the data.
boost::shared_ptr< WSharedObjectTicketRead< std::vector< WDataModule::SPtr > > > ReadTicket
Type for read tickets.
Definition: WSharedObject.h:64
boost::shared_ptr< WModuleContainer > m_targetContainer
The container which later will contain the loaded datasets.
Definition: WBatchLoader.h:126