31 #include "WCondition.h"
37 template <
typename T >
49 typedef std::shared_ptr< WFlag< T > >
SPtr;
54 typedef std::shared_ptr< const WFlag< T > >
ConstSPtr;
74 WFlag( std::shared_ptr< WCondition > condition,
const T& initial );
99 virtual const T&
get(
bool resetChangeState =
false );
106 virtual const T&
get()
const;
120 virtual operator T()
const;
137 virtual bool set(
const T& value,
bool suppressNotification =
false );
169 virtual bool accept(
const T& newValue );
218 template <
typename T >
220 m_condition( std::shared_ptr<
WCondition >( condition ) ),
227 template <
typename T >
229 m_condition( condition ),
236 template <
typename T >
240 m_flag( from.m_flag ),
241 m_changed( from.m_changed )
245 template <
typename T >
250 template <
typename T >
256 template <
typename T >
259 if( resetChangeState )
266 template <
typename T >
272 template <
typename T >
278 template <
typename T >
284 template <
typename T >
290 template <
typename T >
294 if( m_flag == value )
300 if( !accept( value ) )
309 if( !suppressNotification )
311 m_condition->notify();
313 m_valueChangeCondition->notify();
318 template <
typename T >
324 template <
typename T >
327 return m_valueChangeCondition;
330 template <
typename T >
337 template <
typename T >
340 return accept( get() );
343 template <
typename T >
346 bool tmp = m_changed;
Class to encapsulate boost::condition_variable_any.
Class to have a simple notification/condition system for simple flags.
virtual const T & get() const
Operator returns value of the flag.
virtual void wait() const
Wait for the flag to change its value.
WFlag(std::shared_ptr< WCondition > condition, const T &initial)
Constructor.
virtual bool accept(const T &newValue)
Determines whether the specified value is acceptable.
T ValueType
The type for later access.
std::shared_ptr< const WFlag< T > > ConstSPtr
Convenience typedef for a std::shared_ptr.
std::shared_ptr< WCondition > getCondition()
Returns the condition that is used by this flag.
virtual bool changed(bool reset=false)
True whenever the value inside this flag has changed since the last reset.
virtual const T & get(bool resetChangeState=false)
Operator returns value of the flag.
std::shared_ptr< WFlag< T > > SPtr
Convenience typedef for a std::shared_ptr.
std::shared_ptr< WCondition > getValueChangeCondition()
Returns the condition denoting a value change.
virtual void operator()(const T &value)
Sets the new value for this flag.
std::shared_ptr< WCondition > m_condition
The condition to be used for waiting/notifying.
std::shared_ptr< WCondition > m_valueChangeCondition
This condition is fired whenever the value changes.
virtual bool set(const T &value, bool suppressNotification=false)
Sets the new value for this flag.
WFlag(const WFlag &from)
Copy constructor.
virtual const T & operator()() const
Operator returns value of the flag.
WFlag(WCondition *condition, const T &initial)
Constructor.
virtual bool isValid()
Tests whether a flag is currently valid.
virtual ~WFlag()
Destructor.
bool m_changed
Denotes whether the value has changed since the last reset.