OpenWalnut  1.2.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
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 #include "WExportDataHandler.h"
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 OWDATAHANDLER_EXPORT 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 its 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  * \param fileName the string representing the name
71  */
72  void setFileName( const std::string fileName );
73 
74  /**
75  * Get the name of the file that this data set stems from.
76  *
77  * \return the filename.
78  */
79  std::string getFileName() const;
80 
81  /**
82  * Determines whether this dataset can be used as a texture.
83  *
84  * \return true if usable as texture.
85  */
86  virtual bool isTexture() const;
87 
88  /**
89  * Checks if this dataset is a vector dataset.
90  *
91  * \return Returns a nonempty shared_ptr to it if it is a vector dataset, otherwise the pointer is empty!
92  */
93  virtual boost::shared_ptr< WDataSetVector > isVectorDataSet();
94 
95  /**
96  * Returns the texture- representation of the dataset. May throw an exception if no texture is available.
97  *
98  * \return The texture.
99  * \deprecated
100  */
101  virtual osg::ref_ptr< WDataTexture3D > getTexture() const;
102 
103  /**
104  * Gets the name of this prototype.
105  *
106  * \return the name.
107  */
108  virtual const std::string getName() const;
109 
110  /**
111  * Gets the description for this prototype.
112  *
113  * \return the description
114  */
115  virtual const std::string getDescription() const;
116 
117  /**
118  * Returns a prototype instantiated with the true type of the deriving class.
119  *
120  * \return the prototype.
121  */
122  static boost::shared_ptr< WPrototyped > getPrototype();
123 
124  /**
125  * Return a pointer to the properties object of the dataset. Add all the modifiable settings here. This allows the user to modify several
126  * properties of a dataset.
127  *
128  * \return the properties.
129  */
130  boost::shared_ptr< WProperties > getProperties() const;
131 
132  /**
133  * Return a pointer to the information properties object of the dataset. The dataset intends these properties to not be modified.
134  *
135  * \return the properties.
136  */
137  boost::shared_ptr< WProperties > getInformationProperties() const;
138 
139 protected:
140 
141  /**
142  * The prototype as singleton.
143  */
144  static boost::shared_ptr< WPrototyped > m_prototype;
145 
146  /**
147  * The property object for the dataset.
148  */
149  boost::shared_ptr< WProperties > m_properties;
150 
151  /**
152  * The property object for the dataset containing only props whose purpose is "PV_PURPOSE_INFORMNATION". It is useful to define some property
153  * 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
154  * m_properties.
155  */
156  boost::shared_ptr< WProperties > m_infoProperties;
157 
158 private:
159  /**
160  * Name of the file this data set was loaded from. This information
161  * may allow hollowing data sets later. DataSets that were not loaded
162  * from a file should have the empty string stored here.
163  */
164  std::string m_fileName;
165 };
166 
167 #endif // WDATASET_H
168