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