1
//---------------------------------------------------------------------------
3
// Project: OpenWalnut ( http://www.openwalnut.org )
5
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6
// For more information see http://www.openwalnut.org/copying
8
// This file is part of OpenWalnut.
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.
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.
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/>.
23
//---------------------------------------------------------------------------
28
#include <boost/filesystem.hpp>
30
#include "exceptions/WPropertyNameMalformed.h"
31
#include "WProperties.h"
32
#include "WPropertyBase.h"
33
#include "WPropertyGroupBase.h"
34
#include "WPropertyVariable.h"
36
#include "WTransferFunction.h"
38
WPropertyBase::WPropertyBase( std::string name, std::string description ):
39
boost::enable_shared_from_this< WPropertyBase >(),
41
m_description( description ),
43
m_purpose( PV_PURPOSE_PARAMETER ),
44
signal_PropertyChange(),
45
m_updateCondition( new WConditionSet() )
47
// check name validity
48
if( ( m_name.find( std::string( "/" ) ) != std::string::npos ) || m_name.empty() )
50
throw WPropertyNameMalformed( std::string( "Property name \"" + name +
51
"\" is malformed. Do not use slashes (\"/\") or empty strings in property names." ) );
55
WPropertyBase::WPropertyBase( const WPropertyBase& from ):
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.
67
WPropertyBase::~WPropertyBase()
72
std::string WPropertyBase::getName() const
77
std::string WPropertyBase::getDescription() const
82
PROPERTY_TYPE WPropertyBase::getType() const
87
PROPERTY_PURPOSE WPropertyBase::getPurpose() const
92
void WPropertyBase::setPurpose( PROPERTY_PURPOSE purpose )
97
void WPropertyBase::updateType()
102
bool WPropertyBase::isHidden() const
107
void WPropertyBase::setHidden( bool hidden )
109
if( m_hidden != hidden )
112
m_updateCondition->notify();
116
WPropInt WPropertyBase::toPropInt()
118
return boost::shared_static_cast< WPVInt >( shared_from_this() );
121
WPropDouble WPropertyBase::toPropDouble()
123
return boost::shared_static_cast< WPVDouble >( shared_from_this() );
126
WPropBool WPropertyBase::toPropBool()
128
return boost::shared_static_cast< WPVBool >( shared_from_this() );
131
WPropString WPropertyBase::toPropString()
133
return boost::shared_static_cast< WPVString >( shared_from_this() );
136
WPropFilename WPropertyBase::toPropFilename()
138
return boost::shared_static_cast< WPVFilename >( shared_from_this() );
141
WPropSelection WPropertyBase::toPropSelection()
143
return boost::shared_static_cast< WPVSelection >( shared_from_this() );
146
WPropColor WPropertyBase::toPropColor()
148
return boost::shared_static_cast< WPVColor >( shared_from_this() );
151
WPropPosition WPropertyBase::toPropPosition()
153
return boost::shared_static_cast< WPVPosition >( shared_from_this() );
156
WPropGroup WPropertyBase::toPropGroup()
158
return boost::shared_static_cast< WPVGroup >( shared_from_this() );
161
WPropertyGroupBase::SPtr WPropertyBase::toPropGroupBase()
163
return boost::shared_static_cast< WPropertyGroupBase >( shared_from_this() );
166
WPropMatrix4X4 WPropertyBase::toPropMatrix4X4()
168
return boost::shared_static_cast< WPVMatrix4X4 >( shared_from_this() );
171
WPropTrigger WPropertyBase::toPropTrigger()
173
return boost::shared_static_cast< WPVTrigger >( shared_from_this() );
176
WPropTransferFunction WPropertyBase::toPropTransferFunction()
178
return boost::shared_static_cast< WPVTransferFunction >( shared_from_this() );
181
boost::shared_ptr< WCondition > WPropertyBase::getUpdateCondition() const
183
return m_updateCondition;