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 #include <boost/enable_shared_from_this.hpp>
32 #include <boost/shared_ptr.hpp>
33 
34 #include "../common/WThreadedRunner.h"
35 #include "../common/WSharedSequenceContainer.h"
36 
37 #include "WDataModule.h"
38 
39 
40 
41 class WModuleContainer;
42 
43 /**
44  * Class for loading many datasets. It runs in a separate thread.
45  */
47  public boost::enable_shared_from_this< WBatchLoader >
48 {
49 public:
50  /**
51  * Shared ptr abbreviation
52  */
53  typedef boost::shared_ptr< WBatchLoader > SPtr;
54 
55  /**
56  * Const shared ptr abbreviation
57  */
58  typedef boost::shared_ptr< const WBatchLoader > ConstSPtr;
59 
60  /**
61  * The type is used to store the list of data modules
62  */
64 
65  /**
66  * Initializes the batchloader but does not start it. Use run().
67  *
68  * \param filenames the files to load.
69  * \param targetContainer the container to which the data modules should be added.
70  */
71  WBatchLoader( std::vector< std::string > filenames, boost::shared_ptr< WModuleContainer > targetContainer );
72 
73  /**
74  * Destructor.
75  */
76  virtual ~WBatchLoader();
77 
78  /**
79  * Run thread and load the data.
80  */
81  virtual void run();
82 
83  /**
84  * Returns a ticket to the list of data modules that have been added so far.
85  *
86  * \return the ticket
87  */
89 
90  /**
91  * Allows suppression of colormap registration in data modules. This can be handy if you use data modules in a container to construct more
92  * complex data sets from multiple input files.
93  *
94  * \note call this before run().
95  *
96  * \param suppress true if suppress
97  */
98  void setSuppressColormaps( bool suppress = true );
99 
100  /**
101  * Checks whether suppression of colormaps is active.
102  *
103  * \return true if colormaps are suppressed.
104  */
105  bool getSuppressColormaps() const;
106 
107 protected:
108  /**
109  * Function that has to be overwritten for execution. It gets executed in a separate thread after run()
110  * has been called.
111  */
112  virtual void threadMain();
113 
114  /**
115  * List of files to load.
116  */
117  std::vector< std::string > m_filenamesToLoad;
118 
119  /**
120  * The container which later will contain the loaded datasets.
121  */
122  boost::shared_ptr< WModuleContainer > m_targetContainer;
123 
124  /**
125  * The list of modules that have been added.
126  */
128 
129  /**
130  * If true, data modules are instructed to suppress colormap registration.
131  */
133 
134 private:
135 };
136 
137 #endif // WBATCHLOADER_H
138 
boost::shared_ptr< const WBatchLoader > ConstSPtr
Const shared ptr abbreviation.
Definition: WBatchLoader.h:58
Class for loading many datasets.
Definition: WBatchLoader.h:46
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:127
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:63
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:132
std::vector< std::string > m_filenamesToLoad
List of files to load.
Definition: WBatchLoader.h:117
boost::shared_ptr< WBatchLoader > SPtr
Shared ptr abbreviation.
Definition: WBatchLoader.h:53
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:62
boost::shared_ptr< WModuleContainer > m_targetContainer
The container which later will contain the loaded datasets.
Definition: WBatchLoader.h:122