OpenWalnut  1.4.0
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | List of all members
WFlagForwarder< T > Class Template Reference

This class helps especially container module programmers to easily synchronize the value of one flag with several other flag. More...

#include <WFlagForwarder.h>

Public Member Functions

 WFlagForwarder (boost::shared_ptr< WFlag< T > > source)
 Default constructor. More...
 
virtual ~WFlagForwarder ()
 Destructor. More...
 
void forward (boost::shared_ptr< WFlag< T > > to)
 Forward the source property to the specified one. More...
 

Protected Member Functions

void sourceChanged ()
 This is a callback and gets called whenever the source property has changed. More...
 

Protected Attributes

boost::shared_ptr< WFlag< T > > m_source
 The source property to which all other properties are synced to. More...
 
boost::signals2::connection m_sourceConnection
 The signal fired by m_source upon value change. More...
 
boost::signals2::signal< void(T) > signal_forward
 Signal forwarding the new value. More...
 

Private Member Functions

 WFlagForwarder (const WFlagForwarder &rhs)
 Disallow copy construction. More...
 
WFlagForwarderoperator= (const WFlagForwarder &rhs)
 Disallow copy assignment. More...
 

Detailed Description

template<typename T>
class WFlagForwarder< T >

This class helps especially container module programmers to easily synchronize the value of one flag with several other flag.

Assume the following scenario: you have a container module with two isosurface modules whose isovalue-properties need to be in sync with the isovalue-property your container module provides to the outside world. Here, WFlagForwaderd comes into play. Add the first isosurface's isovalue-property to the container modules m_properties list and forward it to the other isovalue-property of the second isosurface module. Now they are in sync. Be aware, that this is not a property itself!

Notes:
this class is not thread-safe for performance reasons. It is possible to add further flags to the forward-list but be yourself aware that you might miss value changes if you add the flag right between two value changes of the source flag.
Notes:
Also be aware that this class only forwards changes in the flag value! Changes of "hidden" in PropertyVariables are not propagated.
Notes:
The template parameter is the type encapsulated inside the flag. I.e. for WFlag< bool > use T=bool
Parameters
Tthe encapsulated type inside the flag. I.e. for WFlag< int32_t > use T=int32_t

Definition at line 53 of file WFlagForwarder.h.

Constructor & Destructor Documentation

template<typename T >
WFlagForwarder< T >::WFlagForwarder ( boost::shared_ptr< WFlag< T > >  source)
explicit

Default constructor.

Parameters
sourcethe property to be used as reference. All other properties will be synced with this one.

Definition at line 115 of file WFlagForwarder.h.

References WFlagForwarder< T >::m_sourceConnection, and WFlagForwarder< T >::sourceChanged().

template<typename T >
WFlagForwarder< T >::~WFlagForwarder ( )
virtual

Destructor.

Definition at line 123 of file WFlagForwarder.h.

template<typename T>
WFlagForwarder< T >::WFlagForwarder ( const WFlagForwarder< T > &  rhs)
private

Disallow copy construction.

Parameters
rhsthe other forwarder.

Member Function Documentation

template<typename T >
void WFlagForwarder< T >::forward ( boost::shared_ptr< WFlag< T > >  to)

Forward the source property to the specified one.

This ensures that the flag in "to" always has the value of the source flag. There is no remove method.

Parameters
tothe property to sync with source.

Definition at line 131 of file WFlagForwarder.h.

References WFlag< T >::get().

Referenced by WFlagForwarderTest::testPropagation().

template<typename T>
WFlagForwarder& WFlagForwarder< T >::operator= ( const WFlagForwarder< T > &  rhs)
private

Disallow copy assignment.

Parameters
rhsthe other forwarder.
Returns
this.
template<typename T >
void WFlagForwarder< T >::sourceChanged ( )
protected

This is a callback and gets called whenever the source property has changed.

Definition at line 140 of file WFlagForwarder.h.

Referenced by WFlagForwarder< T >::WFlagForwarder().

Member Data Documentation

template<typename T>
boost::shared_ptr< WFlag< T > > WFlagForwarder< T >::m_source
protected

The source property to which all other properties are synced to.

Definition at line 80 of file WFlagForwarder.h.

template<typename T>
boost::signals2::connection WFlagForwarder< T >::m_sourceConnection
protected

The signal fired by m_source upon value change.

Definition at line 85 of file WFlagForwarder.h.

Referenced by WFlagForwarder< T >::WFlagForwarder().

template<typename T>
boost::signals2::signal< void( T ) > WFlagForwarder< T >::signal_forward
protected

Signal forwarding the new value.

Definition at line 90 of file WFlagForwarder.h.


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