3 #include "ScopeValue.h"
11 :
public ScopeValue<T>
12 ,
virtual public ScopeValueBase {
23 return( ( v < lowerLimit ) ? lowerLimit : ( v > upperLimit ? upperLimit : v ) );
31 ScopeNumber(
const T& _v = 0,
const T& _ll = 0,
const T& _ul = 0,
const std::wstring& _name = L
"None")
115 bool operator<(const ScopeNumber<T>& r)
const {
116 return (
Value() < r.Value() );
119 bool operator<(
const T& r)
const {
120 return (
Value() < r );
123 bool operator>(
const ScopeNumber<T>& r)
const {
124 return (
Value() > r.Value() );
127 bool operator>(
const T& r)
const {
128 return (
Value() > r );
131 bool operator==(
const ScopeNumber<T>& r)
const {
132 return (
Value() == r.Value() );
139 bool operator!=(
const ScopeNumber<T>& r)
const {
140 return !(operator==(r));
150 std::lock_guard<std::mutex> lock(
mutex);
156 std::lock_guard<std::mutex> lock(
mutex);
174 T
SetLimits(
const T& _ll,
const T& _ul,
const bool& _callguisignal =
true,
const bool& _callothersignal =
true,
const bool& _callatnochange =
false) {
176 bool changed =
false;
178 std::lock_guard<std::mutex> lock(
mutex);
179 lowerLimit = ( ( _ll < _ul ) ? _ll : _ul );
180 upperLimit = ( ( _ll < _ul ) ? _ul : _ll );
182 changed = (tmp !=
value);
190 if ( changed || _callatnochange) {
191 if ( _callguisignal )
193 if ( _callothersignal )
std::wstring Name() const
signalchange_t changesigother
signal that is called for other stuff on value changes
virtual T Set(const T &_v, const bool &_callguisignal=true, const bool &_callothersignal=true, const bool &_callatnochange=false)
Sets the value and calls both change signals if the value actually changed.
T lowerLimit
lower limit (including) to which the value is coerced
ScopeValueBase & operator=(const ScopeValueBase &_svb)
Safe assignment.
std::mutex mutex
a mutex for protection.
T SetLimits(const T &_ll, const T &_ul, const bool &_callguisignal=true, const bool &_callothersignal=true, const bool &_callatnochange=false)
Sets the limits and coerces the value accordingly change signal is called if value has to be coerced...
T SetWithLimits(const T &v, const T &ll, const T &ul)
Sets new value and new limits at the same time.
T upperLimit
upper limit (including) to which the value is coerced
bool readwrite
read-write state, true if read&write, false if onyl read (not an atomic, since access to the data var...
ScopeNumber(const ScopeNumber< T > &orig)
Safe copy constructor.
ScopeNumber(const T &_v=0, const T &_ll=0, const T &_ul=0, const std::wstring &_name=L"None")
ScopeNumber & operator=(const ScopeNumber< T > &v)
Safe assignment.
signalchange_t changesiggui
signal that is called for GUI on value changes
A templated class for a thread-safe numeric value, with signals that are called on value changes...
Base class for a thread-safe value, with signals that are called on value changes.
ScopeNumber & operator=(const T &v)
Safe assignment, does keep name and limits.
T CoerceValue(const T &v) const override
Does the actual coercion in between the lowerLimit and upperLimit.