OpenWalnut  1.4.0
WDataSet.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 WDATASET_H
26 #define WDATASET_H
27 
28 #include <string>
29 
30 #ifndef Q_MOC_RUN
31 #include <boost/shared_ptr.hpp>
32 #endif
33 #ifndef Q_MOC_RUN
34 #include <boost/enable_shared_from_this.hpp>
35 #endif
36 
37 #include <osg/ref_ptr>
38 
39 #include "../common/WDefines.h"
40 #include "../common/WProperties.h"
41 #include "../common/WTransferable.h"
42 #include "WDataTexture3D.h"
43 
44 
45 class WCondition;
46 class WDataSetVector;
47 
48 /**
49  * Base class for all data set types. This class has a number of subclasses
50  * specifying the different types of data sets. Two of the dataset types
51  * represent single and time-dependent datasets (compound of several time
52  * steps) respectively.
53  * \ingroup dataHandler
54  */
55 class WDataSet: public WTransferable, public boost::enable_shared_from_this< WDataSet > // NOLINT
56 {
57 public:
58  /**
59  * Shared pointer abbreviation to a instance of this class.
60  */
61  typedef boost::shared_ptr< WDataSet > SPtr;
62 
63  /**
64  * Shared pointer abbreviation to a const instance of this class.
65  */
66  typedef boost::shared_ptr< const WDataSet > ConstSPtr;
67 
68  /**
69  * This constructor should be used if a dataSet does not stem from a file.
70  * It presets the correpsonding filename as empty string.
71  */
72  WDataSet();
73 
74  /**
75  * Since WDataSet is a base class and thus should be polymorphic we add
76  * virtual destructor.
77  */
78  virtual ~WDataSet()
79  {
80  }
81 
82  /**
83  * Set the name of the file that this data set stems from.
84  *
85  * \param filename the string representing the name
86  */
87  void setFilename( const std::string filename );
88 
89  /**
90  * Get the name of the file that this data set stems from.
91  *
92  * \return the filename.
93  */
94  std::string getFilename() const;
95 
96  /**
97  * Set the name of the file that this data set stems from.
98  *
99  * \param filename the string representing the name
100  *
101  * \deprecated use setFilename instead
102  */
103  OW_API_DEPRECATED void setFileName( const std::string filename );
104 
105  /**
106  * Get the name of the file that this data set stems from.
107  *
108  * \deprecated use getFilename instead
109  * \return the filename.
110  */
111  OW_API_DEPRECATED std::string getFileName() const;
112 
113  /**
114  * Determines whether this dataset can be used as a texture.
115  *
116  * \return true if usable as texture.
117  */
118  virtual bool isTexture() const;
119 
120  /**
121  * Checks if this dataset is a vector dataset.
122  *
123  * \return Returns a nonempty shared_ptr to it if it is a vector dataset, otherwise the pointer is empty!
124  */
125  virtual boost::shared_ptr< WDataSetVector > isVectorDataSet();
126 
127  /**
128  * Returns the texture- representation of the dataset. May throw an exception if no texture is available.
129  *
130  * \return The texture.
131  * \deprecated
132  */
133  virtual osg::ref_ptr< WDataTexture3D > getTexture() const;
134 
135  /**
136  * Gets the name of this prototype.
137  *
138  * \return the name.
139  */
140  virtual const std::string getName() const;
141 
142  /**
143  * Gets the description for this prototype.
144  *
145  * \return the description
146  */
147  virtual const std::string getDescription() const;
148 
149  /**
150  * Returns a prototype instantiated with the true type of the deriving class.
151  *
152  * \return the prototype.
153  */
154  static boost::shared_ptr< WPrototyped > getPrototype();
155 
156  /**
157  * Return a pointer to the properties object of the dataset. Add all the modifiable settings here. This allows the user to modify several
158  * properties of a dataset.
159  *
160  * \return the properties.
161  */
162  boost::shared_ptr< WProperties > getProperties() const;
163 
164  /**
165  * Return a pointer to the information properties object of the dataset. The dataset intends these properties to not be modified.
166  *
167  * \return the properties.
168  */
169  boost::shared_ptr< WProperties > getInformationProperties() const;
170 
171 protected:
172  /**
173  * The prototype as singleton.
174  */
175  static boost::shared_ptr< WPrototyped > m_prototype;
176 
177  /**
178  * The property object for the dataset.
179  */
180  boost::shared_ptr< WProperties > m_properties;
181 
182  /**
183  * The property object for the dataset containing only props whose purpose is "PV_PURPOSE_INFORMNATION". It is useful to define some property
184  * to only be of informational nature. The GUI does not modify them. As it is a WProperties instance, you can use it the same way as
185  * m_properties.
186  */
187  boost::shared_ptr< WProperties > m_infoProperties;
188 
189 private:
190  /**
191  * Name of the file this data set was loaded from. This information
192  * may allow hollowing data sets later. DataSets that were not loaded
193  * from a file should have the empty string stored here.
194  */
195  std::string m_filename;
196 };
197 
198 #endif // WDATASET_H
199 
This data set type contains vectors as values.
Base class for all data set types.
Definition: WDataSet.h:55
static boost::shared_ptr< WPrototyped > getPrototype()
Returns a prototype instantiated with the true type of the deriving class.
Definition: WDataSet.cpp:88
virtual ~WDataSet()
Since WDataSet is a base class and thus should be polymorphic we add virtual destructor.
Definition: WDataSet.h:78
OW_API_DEPRECATED void setFileName(const std::string filename)
Set the name of the file that this data set stems from.
Definition: WDataSet.cpp:47
virtual const std::string getDescription() const
Gets the description for this prototype.
Definition: WDataSet.cpp:83
std::string getFilename() const
Get the name of the file that this data set stems from.
Definition: WDataSet.cpp:63
boost::shared_ptr< WProperties > getInformationProperties() const
Return a pointer to the information properties object of the dataset.
Definition: WDataSet.cpp:108
virtual const std::string getName() const
Gets the name of this prototype.
Definition: WDataSet.cpp:78
void setFilename(const std::string filename)
Set the name of the file that this data set stems from.
Definition: WDataSet.cpp:57
boost::shared_ptr< WProperties > m_properties
The property object for the dataset.
Definition: WDataSet.h:180
Class building the interface for classes that might be transferred using WModuleConnector.
Definition: WTransferable.h:37
OW_API_DEPRECATED std::string getFileName() const
Get the name of the file that this data set stems from.
Definition: WDataSet.cpp:52
#define OW_API_DEPRECATED
In order to mark functions for the compiler as deprecated we need to put this before each deprecated ...
Definition: WDefines.h:44
boost::shared_ptr< WProperties > getProperties() const
Return a pointer to the properties object of the dataset.
Definition: WDataSet.cpp:103
boost::shared_ptr< WProperties > m_infoProperties
The property object for the dataset containing only props whose purpose is "PV_PURPOSE_INFORMNATION"...
Definition: WDataSet.h:187
virtual boost::shared_ptr< WDataSetVector > isVectorDataSet()
Checks if this dataset is a vector dataset.
Definition: WDataSet.cpp:98
std::string m_filename
Name of the file this data set was loaded from.
Definition: WDataSet.h:195
Class to encapsulate boost::condition_variable_any.
Definition: WCondition.h:47
boost::shared_ptr< const WDataSet > ConstSPtr
Shared pointer abbreviation to a const instance of this class.
Definition: WDataSet.h:66
static boost::shared_ptr< WPrototyped > m_prototype
The prototype as singleton.
Definition: WDataSet.h:175
virtual osg::ref_ptr< WDataTexture3D > getTexture() const
Returns the texture- representation of the dataset.
Definition: WDataSet.cpp:73
WDataSet()
This constructor should be used if a dataSet does not stem from a file.
Definition: WDataSet.cpp:38
virtual bool isTexture() const
Determines whether this dataset can be used as a texture.
Definition: WDataSet.cpp:68
boost::shared_ptr< WDataSet > SPtr
Shared pointer abbreviation to a instance of this class.
Definition: WDataSet.h:61