OpenWalnut
1.4.0
|
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 #include <list> 00026 #include <string> 00027 00028 #include <boost/filesystem.hpp> 00029 00030 #include "exceptions/WPropertyNameMalformed.h" 00031 #include "WProperties.h" 00032 #include "WPropertyBase.h" 00033 #include "WPropertyGroupBase.h" 00034 #include "WPropertyVariable.h" 00035 00036 #include "WTransferFunction.h" 00037 00038 WPropertyBase::WPropertyBase( std::string name, std::string description ): 00039 boost::enable_shared_from_this< WPropertyBase >(), 00040 m_name( name ), 00041 m_description( description ), 00042 m_hidden( false ), 00043 m_purpose( PV_PURPOSE_PARAMETER ), 00044 signal_PropertyChange(), 00045 m_updateCondition( new WConditionSet() ) 00046 { 00047 // check name validity 00048 if( ( m_name.find( std::string( "/" ) ) != std::string::npos ) || m_name.empty() ) 00049 { 00050 throw WPropertyNameMalformed( std::string( "Property name \"" + name + 00051 "\" is malformed. Do not use slashes (\"/\") or empty strings in property names." ) ); 00052 } 00053 } 00054 00055 WPropertyBase::WPropertyBase( const WPropertyBase& from ): 00056 boost::enable_shared_from_this< WPropertyBase >(), 00057 m_name( from.m_name ), 00058 m_description( from.m_description ), 00059 m_hidden( from.m_hidden ), 00060 m_type( from.m_type ), 00061 m_purpose( from.m_purpose ), 00062 signal_PropertyChange(), // create a new and empty signal 00063 m_updateCondition( new WConditionSet() ) // create a new condition set. Do not copy it. 00064 { 00065 } 00066 00067 WPropertyBase::~WPropertyBase() 00068 { 00069 // cleanup 00070 } 00071 00072 std::string WPropertyBase::getName() const 00073 { 00074 return m_name; 00075 } 00076 00077 std::string WPropertyBase::getDescription() const 00078 { 00079 return m_description; 00080 } 00081 00082 PROPERTY_TYPE WPropertyBase::getType() const 00083 { 00084 return m_type; 00085 } 00086 00087 PROPERTY_PURPOSE WPropertyBase::getPurpose() const 00088 { 00089 return m_purpose; 00090 } 00091 00092 void WPropertyBase::setPurpose( PROPERTY_PURPOSE purpose ) 00093 { 00094 m_purpose = purpose; 00095 } 00096 00097 void WPropertyBase::updateType() 00098 { 00099 m_type = PV_UNKNOWN; 00100 } 00101 00102 bool WPropertyBase::isHidden() const 00103 { 00104 return m_hidden; 00105 } 00106 00107 void WPropertyBase::setHidden( bool hidden ) 00108 { 00109 if( m_hidden != hidden ) 00110 { 00111 m_hidden = hidden; 00112 m_updateCondition->notify(); 00113 } 00114 } 00115 00116 WPropInt WPropertyBase::toPropInt() 00117 { 00118 return boost::dynamic_pointer_cast< WPVInt >( shared_from_this() ); 00119 } 00120 00121 WPropDouble WPropertyBase::toPropDouble() 00122 { 00123 return boost::dynamic_pointer_cast< WPVDouble >( shared_from_this() ); 00124 } 00125 00126 WPropBool WPropertyBase::toPropBool() 00127 { 00128 return boost::dynamic_pointer_cast< WPVBool >( shared_from_this() ); 00129 } 00130 00131 WPropString WPropertyBase::toPropString() 00132 { 00133 return boost::dynamic_pointer_cast< WPVString >( shared_from_this() ); 00134 } 00135 00136 WPropFilename WPropertyBase::toPropFilename() 00137 { 00138 return boost::dynamic_pointer_cast< WPVFilename >( shared_from_this() ); 00139 } 00140 00141 WPropSelection WPropertyBase::toPropSelection() 00142 { 00143 return boost::dynamic_pointer_cast< WPVSelection >( shared_from_this() ); 00144 } 00145 00146 WPropColor WPropertyBase::toPropColor() 00147 { 00148 return boost::dynamic_pointer_cast< WPVColor >( shared_from_this() ); 00149 } 00150 00151 WPropPosition WPropertyBase::toPropPosition() 00152 { 00153 return boost::dynamic_pointer_cast< WPVPosition >( shared_from_this() ); 00154 } 00155 00156 WPropGroup WPropertyBase::toPropGroup() 00157 { 00158 return boost::dynamic_pointer_cast< WPVGroup >( shared_from_this() ); 00159 } 00160 00161 WPropertyGroupBase::SPtr WPropertyBase::toPropGroupBase() 00162 { 00163 return boost::dynamic_pointer_cast< WPropertyGroupBase >( shared_from_this() ); 00164 } 00165 00166 WPropMatrix4X4 WPropertyBase::toPropMatrix4X4() 00167 { 00168 return boost::dynamic_pointer_cast< WPVMatrix4X4 >( shared_from_this() ); 00169 } 00170 00171 WPropTrigger WPropertyBase::toPropTrigger() 00172 { 00173 return boost::dynamic_pointer_cast< WPVTrigger >( shared_from_this() ); 00174 } 00175 00176 WPropTransferFunction WPropertyBase::toPropTransferFunction() 00177 { 00178 return boost::dynamic_pointer_cast< WPVTransferFunction >( shared_from_this() ); 00179 } 00180 00181 boost::shared_ptr< WCondition > WPropertyBase::getUpdateCondition() const 00182 { 00183 return m_updateCondition; 00184 } 00185 00186 WPropInterval WPropertyBase::toPropInterval() 00187 { 00188 return boost::dynamic_pointer_cast< WPVInterval >( shared_from_this() ); 00189 } 00190