OpenWalnut  1.3.1
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  * This constructor should be used if a dataSet does not stem from a file.
56  * It presets the correpsonding filename as empty string.
57  */
58  WDataSet();
59 
60  /**
61  * Since WDataSet is a base class and thus should be polymorphic we add
62  * virtual destructor.
63  */
64  virtual ~WDataSet()
65  {
66  }
67 
68  /**
69  * Set the name of the file that this data set stems from.
70  *
71  * \param filename the string representing the name
72  */
73  void setFilename( const std::string filename );
74 
75  /**
76  * Get the name of the file that this data set stems from.
77  *
78  * \return the filename.
79  */
80  std::string getFilename() const;
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  * \deprecated use setFilename instead
88  */
89  OW_API_DEPRECATED void setFileName( const std::string filename );
90 
91  /**
92  * Get the name of the file that this data set stems from.
93  *
94  * \deprecated use getFilename instead
95  * \return the filename.
96  */
97  OW_API_DEPRECATED std::string getFileName() const;
98 
99  /**
100  * Determines whether this dataset can be used as a texture.
101  *
102  * \return true if usable as texture.
103  */
104  virtual bool isTexture() const;
105 
106  /**
107  * Checks if this dataset is a vector dataset.
108  *
109  * \return Returns a nonempty shared_ptr to it if it is a vector dataset, otherwise the pointer is empty!
110  */
111  virtual boost::shared_ptr< WDataSetVector > isVectorDataSet();
112 
113  /**
114  * Returns the texture- representation of the dataset. May throw an exception if no texture is available.
115  *
116  * \return The texture.
117  * \deprecated
118  */
119  virtual osg::ref_ptr< WDataTexture3D > getTexture() const;
120 
121  /**
122  * Gets the name of this prototype.
123  *
124  * \return the name.
125  */
126  virtual const std::string getName() const;
127 
128  /**
129  * Gets the description for this prototype.
130  *
131  * \return the description
132  */
133  virtual const std::string getDescription() const;
134 
135  /**
136  * Returns a prototype instantiated with the true type of the deriving class.
137  *
138  * \return the prototype.
139  */
140  static boost::shared_ptr< WPrototyped > getPrototype();
141 
142  /**
143  * Return a pointer to the properties object of the dataset. Add all the modifiable settings here. This allows the user to modify several
144  * properties of a dataset.
145  *
146  * \return the properties.
147  */
148  boost::shared_ptr< WProperties > getProperties() const;
149 
150  /**
151  * Return a pointer to the information properties object of the dataset. The dataset intends these properties to not be modified.
152  *
153  * \return the properties.
154  */
155  boost::shared_ptr< WProperties > getInformationProperties() const;
156 
157 protected:
158  /**
159  * The prototype as singleton.
160  */
161  static boost::shared_ptr< WPrototyped > m_prototype;
162 
163  /**
164  * The property object for the dataset.
165  */
166  boost::shared_ptr< WProperties > m_properties;
167 
168  /**
169  * The property object for the dataset containing only props whose purpose is "PV_PURPOSE_INFORMNATION". It is useful to define some property
170  * 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
171  * m_properties.
172  */
173  boost::shared_ptr< WProperties > m_infoProperties;
174 
175 private:
176  /**
177  * Name of the file this data set was loaded from. This information
178  * may allow hollowing data sets later. DataSets that were not loaded
179  * from a file should have the empty string stored here.
180  */
181  std::string m_filename;
182 };
183 
184 #endif // WDATASET_H
185