Scope
scope::ScopeNumber< T > Class Template Reference

#include <ScopeNumber.h>

Inherits scope::ScopeValue< T >, and scope::ScopeValueBase.

Public Member Functions

 ScopeNumber (const T &_v=0, const T &_ll=0, const T &_ul=0, const std::wstring &_name=L"None")
 
 ScopeNumber (const ScopeNumber< T > &orig)
 
ScopeNumberoperator= (const ScopeNumber< T > &v)
 
ScopeNumberoperator= (const T &v)
 
ll () const
 
ul () const
 
SetWithLimits (const T &v, const T &ll, const T &ul)
 
SetLimits (const T &_ll, const T &_ul, const bool &_callguisignal=true, const bool &_callothersignal=true, const bool &_callatnochange=false)
 
Arithmetic operators

With this a ScopeNumber<T> can be treated like a T

ScopeNumberoperator+= (const ScopeNumber< T > &v)
 
ScopeNumberoperator+= (const T &_val)
 
ScopeNumberoperator-= (const ScopeNumber< T > &v)
 
ScopeNumberoperator-= (const T &_val)
 
ScopeNumberoperator*= (const ScopeNumber< T > &v)
 
ScopeNumberoperator*= (const T &_val)
 
ScopeNumberoperator/= (const ScopeNumber< T > &v)
 
ScopeNumberoperator/= (const T &_val)
 
ScopeNumber operator+ (const ScopeNumber< T > &v) const
 
ScopeNumber operator- (const ScopeNumber< T > &v) const
 
ScopeNumber operator* (const ScopeNumber< T > &v) const
 
ScopeNumber operator/ (const ScopeNumber< T > &v) const
 
ScopeNumber operator+ (const T &_val) const
 
ScopeNumber operator- (const T &_val) const
 
ScopeNumber operator* (const T &_val) const
 
ScopeNumber operator/ (const T &_val) const
 
Comparison operators

With this a ScopeNumber<T> can be treated like a T

bool operator< (const ScopeNumber< T > &r) const
 
bool operator< (const T &r) const
 
bool operator> (const ScopeNumber< T > &r) const
 
bool operator> (const T &r) const
 
bool operator== (const ScopeNumber< T > &r) const
 
bool operator!= (const ScopeNumber< T > &r) const
 
- Public Member Functions inherited from scope::ScopeValue< T >
 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)
 
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

CoerceValue (const T &v) const override
 

Protected Attributes

lowerLimit
 
upperLimit
 
- Protected Attributes inherited from scope::ScopeValue< T >
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::ScopeNumber< T >

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

Derived from ScopeValue and ScopeValueBase (virtual, since ScopeValue is also derived from ScopeValueBase; but we want ScopeValueBase constructor).

Definition at line 7 of file XYControl.h.

Constructor & Destructor Documentation

template<class T>
scope::ScopeNumber< T >::ScopeNumber ( const T &  _v = 0,
const T &  _ll = 0,
const T &  _ul = 0,
const std::wstring &  _name = L"None" 
)
inline
Parameters
[in]_vinitial value (will be coerced)
[in]_llinitial lower limit
[in]_ulinitial upper limit
[in]_namename of the value

Definition at line 31 of file ScopeNumber.h.

template<class T>
scope::ScopeNumber< T >::ScopeNumber ( const ScopeNumber< T > &  orig)
inline

Safe copy constructor.

Definition at line 37 of file ScopeNumber.h.

Member Function Documentation

template<class T>
T scope::ScopeNumber< T >::CoerceValue ( const T &  v) const
inlineoverrideprotectedvirtual

Does the actual coercion in between the lowerLimit and upperLimit.

Not thread-safe.

Reimplemented from scope::ScopeValue< T >.

Definition at line 22 of file ScopeNumber.h.

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

Safe assignment.

Definition at line 43 of file ScopeNumber.h.

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

Safe assignment, does keep name and limits.

Definition at line 53 of file ScopeNumber.h.

template<class T>
T scope::ScopeNumber< T >::ll ( ) const
inline
Returns
the lower limit

Definition at line 149 of file ScopeNumber.h.

template<class T>
T scope::ScopeNumber< T >::ul ( ) const
inline
Returns
the upper limit

Definition at line 155 of file ScopeNumber.h.

template<class T>
T scope::ScopeNumber< T >::SetWithLimits ( const T &  v,
const T &  ll,
const T &  ul 
)
inline

Sets new value and new limits at the same time.

Definition at line 161 of file ScopeNumber.h.

template<class T>
T scope::ScopeNumber< T >::SetLimits ( const T &  _ll,
const T &  _ul,
const bool &  _callguisignal = true,
const bool &  _callothersignal = true,
const bool &  _callatnochange = false 
)
inline

Sets the limits and coerces the value accordingly change signal is called if value has to be coerced.

Parameters
[in]llnew lower limit
[in]ulnew upper limit
[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 (possibly coerced to the new limits).

Definition at line 174 of file ScopeNumber.h.

Member Data Documentation

template<class T>
T scope::ScopeNumber< T >::lowerLimit
protected

lower limit (including) to which the value is coerced

Definition at line 16 of file ScopeNumber.h.

template<class T>
T scope::ScopeNumber< T >::upperLimit
protected

upper limit (including) to which the value is coerced

Definition at line 19 of file ScopeNumber.h.


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