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:
*
* \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
......@@ -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
*/
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.
......@@ -201,7 +201,7 @@ public:
*
* \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.
......@@ -273,7 +273,7 @@ public:
*
* \return the new constraint.
*/
static PropertyConstraintMin minConstraint( T min );
static PropertyConstraintMin minConstraint( const T& min );
/**
* Creates a new WPropertyConstraintMax for this WPropertyVariable.
......@@ -282,7 +282,7 @@ public:
*
* \return the new constraint.
*/
static PropertyConstraintMax maxConstraint( T max );
static PropertyConstraintMax maxConstraint( const T& max );
/**
* Set a minimum constraint.
......@@ -291,7 +291,7 @@ public:
*
* \return the newly created constraint.
*/
PropertyConstraintMin setMin( T min );
PropertyConstraintMin setMin( const T& min );
/**
* Set a maximum constraint.
......@@ -300,7 +300,7 @@ public:
*
* \return the newly created constraint.
*/
PropertyConstraintMax setMax( T max );
PropertyConstraintMax setMax( const T& max );
/**
* Gets the current minimum constraint value.
......@@ -404,7 +404,7 @@ public:
* \note set( get() ) == true
* \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
......@@ -415,7 +415,7 @@ public:
*
* \return true if value has been set successfully.
*/
virtual bool setRecommendedValue( T value );
virtual bool setRecommendedValue( const T& value );
protected:
......@@ -583,7 +583,7 @@ void WPropertyVariable< T >::propertyChangeNotifier()
}
template < typename T >
bool WPropertyVariable< T >::accept( T newValue )
bool WPropertyVariable< T >::accept( const T& newValue )
{
// lock, lock vanishes if l looses focus
typename WPropertyVariable< T >::ConstraintContainerType::ReadTicket l = m_constraints->getReadTicket();
......@@ -640,14 +640,14 @@ bool WPropertyVariable< T >::set( boost::shared_ptr< WPropertyBase > value )
}
template < typename T >
bool WPropertyVariable< T >::set( T value, bool suppressNotification )
bool WPropertyVariable< T >::set( const T& value, bool suppressNotification )
{
m_notYetSet = false;
return WFlag< T >::set( value, suppressNotification );
}
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 ...
if( m_notYetSet )
......@@ -663,7 +663,7 @@ bool WPropertyVariable< T >::setRecommendedValue( T value )
}
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() ) )
{
......@@ -700,19 +700,19 @@ void WPropertyVariable< T >::updateType()
}
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 ) );
}
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 ) );
}
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 );
replaceConstraint( c, PC_MIN );
......@@ -720,7 +720,7 @@ boost::shared_ptr< WPropertyConstraintMin< T > > WPropertyVariable< T >::setMin(
}
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 );
replaceConstraint( c, PC_MAX );
......
......@@ -53,7 +53,7 @@ public:
*
* \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.
......@@ -83,7 +83,7 @@ WPropertyConstraintIsDirectory< T >::~WPropertyConstraintIsDirectory()
}
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 );
}
......
......@@ -54,7 +54,7 @@ public:
*
* \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.
......@@ -84,7 +84,7 @@ WPropertyConstraintIsValid< T >::~WPropertyConstraintIsValid()
}
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();
}
......
......@@ -55,7 +55,7 @@ public:
*
* \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.
......@@ -98,7 +98,7 @@ WPropertyConstraintMax< T >::~WPropertyConstraintMax()
}
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;
}
......
......@@ -55,7 +55,7 @@ public:
*
* \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.
......@@ -98,7 +98,7 @@ WPropertyConstraintMin< T >::~WPropertyConstraintMin()
}
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;
}
......
......@@ -54,7 +54,7 @@ public:
*
* \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.
......@@ -84,7 +84,7 @@ WPropertyConstraintNotEmpty< T >::~WPropertyConstraintNotEmpty()
}
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();
}
......
......@@ -53,7 +53,7 @@ public:
*
* \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.
......@@ -83,7 +83,7 @@ WPropertyConstraintPathExists< T >::~WPropertyConstraintPathExists()
}
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 );
}
......
......@@ -53,7 +53,7 @@ public:
*
* \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.
......@@ -83,7 +83,7 @@ WPropertyConstraintSelectOnlyOne< T >::~WPropertyConstraintSelectOnlyOne()
}
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 );
}
......
......@@ -300,7 +300,7 @@ void WMHARDIToSphericalHarmonics::properties()
}
bool WMHARDIToSphericalHarmonics::evenInt::accept( boost::shared_ptr< WPropertyVariable< WPVBaseTypes::PV_INT > >,
WPVBaseTypes::PV_INT value )
const WPVBaseTypes::PV_INT& value )
{
return ( value % 2 == 0 );
}
......
......@@ -178,7 +178,7 @@ private:
*
* \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.
......
......@@ -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 */,
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
// the method returns true, the new value is set. If it returns false, the value is rejected.
......
......@@ -374,7 +374,7 @@ private:
*
* \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.
......
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