OpenWalnut  1.4.0
WPropertyBase.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 <list>
26 #include <string>
27 
28 #include <boost/filesystem.hpp>
29 
30 #include "exceptions/WPropertyNameMalformed.h"
31 #include "WProperties.h"
32 #include "WPropertyBase.h"
33 #include "WPropertyGroupBase.h"
34 #include "WPropertyVariable.h"
35 
36 #include "WTransferFunction.h"
37 
38 WPropertyBase::WPropertyBase( std::string name, std::string description ):
39  boost::enable_shared_from_this< WPropertyBase >(),
40  m_name( name ),
41  m_description( description ),
42  m_hidden( false ),
43  m_purpose( PV_PURPOSE_PARAMETER ),
44  signal_PropertyChange(),
45  m_updateCondition( new WConditionSet() )
46 {
47  // check name validity
48  if( ( m_name.find( std::string( "/" ) ) != std::string::npos ) || m_name.empty() )
49  {
50  throw WPropertyNameMalformed( std::string( "Property name \"" + name +
51  "\" is malformed. Do not use slashes (\"/\") or empty strings in property names." ) );
52  }
53 }
54 
56  boost::enable_shared_from_this< WPropertyBase >(),
57  m_name( from.m_name ),
58  m_description( from.m_description ),
59  m_hidden( from.m_hidden ),
60  m_type( from.m_type ),
61  m_purpose( from.m_purpose ),
62  signal_PropertyChange(), // create a new and empty signal
63  m_updateCondition( new WConditionSet() ) // create a new condition set. Do not copy it.
64 {
65 }
66 
68 {
69  // cleanup
70 }
71 
72 std::string WPropertyBase::getName() const
73 {
74  return m_name;
75 }
76 
77 std::string WPropertyBase::getDescription() const
78 {
79  return m_description;
80 }
81 
82 PROPERTY_TYPE WPropertyBase::getType() const
83 {
84  return m_type;
85 }
86 
87 PROPERTY_PURPOSE WPropertyBase::getPurpose() const
88 {
89  return m_purpose;
90 }
91 
92 void WPropertyBase::setPurpose( PROPERTY_PURPOSE purpose )
93 {
94  m_purpose = purpose;
95 }
96 
98 {
99  m_type = PV_UNKNOWN;
100 }
101 
103 {
104  return m_hidden;
105 }
106 
107 void WPropertyBase::setHidden( bool hidden )
108 {
109  if( m_hidden != hidden )
110  {
111  m_hidden = hidden;
112  m_updateCondition->notify();
113  }
114 }
115 
117 {
118  return boost::dynamic_pointer_cast< WPVInt >( shared_from_this() );
119 }
120 
122 {
123  return boost::dynamic_pointer_cast< WPVDouble >( shared_from_this() );
124 }
125 
127 {
128  return boost::dynamic_pointer_cast< WPVBool >( shared_from_this() );
129 }
130 
132 {
133  return boost::dynamic_pointer_cast< WPVString >( shared_from_this() );
134 }
135 
137 {
138  return boost::dynamic_pointer_cast< WPVFilename >( shared_from_this() );
139 }
140 
142 {
143  return boost::dynamic_pointer_cast< WPVSelection >( shared_from_this() );
144 }
145 
147 {
148  return boost::dynamic_pointer_cast< WPVColor >( shared_from_this() );
149 }
150 
152 {
153  return boost::dynamic_pointer_cast< WPVPosition >( shared_from_this() );
154 }
155 
157 {
158  return boost::dynamic_pointer_cast< WPVGroup >( shared_from_this() );
159 }
160 
162 {
163  return boost::dynamic_pointer_cast< WPropertyGroupBase >( shared_from_this() );
164 }
165 
167 {
168  return boost::dynamic_pointer_cast< WPVMatrix4X4 >( shared_from_this() );
169 }
170 
172 {
173  return boost::dynamic_pointer_cast< WPVTrigger >( shared_from_this() );
174 }
175 
177 {
178  return boost::dynamic_pointer_cast< WPVTransferFunction >( shared_from_this() );
179 }
180 
181 boost::shared_ptr< WCondition > WPropertyBase::getUpdateCondition() const
182 {
183  return m_updateCondition;
184 }
185 
187 {
188  return boost::dynamic_pointer_cast< WPVInterval >( shared_from_this() );
189 }
190