OpenWalnut  1.4.0
Public Types | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes
WPropertyObserver Class Reference

This class can observe properties inside a property group. More...

#include <WPropertyObserver.h>

+ Inheritance diagram for WPropertyObserver:

List of all members.

Public Types

typedef std::map< std::string,
boost::shared_ptr
< WPropertyBase > > 
PropertyNameMap
 Convenience type for a set of property instances.
typedef boost::shared_ptr
< WPropertyObserver
SPtr
 Convenience type for a shared pointer on property observers.

Public Member Functions

 WPropertyObserver ()
 Default constructor.
virtual ~WPropertyObserver ()
 Destructor.
void observe (boost::shared_ptr< WProperties > properties, std::set< std::string > names=std::set< std::string >())
 Defines the property group whose children should be watched.
bool updated () const
 Is true if one observed property fired.
PropertyNameMap handled ()
 Resets the update flag and the list of fired properties.

Static Public Member Functions

static boost::shared_ptr
< WPropertyObserver
create ()
 Creates a new instance of WPropertyObserver.

Private Types

typedef
WSharedAssociativeContainer
< std::map< boost::shared_ptr
< WPropertyBase >
, boost::signals2::connection > > 
Subscriptions
 Type for shared container with signal connections.
typedef
WSharedAssociativeContainer
< PropertyNameMap
LastUpdated
 Type of shared container for the list of last updated properties.

Private Member Functions

 WPropertyObserver (const WPropertyObserver &rhs)
 Disallow copy construction.
WPropertyObserveroperator= (const WPropertyObserver &rhs)
 Disallow copy assignment.
void cancelSubscriptions ()
 Cancels all current subscriptions and cleans m_subscriptions.
void updateSubscriptions ()
 Subscribes each property update condition which matches an entry in m_propNames.
void propertyUpdated (boost::shared_ptr< WPropertyBase > property)
 Gets called by the update callback of the property.

Private Attributes

Subscriptions m_subscriptions
 The subscription to each property which was subscribed.
bool m_updated
 True if a property fired.
boost::shared_ptr< WPropertiesm_properties
 The properties handled by this observer.
std::set< std::string > m_propNames
 The names of the properties which shall be observed if they are or become available.
boost::signals2::scoped_connection m_updateConditionConnection
 The connection used to get notified about m_properties updates.
LastUpdated m_lastUpdated
 The queue of properties that fired before handled() is called.

Detailed Description

This class can observe properties inside a property group.

The property group to observer can simply be set and replaced comfortably. Whenever one of the child properties updates, the observer fires too. If the observed property group itself changes (added properties, removed properties and so on), the observer gets updated automatically.

Definition at line 44 of file WPropertyObserver.h.


Member Typedef Documentation

Type of shared container for the list of last updated properties.

Definition at line 165 of file WPropertyObserver.h.

typedef std::map< std::string, boost::shared_ptr< WPropertyBase > > WPropertyObserver::PropertyNameMap

Convenience type for a set of property instances.

Definition at line 50 of file WPropertyObserver.h.

typedef boost::shared_ptr< WPropertyObserver > WPropertyObserver::SPtr

Convenience type for a shared pointer on property observers.

Reimplemented from WCondition.

Definition at line 55 of file WPropertyObserver.h.

typedef WSharedAssociativeContainer< std::map< boost::shared_ptr< WPropertyBase >, boost::signals2::connection > > WPropertyObserver::Subscriptions [private]

Type for shared container with signal connections.

Definition at line 135 of file WPropertyObserver.h.


Constructor & Destructor Documentation

Default constructor.

Definition at line 31 of file WPropertyObserver.cpp.

Referenced by create().

Destructor.

Definition at line 42 of file WPropertyObserver.cpp.

Disallow copy construction.

Parameters:
rhsthe other threaded runner.

Member Function Documentation

Cancels all current subscriptions and cleans m_subscriptions.

Definition at line 95 of file WPropertyObserver.cpp.

References WSharedObject< T >::getWriteTicket(), and m_subscriptions.

Referenced by observe().

boost::shared_ptr< WPropertyObserver > WPropertyObserver::create ( ) [static]

Creates a new instance of WPropertyObserver.

Useful to save some typing as it creates an shared pointer for you.

Returns:
the new instance.

Definition at line 139 of file WPropertyObserver.cpp.

References WPropertyObserver().

Resets the update flag and the list of fired properties.

Returns:
the set of properties fired until the last call of handled.

Definition at line 52 of file WPropertyObserver.cpp.

References WSharedObject< T >::getWriteTicket(), m_lastUpdated, and m_updated.

void WPropertyObserver::observe ( boost::shared_ptr< WProperties properties,
std::set< std::string >  names = std::set< std::string >() 
)

Defines the property group whose children should be watched.

You can define a list of names manually if you are not interested in updates of ALL properties.

Notes:
this also resets the updated flag and the list of the last fired properties.
Parameters:
propertiesthe group whose children should be watched.
nameslist of names. If specified, only these properties are observed.

Definition at line 66 of file WPropertyObserver.cpp.

References cancelSubscriptions(), WSharedObject< T >::getWriteTicket(), m_lastUpdated, m_properties, m_propNames, m_updateConditionConnection, m_updated, and updateSubscriptions().

WPropertyObserver& WPropertyObserver::operator= ( const WPropertyObserver rhs) [private]

Disallow copy assignment.

Parameters:
rhsthe other threaded runner.
Returns:
this.
void WPropertyObserver::propertyUpdated ( boost::shared_ptr< WPropertyBase property) [private]

Gets called by the update callback of the property.

The property given as parameter was the property that fired.

Parameters:
propertythe property that fired.

Definition at line 130 of file WPropertyObserver.cpp.

References WSharedObject< T >::getWriteTicket(), m_lastUpdated, m_updated, and WCondition::notify().

Referenced by updateSubscriptions().

Is true if one observed property fired.

This is reset by the handled method.

Returns:
true if one property fired.

Definition at line 47 of file WPropertyObserver.cpp.

References m_updated.

Subscribes each property update condition which matches an entry in m_propNames.

Definition at line 110 of file WPropertyObserver.cpp.

References WSharedObject< T >::getWriteTicket(), m_properties, m_propNames, m_subscriptions, and propertyUpdated().

Referenced by observe().


Member Data Documentation

The queue of properties that fired before handled() is called.

Definition at line 170 of file WPropertyObserver.h.

Referenced by handled(), observe(), and propertyUpdated().

boost::shared_ptr< WProperties > WPropertyObserver::m_properties [private]

The properties handled by this observer.

Definition at line 150 of file WPropertyObserver.h.

Referenced by observe(), and updateSubscriptions().

std::set< std::string > WPropertyObserver::m_propNames [private]

The names of the properties which shall be observed if they are or become available.

Definition at line 155 of file WPropertyObserver.h.

Referenced by observe(), and updateSubscriptions().

The subscription to each property which was subscribed.

Definition at line 140 of file WPropertyObserver.h.

Referenced by cancelSubscriptions(), and updateSubscriptions().

boost::signals2::scoped_connection WPropertyObserver::m_updateConditionConnection [private]

The connection used to get notified about m_properties updates.

Definition at line 160 of file WPropertyObserver.h.

Referenced by observe().

True if a property fired.

Definition at line 145 of file WPropertyObserver.h.

Referenced by handled(), observe(), propertyUpdated(), and updated().


The documentation for this class was generated from the following files: