OpenWalnut  1.4.0
WDataModule.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 WDATAMODULE_H
26 #define WDATAMODULE_H
27 
28 #ifndef Q_MOC_RUN
29 #include <boost/shared_ptr.hpp>
30 #endif
31 
32 #include "WModule.h"
33 
34 /**
35  * Base for all data loader modules. This currently is only a prototype to move WMData out of the core. Later, it will provide a whole interface
36  * to handle arbitrary data/multi-file data and other complex things.
37  */
38 class WDataModule: public WModule
39 {
40 public:
41  /**
42  * Convenience typedef for a boost::shared_ptr< WDataModule >.
43  */
44  typedef boost::shared_ptr< WDataModule > SPtr;
45 
46  /**
47  * Convenience typedef for a boost::shared_ptr< const WDataModule >.
48  */
49  typedef boost::shared_ptr< const WDataModule > ConstSPtr;
50 
51  /**
52  * Default constructor.
53  */
54  WDataModule();
55 
56  /**
57  * Destructor.
58  */
59  virtual ~WDataModule();
60 
61  /**
62  * Gets the type of the module. This is useful for FAST differentiation between several modules like standard modules and data
63  * modules which play a special role in OpenWalnut/Kernel.
64  *
65  * \return the Type. If you do not overwrite this method, it will return MODULE_ARBITRARY.
66  */
67  virtual MODULE_TYPE getType() const;
68 
69  /**
70  * Getter for the dataset.
71  *
72  * \return the dataset encapsulated by this module.
73  */
74  virtual boost::shared_ptr< WDataSet > getDataSet() = 0;
75 
76  /**
77  * Sets the filename of the file to load. If this method is called multiple times it has no effect. It has to be called right after
78  * construction BEFORE running the data module.
79  *
80  * \note The reason for using this method to set the filename instead of a property is, that a property gets set AFTER ready(), but this (and
81  * only this module) needs it before ready got called.
82  *
83  * \param fname the name of the file
84  */
85  virtual void setFilename( boost::filesystem::path fname ) = 0;
86 
87  /**
88  * Gets the path of the file that has been loaded. It always is the value which has been set during the FIRST call of setFilename.
89  *
90  * \return the path of the file that has been loaded.
91  */
92  virtual boost::filesystem::path getFilename() const = 0;
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 adding and running the module.
99  *
100  * \param suppress true if suppress
101  */
102  virtual 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 private:
113  /**
114  * If true, data modules are instructed to suppress colormap registration.
115  */
117 };
118 
119 #endif // WDATAMODULE_H
120 
Base for all data loader modules.
Definition: WDataModule.h:38
boost::shared_ptr< const WDataModule > ConstSPtr
Convenience typedef for a boost::shared_ptr< const WDataModule >.
Definition: WDataModule.h:49
Class representing a single module of OpenWalnut.
Definition: WModule.h:83
virtual MODULE_TYPE getType() const
Gets the type of the module.
Definition: WDataModule.cpp:38
virtual void setFilename(boost::filesystem::path fname)=0
Sets the filename of the file to load.
virtual boost::shared_ptr< WDataSet > getDataSet()=0
Getter for the dataset.
virtual ~WDataModule()
Destructor.
Definition: WDataModule.cpp:33
virtual void setSuppressColormaps(bool suppress=true)
Allows suppression of colormap registration in data modules.
Definition: WDataModule.cpp:43
boost::shared_ptr< WDataModule > SPtr
Convenience typedef for a boost::shared_ptr< WDataModule >.
Definition: WDataModule.h:44
bool m_suppressColormaps
If true, data modules are instructed to suppress colormap registration.
Definition: WDataModule.h:116
WDataModule()
Default constructor.
Definition: WDataModule.cpp:27
bool getSuppressColormaps() const
Checks whether suppression of colormaps is active.
Definition: WDataModule.cpp:48
virtual boost::filesystem::path getFilename() const =0
Gets the path of the file that has been loaded.