Commit 0ed9149b authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum

[CHANGE] - WFlag now offers additional condition which always fires if the...

[CHANGE] - WFlag now offers additional condition which always fires if the value has changed, regardless of the supression flag of set()
parent deb927b0
......@@ -115,6 +115,14 @@ public:
*/
boost::shared_ptr< WCondition > getCondition();
/**
* Returns the condition denoting a value change. In contrast to getCondition, this condition fires regardless of notification is suppressed
* during set() or not.
*
* \return the condition denoting a value change.
*/
boost::shared_ptr< WCondition > getValueChangeCondition();
/**
* Determines whether the specified value is acceptable. In WFlags, this always returns true. To modify the behaviour,
* implement this function in an appropriate way.
......@@ -139,6 +147,12 @@ protected:
*/
boost::shared_ptr< WCondition > m_condition;
/**
* This condition is fired whenever the value changes. In contrast to m_condition, this also fires if set() is called with
* suppressNotification=true.
*/
boost::shared_ptr< WCondition > m_valueChangeCondition;
/**
* The flag value.
*/
......@@ -160,6 +174,7 @@ typedef WFlag< bool > WBoolFlag;
template < typename T >
WFlag< T >::WFlag( WCondition* condition, T initial ):
m_condition( boost::shared_ptr< WCondition >( condition ) ),
m_valueChangeCondition( boost::shared_ptr< WCondition >( new WCondition() ) ),
m_flag( initial ),
m_changed( true )
{
......@@ -168,6 +183,7 @@ WFlag< T >::WFlag( WCondition* condition, T initial ):
template < typename T >
WFlag< T >::WFlag( boost::shared_ptr< WCondition > condition, T initial ):
m_condition( condition ),
m_valueChangeCondition( boost::shared_ptr< WCondition >( new WCondition() ) ),
m_flag( initial ),
m_changed( true )
{
......@@ -235,6 +251,7 @@ bool WFlag< T >::set( T value, bool suppressNotification )
{
m_condition->notify();
}
m_valueChangeCondition->notify();
return true;
}
......@@ -245,6 +262,12 @@ boost::shared_ptr< WCondition > WFlag< T >::getCondition()
return m_condition;
}
template < typename T >
boost::shared_ptr< WCondition > WFlag< T >::getValueChangeCondition()
{
return m_valueChangeCondition;
}
template < typename T >
bool WFlag< T >::accept( T /* newValue */ )
{
......
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