25 #ifndef WPROPERTYOBSERVER_H
26 #define WPROPERTYOBSERVER_H
33 #include <boost/signals2/signal.hpp>
34 #include <boost/thread.hpp>
36 #include "WCondition.h"
37 #include "WProperties.h"
51 typedef std::map< std::string, std::shared_ptr< WPropertyBase > >
PropertyNameMap;
56 typedef std::shared_ptr< WPropertyObserver >
SPtr;
76 void observe( std::shared_ptr< WProperties > properties, std::set< std::string > names = std::set< std::string >() );
97 static std::shared_ptr< WPropertyObserver >
create();
Class to encapsulate boost::condition_variable_any.
This class can observe properties inside a property group.
std::shared_ptr< WProperties > m_properties
The properties handled by this observer.
static std::shared_ptr< WPropertyObserver > create()
Creates a new instance of WPropertyObserver.
std::shared_ptr< WPropertyObserver > SPtr
Convenience type for a shared pointer on property observers.
void cancelSubscriptions()
Cancels all current subscriptions and cleans m_subscriptions.
WPropertyObserver()
Default constructor.
WPropertyObserver & operator=(const WPropertyObserver &rhs)
Disallow copy assignment.
WSharedAssociativeContainer< std::map< std::shared_ptr< WPropertyBase >, boost::signals2::connection > > Subscriptions
Type for shared container with signal connections.
Subscriptions m_subscriptions
The subscription to each property which was subscribed.
std::set< std::string > m_propNames
The names of the properties which shall be observed if they are or become available.
bool updated() const
Is true if one observed property fired.
WSharedAssociativeContainer< PropertyNameMap > LastUpdated
Type of shared container for the list of last updated properties.
void propertyUpdated(std::shared_ptr< WPropertyBase > property)
Gets called by the update callback of the property.
WPropertyObserver(const WPropertyObserver &rhs)
Disallow copy construction.
bool m_updated
True if a property fired.
void observe(std::shared_ptr< WProperties > properties, std::set< std::string > names=std::set< std::string >())
Defines the property group whose children should be watched.
std::map< std::string, std::shared_ptr< WPropertyBase > > PropertyNameMap
Convenience type for a set of property instances.
PropertyNameMap handled()
Resets the update flag and the list of fired properties.
virtual ~WPropertyObserver()
Destructor.
void updateSubscriptions()
Subscribes each property update condition which matches an entry in m_propNames.
LastUpdated m_lastUpdated
The queue of properties that fired before handled() is called.
boost::signals2::scoped_connection m_updateConditionConnection
The connection used to get notified about m_properties updates.
This class provides a common interface for thread-safe access to associative containers (set,...