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