Scope
scope::ScopeValueBase Class Reference

#include <ScopeValueBase.h>

Inherited by scope::ScopeNumber< T > [virtual], scope::ScopeString [virtual], scope::ScopeValue< T > [virtual], scope::ScopeNumber< bool > [virtual], scope::ScopeNumber< double > [virtual], scope::ScopeNumber< scope::ScopeDatatypeBase > [virtual], scope::ScopeNumber< uint32_t > [virtual], scope::ScopeNumber< uint8_t > [virtual], scope::ScopeNumber< ValT > [virtual], scope::ScopeValue< bool > [virtual], scope::ScopeValue< double > [virtual], scope::ScopeValue< scope::ScopeDatatypeBase > [virtual], scope::ScopeValue< ScopeDatatypeBase< ZDeviceHelper > > [virtual], scope::ScopeValue< std::wstring > [virtual], scope::ScopeValue< uint32_t > [virtual], scope::ScopeValue< uint8_t > [virtual], and scope::ScopeValue< ValT > [virtual].

Public Member Functions

 ScopeValueBase (const std::wstring &_name=L"None")
 
 ScopeValueBase (const ScopeValueBase &_svb)
 
ScopeValueBaseoperator= (const ScopeValueBase &_svb)
 
virtual ~ScopeValueBase ()
 
std::wstring Name () const
 
void SetName (const std::wstring &_name)
 
void SetRWState (const bool &_state)
 
bool GetRWState () const
 
boost::signals2::connection ConnectGUI (signalchange_t::slot_type slot)
 
boost::signals2::connection ConnectOther (signalchange_t::slot_type slot)
 
boost::signals2::connection ConnectState (signalstate_t::slot_type slot)
 

Protected Types

typedef boost::signals2::signal< void()> signalchange_t
 
typedef boost::signals2::signal< void(bool)> signalstate_t
 

Protected Attributes

std::wstring name
 
std::mutex mutex
 
bool readwrite
 
signalchange_t changesiggui
 
signalchange_t changesigother
 
signalstate_t statesig
 

Detailed Description

Base class for a thread-safe value, with signals that are called on value changes.

It uses a mutex to protect the value and boost::signals2 to call connected function.

Definition at line 7 of file ScopeValueBase.h.

Member Typedef Documentation

typedef boost::signals2::signal<void ()> scope::ScopeValueBase::signalchange_t
protected

typedef for change signal slot functions

Definition at line 20 of file ScopeValueBase.h.

typedef boost::signals2::signal<void (bool)> scope::ScopeValueBase::signalstate_t
protected

typedef for state signal slot functions

Definition at line 23 of file ScopeValueBase.h.

Constructor & Destructor Documentation

scope::ScopeValueBase::ScopeValueBase ( const std::wstring &  _name = L"None")
inline

Initialize name and readonly.

Definition at line 36 of file ScopeValueBase.h.

scope::ScopeValueBase::ScopeValueBase ( const ScopeValueBase _svb)
inline

Safe copy.

Signals are not copied!

Definition at line 42 of file ScopeValueBase.h.

virtual scope::ScopeValueBase::~ScopeValueBase ( )
inlinevirtual

Disconnects all slots from signals.

Definition at line 59 of file ScopeValueBase.h.

Member Function Documentation

ScopeValueBase& scope::ScopeValueBase::operator= ( const ScopeValueBase _svb)
inline

Safe assignment.

Signals are not assigned!

Definition at line 48 of file ScopeValueBase.h.

std::wstring scope::ScopeValueBase::Name ( ) const
inline
Returns
the values name

Definition at line 68 of file ScopeValueBase.h.

void scope::ScopeValueBase::SetName ( const std::wstring &  _name)
inline

Set the name.

Definition at line 74 of file ScopeValueBase.h.

void scope::ScopeValueBase::SetRWState ( const bool &  _state)
inline

Sets readonly/read-write state.

True = read&write, false = readonly.

Definition at line 80 of file ScopeValueBase.h.

bool scope::ScopeValueBase::GetRWState ( ) const
inline
Returns
true if read&write, false if read-only

Definition at line 89 of file ScopeValueBase.h.

boost::signals2::connection scope::ScopeValueBase::ConnectGUI ( signalchange_t::slot_type  slot)
inline

Connect signal to slot to GUI.

Save the connection object and call its disconnect to disconnect.

Definition at line 95 of file ScopeValueBase.h.

boost::signals2::connection scope::ScopeValueBase::ConnectOther ( signalchange_t::slot_type  slot)
inline

Connect signal to slot to other stuff.

Save the connection object and call its disconnect to disconnect.

Definition at line 101 of file ScopeValueBase.h.

boost::signals2::connection scope::ScopeValueBase::ConnectState ( signalstate_t::slot_type  slot)
inline

Connect signal to slot for state changes.

Save the connection object and call its disconnect to disconnect.

Definition at line 106 of file ScopeValueBase.h.

Member Data Documentation

std::wstring scope::ScopeValueBase::name
protected

the name of the value

Definition at line 11 of file ScopeValueBase.h.

std::mutex scope::ScopeValueBase::mutex
mutableprotected

a mutex for protection.

Is mutable so we can have accessor functions as const!

Definition at line 14 of file ScopeValueBase.h.

bool scope::ScopeValueBase::readwrite
protected

read-write state, true if read&write, false if onyl read (not an atomic, since access to the data variable has to be protected while we change readonly)

Definition at line 17 of file ScopeValueBase.h.

signalchange_t scope::ScopeValueBase::changesiggui
protected

signal that is called for GUI on value changes

Definition at line 26 of file ScopeValueBase.h.

signalchange_t scope::ScopeValueBase::changesigother
protected

signal that is called for other stuff on value changes

Definition at line 29 of file ScopeValueBase.h.

signalstate_t scope::ScopeValueBase::statesig
protected

signal that is called on changes of read/write status

Definition at line 32 of file ScopeValueBase.h.


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