3 #include "ScopeValueBase.h"
5 #include "ScopeException.h"
24 ScopeValue(
const T& _value = T(0),
const std::wstring& _name = L
"None")
41 Set(v,
true,
true,
false);
47 std::lock_guard<std::mutex> lock(
mutex);
67 virtual T
Set(
const T& _v,
const bool& _callguisignal =
true,
const bool& _callothersignal =
true,
const bool& _callatnochange =
false) {
72 std::lock_guard<std::mutex> lock(
mutex);
87 if ( changed || _callatnochange) {
90 if ( _callothersignal )
100 std::wstring
ToChar()
const;
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.
ScopeValueBase & operator=(const ScopeValueBase &_svb)
Safe assignment.
ScopeValue & operator=(const T &v)
Safe assignment.
void AddToPropertyTree(boost::property_tree::wptree &pt) const
Adds the value to a Boost property tree, using its name and value.
std::mutex mutex
a mutex for protection.
virtual T CoerceValue(const T &v) const
When setting the value it can be coerced by a derivation of this function.
bool readwrite
read-write state, true if read&write, false if onyl read (not an atomic, since access to the data var...
In here all declarations for all kinds of datatypes Scope needs.
ScopeValue & operator=(const ScopeValue &v)
Safe assignment.
std::wstring ToChar() const
Converts value into a wstring.
void ScopeExceptionHandler(const std::string &_origin, const bool &_log, const bool &_showmessagebox, const bool &_trace, const bool &_rethrow)
Handles all exceptions and does nice logging.
signalchange_t changesiggui
signal that is called for GUI on value changes
A templated class for a thread-safe value, with signals to GUI or other stuff that are called on valu...
void SetFromString(const std::wstring &str)
Parses a wstring and sets the value accordingly.
void SetFromPropertyTree(const boost::property_tree::wptree &pt)
Set value from a Boost property, using its name as a key.
Base class for a thread-safe value, with signals that are called on value changes.
ScopeValue(const T &_value=T(0), const std::wstring &_name=L"None")
Construct and set silently.