Scope
scope::ScopeValue< T > Class Template Reference

#include <ScopeValue.h>

Inherits scope::ScopeValueBase.

Inherited by scope::ScopeNumber< T >.

Public Member Functions

 ScopeValue (const T &_value=T(0), const std::wstring &_name=L"None")
 
ScopeValueoperator= (const ScopeValue &v)
 
ScopeValueoperator= (const T &v)
 
Value () const
 
operator() () const
 
 operator T () const
 
virtual T Set (const T &_v, const bool &_callguisignal=true, const bool &_callothersignal=true, const bool &_callatnochange=false)
 
void SetFromString (const std::wstring &str)
 
std::wstring ToChar () const
 
void AddToPropertyTree (boost::property_tree::wptree &pt) const
 
void SetFromPropertyTree (const boost::property_tree::wptree &pt)
 
Specializations
template<>
void SetFromString (const std::wstring &str)
 
template<>
void SetFromString (const std::wstring &str)
 
template<>
void SetFromString (const std::wstring &str)
 
template<>
void SetFromString (const std::wstring &str)
 
template<>
void SetFromString (const std::wstring &str)
 
template<>
void SetFromString (const std::wstring &str)
 
template<>
void SetFromString (const std::wstring &str)
 
template<>
void SetFromString (const std::wstring &str)
 
template<>
void SetFromString (const std::wstring &str)
 
template<>
void SetFromString (const std::wstring &str)
 
template<>
void SetFromString (const std::wstring &str)
 
template<>
void SetFromString (const std::wstring &str)
 
template<>
void SetFromString (const std::wstring &str)
 
template<>
void SetFromString (const std::wstring &str)
 
template<>
void SetFromString (const std::wstring &str)
 
template<>
void SetFromString (const std::wstring &str)
 
template<>
void SetFromString (const std::wstring &str)
 
template<>
std::wstring ToChar () const
 
template<>
std::wstring ToChar () const
 
template<>
std::wstring ToChar () const
 
template<>
std::wstring ToChar () const
 
template<>
std::wstring ToChar () const
 
template<>
std::wstring ToChar () const
 
template<>
std::wstring ToChar () const
 
template<>
std::wstring ToChar () const
 
template<>
std::wstring ToChar () const
 
template<>
std::wstring ToChar () const
 
template<>
std::wstring ToChar () const
 
template<>
std::wstring ToChar () const
 
template<>
std::wstring ToChar () const
 
template<>
std::wstring ToChar () const
 
template<>
std::wstring ToChar () const
 
template<>
std::wstring ToChar () const
 
template<>
std::wstring ToChar () const
 
- Public Member Functions inherited from scope::ScopeValueBase
 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 Member Functions

virtual T CoerceValue (const T &v) const
 

Protected Attributes

value
 
- Protected Attributes inherited from scope::ScopeValueBase
std::wstring name
 
std::mutex mutex
 
bool readwrite
 
signalchange_t changesiggui
 
signalchange_t changesigother
 
signalstate_t statesig
 

Additional Inherited Members

- Protected Types inherited from scope::ScopeValueBase
typedef boost::signals2::signal< void()> signalchange_t
 
typedef boost::signals2::signal< void(bool)> signalstate_t
 

Detailed Description

template<class T>
class scope::ScopeValue< T >

A templated class for a thread-safe value, with signals to GUI or other stuff that are called on value changes.

Definition at line 11 of file ScopeValue.h.

Constructor & Destructor Documentation

template<class T>
scope::ScopeValue< T >::ScopeValue ( const T &  _value = T(0),
const std::wstring &  _name = L"None" 
)
inline

Construct and set silently.

Definition at line 24 of file ScopeValue.h.

Member Function Documentation

template<class T>
virtual T scope::ScopeValue< T >::CoerceValue ( const T &  v) const
inlineprotectedvirtual
template<class T>
ScopeValue& scope::ScopeValue< T >::operator= ( const ScopeValue< T > &  v)
inline

Safe assignment.

Definition at line 30 of file ScopeValue.h.

template<class T>
ScopeValue& scope::ScopeValue< T >::operator= ( const T &  v)
inline

Safe assignment.

Definition at line 40 of file ScopeValue.h.

template<class T>
T scope::ScopeValue< T >::Value ( ) const
inline
Returns
the value

Definition at line 46 of file ScopeValue.h.

template<class T>
T scope::ScopeValue< T >::operator() ( ) const
inline
Returns
the value

Definition at line 52 of file ScopeValue.h.

template<class T>
scope::ScopeValue< T >::operator T ( ) const
inline
Returns
the value

Definition at line 57 of file ScopeValue.h.

template<class T>
virtual T scope::ScopeValue< T >::Set ( const T &  _v,
const bool &  _callguisignal = true,
const bool &  _callothersignal = true,
const bool &  _callatnochange = false 
)
inlinevirtual

Sets the value and calls both change signals if the value actually changed.

Parameters
[in]_vthe new value
[in]_callguisignalcall signal to GUI slots
[in]_callothersignalcall signal to other slots
[in]_callatnochangecall signals also if value did not change
Returns
the current value (i.e. the coerced _v).

Definition at line 67 of file ScopeValue.h.

template<class T>
void scope::ScopeValue< T >::SetFromString ( const std::wstring &  str)

Parses a wstring and sets the value accordingly.

See ScopeValue.cpp for specializations.

template<class T>
std::wstring scope::ScopeValue< T >::ToChar ( ) const

Converts value into a wstring.

See ScopeValue.cpp for specializations.

template<class T>
void scope::ScopeValue< T >::AddToPropertyTree ( boost::property_tree::wptree &  pt) const
inline

Adds the value to a Boost property tree, using its name and value.

Definition at line 103 of file ScopeValue.h.

template<class T>
void scope::ScopeValue< T >::SetFromPropertyTree ( const boost::property_tree::wptree &  pt)
inline

Set value from a Boost property, using its name as a key.

Definition at line 108 of file ScopeValue.h.

Member Data Documentation

template<class T>
T scope::ScopeValue< T >::value
protected

the value proper

Definition at line 16 of file ScopeValue.h.


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