OpenWalnut  1.4.0
WDataSet.h
00001 //---------------------------------------------------------------------------
00002 //
00003 // Project: OpenWalnut ( http://www.openwalnut.org )
00004 //
00005 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
00006 // For more information see http://www.openwalnut.org/copying
00007 //
00008 // This file is part of OpenWalnut.
00009 //
00010 // OpenWalnut is free software: you can redistribute it and/or modify
00011 // it under the terms of the GNU Lesser General Public License as published by
00012 // the Free Software Foundation, either version 3 of the License, or
00013 // (at your option) any later version.
00014 //
00015 // OpenWalnut is distributed in the hope that it will be useful,
00016 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018 // GNU Lesser General Public License for more details.
00019 //
00020 // You should have received a copy of the GNU Lesser General Public License
00021 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
00022 //
00023 //---------------------------------------------------------------------------
00024 
00025 #ifndef WDATASET_H
00026 #define WDATASET_H
00027 
00028 #include <string>
00029 
00030 #include <boost/shared_ptr.hpp>
00031 #include <boost/enable_shared_from_this.hpp>
00032 
00033 #include <osg/ref_ptr>
00034 
00035 #include "../common/WDefines.h"
00036 #include "../common/WProperties.h"
00037 #include "../common/WTransferable.h"
00038 #include "WDataTexture3D.h"
00039 
00040 
00041 class WCondition;
00042 class WDataSetVector;
00043 
00044 /**
00045  * Base class for all data set types. This class has a number of subclasses
00046  * specifying the different types of data sets. Two of the dataset types
00047  * represent single and time-dependent datasets (compound of several time
00048  * steps) respectively.
00049  * \ingroup dataHandler
00050  */
00051 class WDataSet: public WTransferable, public boost::enable_shared_from_this< WDataSet > // NOLINT
00052 {
00053 public:
00054     /**
00055      * Shared pointer abbreviation to a instance of this class.
00056      */
00057     typedef boost::shared_ptr< WDataSet > SPtr;
00058 
00059     /**
00060      * Shared pointer abbreviation to a const instance of this class.
00061      */
00062     typedef boost::shared_ptr< const WDataSet > ConstSPtr;
00063 
00064     /**
00065      * This constructor should be used if a dataSet does not stem from a file.
00066      * It presets the correpsonding filename as empty string.
00067      */
00068     WDataSet();
00069 
00070     /**
00071      * Since WDataSet is a base class and thus should be polymorphic we add
00072      * virtual destructor.
00073      */
00074     virtual ~WDataSet()
00075     {
00076     }
00077 
00078     /**
00079      * Set the name of the file that this data set stems from.
00080      *
00081      * \param filename the string representing the name
00082      */
00083     void setFilename( const std::string filename );
00084 
00085     /**
00086      * Get the name of the file that this data set stems from.
00087      *
00088      * \return the filename.
00089      */
00090     std::string getFilename() const;
00091 
00092     /**
00093      * Set the name of the file that this data set stems from.
00094      *
00095      * \param filename the string representing the name
00096      *
00097      * \deprecated use setFilename instead
00098      */
00099     OW_API_DEPRECATED void setFileName( const std::string filename );
00100 
00101     /**
00102      * Get the name of the file that this data set stems from.
00103      *
00104      * \deprecated use getFilename instead
00105      * \return the filename.
00106      */
00107     OW_API_DEPRECATED std::string getFileName() const;
00108 
00109     /**
00110      * Determines whether this dataset can be used as a texture.
00111      *
00112      * \return true if usable as texture.
00113      */
00114     virtual bool isTexture() const;
00115 
00116     /**
00117      * Checks if this dataset is a vector dataset.
00118      *
00119      * \return Returns a nonempty shared_ptr to it if it is a vector dataset, otherwise the pointer is empty!
00120      */
00121     virtual boost::shared_ptr< WDataSetVector > isVectorDataSet();
00122 
00123     /**
00124      * Returns the texture- representation of the dataset. May throw an exception if no texture is available.
00125      *
00126      * \return The texture.
00127      * \deprecated
00128      */
00129     virtual osg::ref_ptr< WDataTexture3D > getTexture() const;
00130 
00131     /**
00132      * Gets the name of this prototype.
00133      *
00134      * \return the name.
00135      */
00136     virtual const std::string getName() const;
00137 
00138     /**
00139      * Gets the description for this prototype.
00140      *
00141      * \return the description
00142      */
00143     virtual const std::string getDescription() const;
00144 
00145     /**
00146      * Returns a prototype instantiated with the true type of the deriving class.
00147      *
00148      * \return the prototype.
00149      */
00150     static boost::shared_ptr< WPrototyped > getPrototype();
00151 
00152     /**
00153      * Return a pointer to the properties object of the dataset. Add all the modifiable settings here. This allows the user to modify several
00154      * properties of a dataset.
00155      *
00156      * \return the properties.
00157      */
00158     boost::shared_ptr< WProperties > getProperties() const;
00159 
00160     /**
00161      * Return a pointer to the information properties object of the dataset. The dataset intends these properties to not be modified.
00162      *
00163      * \return the properties.
00164      */
00165     boost::shared_ptr< WProperties > getInformationProperties() const;
00166 
00167 protected:
00168     /**
00169      * The prototype as singleton.
00170      */
00171     static boost::shared_ptr< WPrototyped > m_prototype;
00172 
00173     /**
00174      * The property object for the dataset.
00175      */
00176     boost::shared_ptr< WProperties > m_properties;
00177 
00178     /**
00179      * The property object for the dataset containing only props whose purpose is "PV_PURPOSE_INFORMNATION". It is useful to define some property
00180      * 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
00181      * m_properties.
00182      */
00183     boost::shared_ptr< WProperties > m_infoProperties;
00184 
00185 private:
00186     /**
00187      * Name of the file this data set was loaded from. This information
00188      * may allow hollowing data sets later. DataSets that were not loaded
00189      * from a file should have the empty string stored here.
00190      */
00191     std::string m_filename;
00192 };
00193 
00194 #endif  // WDATASET_H
00195