Commit ea79840f authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum

[CHANGE] - in properties, now const refs are used.

parent 80e24939
...@@ -161,7 +161,7 @@ public: ...@@ -161,7 +161,7 @@ public:
* *
* \return true if it is a valid/acceptable value. * \return true if it is a valid/acceptable value.
*/ */
virtual bool accept( T newValue ); virtual bool accept( const T& newValue );
/** /**
* This method is useful to ensure, that there is a valid value in the property. Assume the following situation. The property p got a min * This method is useful to ensure, that there is a valid value in the property. Assume the following situation. The property p got a min
...@@ -174,7 +174,7 @@ public: ...@@ -174,7 +174,7 @@ public:
* *
* \return true if the new value has been accepted ( if it was valid ) - for short true if the property NOW is valid * \return true if the new value has been accepted ( if it was valid ) - for short true if the property NOW is valid
*/ */
virtual bool ensureValidity( T newValidValue, bool suppressNotification = false ); virtual bool ensureValidity( const T& newValidValue, bool suppressNotification = false );
/** /**
* Class building the base for user defined constraints on a property instance. * Class building the base for user defined constraints on a property instance.
...@@ -201,7 +201,7 @@ public: ...@@ -201,7 +201,7 @@ public:
* *
* \return true whenever the new value is acceptable for the property. * \return true whenever the new value is acceptable for the property.
*/ */
virtual bool accept( boost::shared_ptr< WPropertyVariable< T > > property, T value ) = 0; virtual bool accept( boost::shared_ptr< WPropertyVariable< T > > property, const T& value ) = 0;
/** /**
* Allows simple identification of the real constraint type. * Allows simple identification of the real constraint type.
...@@ -273,7 +273,7 @@ public: ...@@ -273,7 +273,7 @@ public:
* *
* \return the new constraint. * \return the new constraint.
*/ */
static PropertyConstraintMin minConstraint( T min ); static PropertyConstraintMin minConstraint( const T& min );
/** /**
* Creates a new WPropertyConstraintMax for this WPropertyVariable. * Creates a new WPropertyConstraintMax for this WPropertyVariable.
...@@ -282,7 +282,7 @@ public: ...@@ -282,7 +282,7 @@ public:
* *
* \return the new constraint. * \return the new constraint.
*/ */
static PropertyConstraintMax maxConstraint( T max ); static PropertyConstraintMax maxConstraint( const T& max );
/** /**
* Set a minimum constraint. * Set a minimum constraint.
...@@ -291,7 +291,7 @@ public: ...@@ -291,7 +291,7 @@ public:
* *
* \return the newly created constraint. * \return the newly created constraint.
*/ */
PropertyConstraintMin setMin( T min ); PropertyConstraintMin setMin( const T& min );
/** /**
* Set a maximum constraint. * Set a maximum constraint.
...@@ -300,7 +300,7 @@ public: ...@@ -300,7 +300,7 @@ public:
* *
* \return the newly created constraint. * \return the newly created constraint.
*/ */
PropertyConstraintMax setMax( T max ); PropertyConstraintMax setMax( const T& max );
/** /**
* Gets the current minimum constraint value. * Gets the current minimum constraint value.
...@@ -404,7 +404,7 @@ public: ...@@ -404,7 +404,7 @@ public:
* \note set( get() ) == true * \note set( get() ) == true
* \note this is defined here to help the compiler to disambiguate between WFlag::set and the WPropertyBase::set. * \note this is defined here to help the compiler to disambiguate between WFlag::set and the WPropertyBase::set.
*/ */
virtual bool set( T value, bool suppressNotification = false ); virtual bool set( const T& value, bool suppressNotification = false );
/** /**
* Sets the specified value as recommended value. The difference to \ref set is simple. If some value was set using the method \ref set * Sets the specified value as recommended value. The difference to \ref set is simple. If some value was set using the method \ref set
...@@ -415,7 +415,7 @@ public: ...@@ -415,7 +415,7 @@ public:
* *
* \return true if value has been set successfully. * \return true if value has been set successfully.
*/ */
virtual bool setRecommendedValue( T value ); virtual bool setRecommendedValue( const T& value );
protected: protected:
...@@ -583,7 +583,7 @@ void WPropertyVariable< T >::propertyChangeNotifier() ...@@ -583,7 +583,7 @@ void WPropertyVariable< T >::propertyChangeNotifier()
} }
template < typename T > template < typename T >
bool WPropertyVariable< T >::accept( T newValue ) bool WPropertyVariable< T >::accept( const T& newValue )
{ {
// lock, lock vanishes if l looses focus // lock, lock vanishes if l looses focus
typename WPropertyVariable< T >::ConstraintContainerType::ReadTicket l = m_constraints->getReadTicket(); typename WPropertyVariable< T >::ConstraintContainerType::ReadTicket l = m_constraints->getReadTicket();
...@@ -640,14 +640,14 @@ bool WPropertyVariable< T >::set( boost::shared_ptr< WPropertyBase > value ) ...@@ -640,14 +640,14 @@ bool WPropertyVariable< T >::set( boost::shared_ptr< WPropertyBase > value )
} }
template < typename T > template < typename T >
bool WPropertyVariable< T >::set( T value, bool suppressNotification ) bool WPropertyVariable< T >::set( const T& value, bool suppressNotification )
{ {
m_notYetSet = false; m_notYetSet = false;
return WFlag< T >::set( value, suppressNotification ); return WFlag< T >::set( value, suppressNotification );
} }
template < typename T > template < typename T >
bool WPropertyVariable< T >::setRecommendedValue( T value ) bool WPropertyVariable< T >::setRecommendedValue( const T& value )
{ {
// NOTE: well this is quite problematic when used multi-threaded ... // NOTE: well this is quite problematic when used multi-threaded ...
if( m_notYetSet ) if( m_notYetSet )
...@@ -663,7 +663,7 @@ bool WPropertyVariable< T >::setRecommendedValue( T value ) ...@@ -663,7 +663,7 @@ bool WPropertyVariable< T >::setRecommendedValue( T value )
} }
template < typename T > template < typename T >
bool WPropertyVariable< T >::ensureValidity( T newValidValue, bool suppressNotification ) bool WPropertyVariable< T >::ensureValidity( const T& newValidValue, bool suppressNotification )
{ {
if( !accept( WFlag< T >::get() ) ) if( !accept( WFlag< T >::get() ) )
{ {
...@@ -700,19 +700,19 @@ void WPropertyVariable< T >::updateType() ...@@ -700,19 +700,19 @@ void WPropertyVariable< T >::updateType()
} }
template < typename T > template < typename T >
boost::shared_ptr< WPropertyConstraintMin< T > > WPropertyVariable< T >::minConstraint( T min ) boost::shared_ptr< WPropertyConstraintMin< T > > WPropertyVariable< T >::minConstraint( const T& min )
{ {
return boost::shared_ptr< WPropertyConstraintMin< T > >( new WPropertyConstraintMin< T >( min ) ); return boost::shared_ptr< WPropertyConstraintMin< T > >( new WPropertyConstraintMin< T >( min ) );
} }
template < typename T > template < typename T >
boost::shared_ptr< WPropertyConstraintMax< T > > WPropertyVariable< T >::maxConstraint( T max ) boost::shared_ptr< WPropertyConstraintMax< T > > WPropertyVariable< T >::maxConstraint( const T& max )
{ {
return boost::shared_ptr< WPropertyConstraintMax< T > >( new WPropertyConstraintMax< T >( max ) ); return boost::shared_ptr< WPropertyConstraintMax< T > >( new WPropertyConstraintMax< T >( max ) );
} }
template < typename T > template < typename T >
boost::shared_ptr< WPropertyConstraintMin< T > > WPropertyVariable< T >::setMin( T min ) boost::shared_ptr< WPropertyConstraintMin< T > > WPropertyVariable< T >::setMin( const T& min )
{ {
boost::shared_ptr< WPropertyConstraintMin< T > > c = minConstraint( min ); boost::shared_ptr< WPropertyConstraintMin< T > > c = minConstraint( min );
replaceConstraint( c, PC_MIN ); replaceConstraint( c, PC_MIN );
...@@ -720,7 +720,7 @@ boost::shared_ptr< WPropertyConstraintMin< T > > WPropertyVariable< T >::setMin( ...@@ -720,7 +720,7 @@ boost::shared_ptr< WPropertyConstraintMin< T > > WPropertyVariable< T >::setMin(
} }
template < typename T > template < typename T >
boost::shared_ptr< WPropertyConstraintMax< T > > WPropertyVariable< T >::setMax( T max ) boost::shared_ptr< WPropertyConstraintMax< T > > WPropertyVariable< T >::setMax( const T& max )
{ {
boost::shared_ptr< WPropertyConstraintMax< T > > c = maxConstraint( max ); boost::shared_ptr< WPropertyConstraintMax< T > > c = maxConstraint( max );
replaceConstraint( c, PC_MAX ); replaceConstraint( c, PC_MAX );
......
...@@ -53,7 +53,7 @@ public: ...@@ -53,7 +53,7 @@ public:
* *
* \return true if the file/path is a directory * \return true if the file/path is a directory
*/ */
virtual bool accept( boost::shared_ptr< WPropertyVariable< T > > property, T value ); virtual bool accept( boost::shared_ptr< WPropertyVariable< T > > property, const T& value );
/** /**
* Allows simple identification of the real constraint type. * Allows simple identification of the real constraint type.
...@@ -83,7 +83,7 @@ WPropertyConstraintIsDirectory< T >::~WPropertyConstraintIsDirectory() ...@@ -83,7 +83,7 @@ WPropertyConstraintIsDirectory< T >::~WPropertyConstraintIsDirectory()
} }
template < typename T > template < typename T >
bool WPropertyConstraintIsDirectory< T >::accept( boost::shared_ptr< WPropertyVariable< T > > /* property */, T value ) bool WPropertyConstraintIsDirectory< T >::accept( boost::shared_ptr< WPropertyVariable< T > > /* property */, const T& value )
{ {
return boost::filesystem::is_directory( value ); return boost::filesystem::is_directory( value );
} }
......
...@@ -54,7 +54,7 @@ public: ...@@ -54,7 +54,7 @@ public:
* *
* \return true if value.isValid() * \return true if value.isValid()
*/ */
virtual bool accept( boost::shared_ptr< WPropertyVariable< T > > property, T value ); virtual bool accept( boost::shared_ptr< WPropertyVariable< T > > property, const T& value );
/** /**
* Allows simple identification of the real constraint type. * Allows simple identification of the real constraint type.
...@@ -84,7 +84,7 @@ WPropertyConstraintIsValid< T >::~WPropertyConstraintIsValid() ...@@ -84,7 +84,7 @@ WPropertyConstraintIsValid< T >::~WPropertyConstraintIsValid()
} }
template < typename T > template < typename T >
bool WPropertyConstraintIsValid< T >::accept( boost::shared_ptr< WPropertyVariable< T > > /* property */, T value ) bool WPropertyConstraintIsValid< T >::accept( boost::shared_ptr< WPropertyVariable< T > > /* property */, const T& value )
{ {
return value.isValid(); return value.isValid();
} }
......
...@@ -55,7 +55,7 @@ public: ...@@ -55,7 +55,7 @@ public:
* *
* \return true if value <= m_max * \return true if value <= m_max
*/ */
virtual bool accept( boost::shared_ptr< WPropertyVariable< T > > property, T value ); virtual bool accept( boost::shared_ptr< WPropertyVariable< T > > property, const T& value );
/** /**
* Returns the current max value. * Returns the current max value.
...@@ -98,7 +98,7 @@ WPropertyConstraintMax< T >::~WPropertyConstraintMax() ...@@ -98,7 +98,7 @@ WPropertyConstraintMax< T >::~WPropertyConstraintMax()
} }
template < typename T > template < typename T >
bool WPropertyConstraintMax< T >::accept( boost::shared_ptr< WPropertyVariable< T > > /* property */, T value ) bool WPropertyConstraintMax< T >::accept( boost::shared_ptr< WPropertyVariable< T > > /* property */, const T& value )
{ {
return value <= m_max; return value <= m_max;
} }
......
...@@ -55,7 +55,7 @@ public: ...@@ -55,7 +55,7 @@ public:
* *
* \return true if value >= m_min * \return true if value >= m_min
*/ */
virtual bool accept( boost::shared_ptr< WPropertyVariable< T > > property, T value ); virtual bool accept( boost::shared_ptr< WPropertyVariable< T > > property, const T& value );
/** /**
* Returns the current min value. * Returns the current min value.
...@@ -98,7 +98,7 @@ WPropertyConstraintMin< T >::~WPropertyConstraintMin() ...@@ -98,7 +98,7 @@ WPropertyConstraintMin< T >::~WPropertyConstraintMin()
} }
template < typename T > template < typename T >
bool WPropertyConstraintMin< T >::accept( boost::shared_ptr< WPropertyVariable< T > > /* property */, T value ) bool WPropertyConstraintMin< T >::accept( boost::shared_ptr< WPropertyVariable< T > > /* property */, const T& value )
{ {
return value >= m_min; return value >= m_min;
} }
......
...@@ -54,7 +54,7 @@ public: ...@@ -54,7 +54,7 @@ public:
* *
* \return true if value >= m_min * \return true if value >= m_min
*/ */
virtual bool accept( boost::shared_ptr< WPropertyVariable< T > > property, T value ); virtual bool accept( boost::shared_ptr< WPropertyVariable< T > > property, const T& value );
/** /**
* Allows simple identification of the real constraint type. * Allows simple identification of the real constraint type.
...@@ -84,7 +84,7 @@ WPropertyConstraintNotEmpty< T >::~WPropertyConstraintNotEmpty() ...@@ -84,7 +84,7 @@ WPropertyConstraintNotEmpty< T >::~WPropertyConstraintNotEmpty()
} }
template < typename T > template < typename T >
bool WPropertyConstraintNotEmpty< T >::accept( boost::shared_ptr< WPropertyVariable< T > > /* property */, T value ) bool WPropertyConstraintNotEmpty< T >::accept( boost::shared_ptr< WPropertyVariable< T > > /* property */, const T& value )
{ {
return !value.empty(); return !value.empty();
} }
......
...@@ -53,7 +53,7 @@ public: ...@@ -53,7 +53,7 @@ public:
* *
* \return true if the file/path exists * \return true if the file/path exists
*/ */
virtual bool accept( boost::shared_ptr< WPropertyVariable< T > > property, T value ); virtual bool accept( boost::shared_ptr< WPropertyVariable< T > > property, const T& value );
/** /**
* Allows simple identification of the real constraint type. * Allows simple identification of the real constraint type.
...@@ -83,7 +83,7 @@ WPropertyConstraintPathExists< T >::~WPropertyConstraintPathExists() ...@@ -83,7 +83,7 @@ WPropertyConstraintPathExists< T >::~WPropertyConstraintPathExists()
} }
template < typename T > template < typename T >
bool WPropertyConstraintPathExists< T >::accept( boost::shared_ptr< WPropertyVariable< T > > /* property */, T value ) bool WPropertyConstraintPathExists< T >::accept( boost::shared_ptr< WPropertyVariable< T > > /* property */, const T& value )
{ {
return boost::filesystem::exists( value ); return boost::filesystem::exists( value );
} }
......
...@@ -53,7 +53,7 @@ public: ...@@ -53,7 +53,7 @@ public:
* *
* \return true if the file/path is a directory * \return true if the file/path is a directory
*/ */
virtual bool accept( boost::shared_ptr< WPropertyVariable< T > > property, T value ); virtual bool accept( boost::shared_ptr< WPropertyVariable< T > > property, const T& value );
/** /**
* Allows simple identification of the real constraint type. * Allows simple identification of the real constraint type.
...@@ -83,7 +83,7 @@ WPropertyConstraintSelectOnlyOne< T >::~WPropertyConstraintSelectOnlyOne() ...@@ -83,7 +83,7 @@ WPropertyConstraintSelectOnlyOne< T >::~WPropertyConstraintSelectOnlyOne()
} }
template < typename T > template < typename T >
bool WPropertyConstraintSelectOnlyOne< T >::accept( boost::shared_ptr< WPropertyVariable< T > > /* property */, T value ) bool WPropertyConstraintSelectOnlyOne< T >::accept( boost::shared_ptr< WPropertyVariable< T > > /* property */, const T& value )
{ {
return ( value.size() <= 1 ); return ( value.size() <= 1 );
} }
......
...@@ -300,7 +300,7 @@ void WMHARDIToSphericalHarmonics::properties() ...@@ -300,7 +300,7 @@ void WMHARDIToSphericalHarmonics::properties()
} }
bool WMHARDIToSphericalHarmonics::evenInt::accept( boost::shared_ptr< WPropertyVariable< WPVBaseTypes::PV_INT > >, bool WMHARDIToSphericalHarmonics::evenInt::accept( boost::shared_ptr< WPropertyVariable< WPVBaseTypes::PV_INT > >,
WPVBaseTypes::PV_INT value ) const WPVBaseTypes::PV_INT& value )
{ {
return ( value % 2 == 0 ); return ( value % 2 == 0 );
} }
......
...@@ -178,7 +178,7 @@ private: ...@@ -178,7 +178,7 @@ private:
* *
* \return true if the new value is OK. * \return true if the new value is OK.
*/ */
virtual bool accept( boost::shared_ptr< WPropertyVariable< WPVBaseTypes::PV_INT > > property, WPVBaseTypes::PV_INT value ); virtual bool accept( boost::shared_ptr< WPropertyVariable< WPVBaseTypes::PV_INT > > property, const WPVBaseTypes::PV_INT& value );
/** /**
* Method to clone the constraint and create a new one with the correct dynamic type. * Method to clone the constraint and create a new one with the correct dynamic type.
......
...@@ -710,7 +710,7 @@ void WMTemplate::TranslateCallback::operator()( osg::Node* node, osg::NodeVisito ...@@ -710,7 +710,7 @@ void WMTemplate::TranslateCallback::operator()( osg::Node* node, osg::NodeVisito
} }
bool WMTemplate::StringLength::accept( boost::shared_ptr< WPropertyVariable< WPVBaseTypes::PV_STRING > > /* property */, bool WMTemplate::StringLength::accept( boost::shared_ptr< WPropertyVariable< WPVBaseTypes::PV_STRING > > /* property */,
WPVBaseTypes::PV_STRING value ) const WPVBaseTypes::PV_STRING& value )
{ {
// This method gets called every time the m_aString property is going to be changed. It can decide whether the new value is valid or not. If // This method gets called every time the m_aString property is going to be changed. It can decide whether the new value is valid or not. If
// the method returns true, the new value is set. If it returns false, the value is rejected. // the method returns true, the new value is set. If it returns false, the value is rejected.
......
...@@ -374,7 +374,7 @@ private: ...@@ -374,7 +374,7 @@ private:
* *
* \return true if the new value is OK. * \return true if the new value is OK.
*/ */
virtual bool accept( boost::shared_ptr< WPropertyVariable< WPVBaseTypes::PV_STRING > > property, WPVBaseTypes::PV_STRING value ); virtual bool accept( boost::shared_ptr< WPropertyVariable< WPVBaseTypes::PV_STRING > > property, const WPVBaseTypes::PV_STRING& value );
/** /**
* Method to clone the constraint and create a new one with the correct dynamic type. * Method to clone the constraint and create a new one with the correct dynamic type.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment