OpenWalnut  1.5.0dev
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>

+ Collaboration diagram for WFlagForwarder< T >:

Public Member Functions

 WFlagForwarder (std::shared_ptr< WFlag< T > > source)
 Default constructor. More...
 
virtual ~WFlagForwarder ()
 Destructor. More...
 
void forward (std::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

std::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!

Note
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.
Also be aware that this class only forwards changes in the flag value! Changes of "hidden" in PropertyVariables are not propagated.
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 54 of file WFlagForwarder.h.

Constructor & Destructor Documentation

◆ WFlagForwarder() [1/2]

template<typename T >
WFlagForwarder< T >::WFlagForwarder ( std::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 116 of file WFlagForwarder.h.

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

+ Here is the call graph for this function:

◆ ~WFlagForwarder()

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

Destructor.

Definition at line 124 of file WFlagForwarder.h.

◆ WFlagForwarder() [2/2]

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

Disallow copy construction.

Parameters
rhsthe other forwarder.

Member Function Documentation

◆ forward()

template<typename T >
void WFlagForwarder< T >::forward ( std::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 132 of file WFlagForwarder.h.

References WFlag< T >::get().

Referenced by WFlagForwarderTest::testPropagation().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ operator=()

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

Disallow copy assignment.

Parameters
rhsthe other forwarder.
Returns
this.

◆ sourceChanged()

template<typename T >
void WFlagForwarder< T >::sourceChanged
protected

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

Definition at line 141 of file WFlagForwarder.h.

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

+ Here is the caller graph for this function:

Member Data Documentation

◆ m_source

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

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

Definition at line 81 of file WFlagForwarder.h.

◆ m_sourceConnection

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

The signal fired by m_source upon value change.

Definition at line 86 of file WFlagForwarder.h.

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

◆ signal_forward

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

Signal forwarding the new value.

Definition at line 91 of file WFlagForwarder.h.


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