25 #ifndef WCONDITIONSET_H
26 #define WCONDITIONSET_H
30 #include <shared_mutex>
33 #include <boost/thread.hpp>
35 #include "WCondition.h"
50 typedef std::shared_ptr< WConditionSet >
SPtr;
55 typedef std::shared_ptr< const WConditionSet >
ConstSPtr;
73 virtual void add( std::shared_ptr< WCondition > condition );
80 virtual void remove( std::shared_ptr< WCondition > condition );
86 virtual void wait()
const;
91 virtual void reset()
const;
104 void setResetable(
bool resetable =
true,
bool autoReset =
true );
Class allowing multiple conditions to be used for one waiting cycle.
virtual void wait() const
Wait for the condition.
std::map< std::shared_ptr< WCondition >, boost::signals2::connection > ConditionConnectionMap
We need to keep track of the connections a condition has made since boost::function objects do not pr...
std::shared_ptr< WConditionSet > SPtr
Shared pointer to instance of this class.
ConditionConnectionMap m_conditionSet
Set of conditions to be waited for.
bool m_fired
Flag denoting whether one condition fired in the past.
virtual ~WConditionSet()
Destructor.
virtual void reset() const
Resets the internal fire state.
void setResetable(bool resetable=true, bool autoReset=true)
Sets the resetable flag.
virtual void remove(std::shared_ptr< WCondition > condition)
Removes the specified condition.
bool m_resetable
Flag denoting whether the condition set should act like a one shot condition.
virtual void add(std::shared_ptr< WCondition > condition)
Adds another condition to the set of conditions to wait for.
std::shared_ptr< const WConditionSet > ConstSPtr
Shared pointer to const instance of this class.
bool isResetable()
Returns whether the condition set acts like a one shot condition.
WCondition::t_ConditionNotifierType m_notifier
The notifier which gets called by all conditions if they fire.
bool m_autoReset
Flag which shows whether the wait() call should reset the state m_fired when it returns.
virtual void conditionFired()
Notifier function getting notified whenever a condition got fired.
std::shared_mutex m_conditionSetLock
Lock used for thread-safe writing to the condition set.
virtual void notify()
Notifies all waiting threads.
WConditionSet()
Default constructor.
std::pair< std::shared_ptr< WCondition >, boost::signals2::connection > ConditionConnectionPair
Each condition has a connection.
Class to encapsulate boost::condition_variable_any.
boost::function0< void > t_ConditionNotifierType
Type used for signalling condition changes.