OpenWalnut  1.2.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
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 // Use filesystem version 2 for compatibility with newer boost versions.
29 #ifndef BOOST_FILESYSTEM_VERSION
30  #define BOOST_FILESYSTEM_VERSION 2
31 #endif
32 #include <boost/filesystem.hpp>
33 
34 #include "exceptions/WPropertyNameMalformed.h"
35 #include "WProperties.h"
36 #include "WPropertyBase.h"
37 #include "WPropertyVariable.h"
38 
39 WPropertyBase::WPropertyBase( std::string name, std::string description ):
41  m_name( name ),
42  m_description( description ),
43  m_hidden( false ),
44  m_purpose( PV_PURPOSE_PARAMETER ),
45  signal_PropertyChange(),
46  m_updateCondition( new WConditionSet() )
47 {
48  // check name validity
49  if( ( m_name.find( std::string( "/" ) ) != std::string::npos ) || m_name.empty() )
50  {
51  throw WPropertyNameMalformed( std::string( "Property name \"" + name +
52  "\" is malformed. Do not use slashes (\"/\") or empty strings in property names." ) );
53  }
54 }
55 
58  m_name( from.m_name ),
59  m_description( from.m_description ),
60  m_hidden( from.m_hidden ),
61  m_type( from.m_type ),
62  m_purpose( from.m_purpose ),
63  signal_PropertyChange(), // create a new and empty signal
64  m_updateCondition( new WConditionSet() ) // create a new condition set. Do not copy it.
65 {
66 }
67 
69 {
70  // cleanup
71 }
72 
73 std::string WPropertyBase::getName() const
74 {
75  return m_name;
76 }
77 
78 std::string WPropertyBase::getDescription() const
79 {
80  return m_description;
81 }
82 
83 PROPERTY_TYPE WPropertyBase::getType() const
84 {
85  return m_type;
86 }
87 
88 PROPERTY_PURPOSE WPropertyBase::getPurpose() const
89 {
90  return m_purpose;
91 }
92 
93 void WPropertyBase::setPurpose( PROPERTY_PURPOSE purpose )
94 {
95  m_purpose = purpose;
96 }
97 
99 {
100  m_type = PV_UNKNOWN;
101 }
102 
104 {
105  return m_hidden;
106 }
107 
108 void WPropertyBase::setHidden( bool hidden )
109 {
110  if( m_hidden != hidden )
111  {
112  m_hidden = hidden;
113  m_updateCondition->notify();
114  }
115 }
116 
118 {
119  return boost::shared_static_cast< WPVInt >( shared_from_this() );
120 }
121 
123 {
124  return boost::shared_static_cast< WPVDouble >( shared_from_this() );
125 }
126 
128 {
129  return boost::shared_static_cast< WPVBool >( shared_from_this() );
130 }
131 
133 {
134  return boost::shared_static_cast< WPVString >( shared_from_this() );
135 }
136 
138 {
139  return boost::shared_static_cast< WPVFilename >( shared_from_this() );
140 }
141 
143 {
144  return boost::shared_static_cast< WPVSelection >( shared_from_this() );
145 }
146 
148 {
149  return boost::shared_static_cast< WPVColor >( shared_from_this() );
150 }
151 
153 {
154  return boost::shared_static_cast< WPVPosition >( shared_from_this() );
155 }
156 
158 {
159  return boost::shared_static_cast< WPVGroup >( shared_from_this() );
160 }
161 
163 {
164  return boost::shared_static_cast< WPVMatrix4X4 >( shared_from_this() );
165 }
166 
168 {
169  return boost::shared_static_cast< WPVTrigger >( shared_from_this() );
170 }
171 
172 boost::shared_ptr< WCondition > WPropertyBase::getUpdateCondition() const
173 {
174  return m_updateCondition;
175 }
176