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