OpenWalnut  1.5.0dev
WDataSet.cpp
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 #include <memory>
26 #include <string>
27 
28 #include "../common/WAssert.h"
29 #include "../common/WCondition.h"
30 #include "../common/WTransferable.h"
31 #include "WDataSet.h"
32 #include "WDataSetVector.h"
33 #include "WDataTexture3D.h"
34 #include "exceptions/WDHException.h"
35 
36 // prototype instance as singleton
37 std::shared_ptr< WPrototyped > WDataSet::m_prototype = std::shared_ptr< WPrototyped >();
38 
40  : WTransferable(),
41  m_properties( std::shared_ptr< WProperties >( new WProperties( "Data-Set Properties", "Properties of a data-set" ) ) ),
42  m_infoProperties( std::shared_ptr< WProperties >( new WProperties( "Data-Set Info Properties", "Data-set's information properties" ) ) ),
43  m_filename( "" )
44 {
45  m_infoProperties->setPurpose( PV_PURPOSE_INFORMATION );
46 }
47 
48 void WDataSet::setFileName( const std::string filename )
49 {
50  setFilename( filename );
51 }
52 
53 std::string WDataSet::getFileName() const
54 {
55  return getFilename();
56 }
57 
58 void WDataSet::setFilename( const std::string filename )
59 {
60  WAssert( filename != "", "No filename set for data set." );
61  m_filename = filename;
62 }
63 
64 std::string WDataSet::getFilename() const
65 {
66  return m_filename;
67 }
68 
69 bool WDataSet::isTexture() const
70 {
71  return false;
72 }
73 
74 osg::ref_ptr< WDataTexture3D > WDataSet::getTexture() const
75 {
76  throw WDHException( std::string( "This dataset does not provide a texture." ) );
77 }
78 
79 const std::string WDataSet::getName() const
80 {
81  return "WDataSet";
82 }
83 
84 const std::string WDataSet::getDescription() const
85 {
86  return "Encapsulates the whole common feature set of all datasets.";
87 }
88 
89 std::shared_ptr< WPrototyped > WDataSet::getPrototype()
90 {
91  if( !m_prototype )
92  {
93  m_prototype = std::shared_ptr< WPrototyped >( new WDataSet() );
94  }
95 
96  return m_prototype;
97 }
98 
99 std::shared_ptr< WDataSetVector > WDataSet::isVectorDataSet()
100 {
101  return std::shared_ptr< WDataSetVector >();
102 }
103 
104 std::shared_ptr< WProperties > WDataSet::getProperties() const
105 {
106  return m_properties;
107 }
108 
109 std::shared_ptr< WProperties > WDataSet::getInformationProperties() const
110 {
111  return m_infoProperties;
112 }
113 
General purpose exception and therefore base class for all DataHandler related exceptions.
Definition: WDHException.h:40
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::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
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 to manage properties of an object and to provide convenience methods for easy access and manipu...
Class building the interface for classes that might be transferred using WModuleConnector.
Definition: WTransferable.h:38