![]() |
Scanframe Modular Application 0.1.0
|
Class for creating and referencing global or local created parameters or settings called variables. This class allows linking of member functions of other classes to handle events generated. See the Example on how to use this class and the 'TVariableHandler' template class. More...
#include <Variable.h>
Public Member Functions | |
Variable () | |
Default constructor for a default global variable. | |
Variable (const Variable &v) | |
Copy constructor. Copies also the Desired ID data member. | |
Variable (id_type id, bool set_desired) | |
Creates an instance having a reference with 'id'. | |
Variable (const std::string &definition, id_type id_ofs=0) | |
Creates a variable according to the definition std::string passed to it. The "id" from the definition string is the passed id offset added to form a final id. This used when instances are created from resource strings for multiple instances of the same module. | |
Variable (const Definition &def, id_type id_ofs=0) | |
Creates a variable using the passed definition structure. | |
~Variable () override | |
Virtual destructor. | |
bool | setup (const std::string &definition, id_type id_ofs=0) |
Creates a variable according to the definition std::string passed to it. The passed identifier offset 'id_ofs' is added to the id in the string. This used when instances are created from resource strings for multiple instances of the same module. | |
bool | setup (const Definition &definition, id_type id_ofs=0) |
Creates a variable using the definition structure. | |
bool | setup (const Variable &v) |
Sets reference to other variable. This is the only way for local variables. | |
bool | setup (id_type id, bool set_did=false) |
Sets reference to other by id. The global list of references is searched for the passed id and referenced when found. When found event veIdChanged is emitted. When the desired id was set and changed the veDesiredId event is emitted. Cannot be used for local variables. | |
bool | setId (id_type id, bool skip_self=false) const |
Only for local non exported owning variables to set the id after setup is called using a string. The id can not be zero and attached local variables are notify with a veNewId event. | |
bool | isValid () const |
Checks validity of the attached reference and used after a setup call. | |
bool | isConverted () const |
Checks if the current instance is converting floating point values. | |
bool | setConvert (bool enable) |
Enables or disables conversion of floating point values. If a change was triggered a veConverted event was emitted. | |
bool | isNumber () const |
Checks if the value is a number or not. Result is true when the value type is either Value::vitFloat or Value::vitInteger. | |
void | makeOwner () |
Makes this instance owner of this variable instance and emits the appropriate events. When the owner really changes instances the new owner handler receives a veGetOwner event and the previous one veLostOwner. | |
Variable & | getOwner () const |
Gets a reference to the owner/server instance of this variable. | |
bool | isOwner () const |
Checks if this instance is the owner of this variable. | |
bool | isGlobal () const |
Check if this instance is a global variable or not. | |
bool | setGlobal (bool global) |
Sets the variable to be global. This can only happen if it attached to Zero Variable so when the id is zero. | |
bool | setExport (bool global) |
Makes an owning local variable appear globally. Useful when reading/creating instances from stored files. First as local instances and then making them global. | |
bool | isExported () const |
Checks if the variable is an exported local variable. | |
bool | isTemporary () const |
Checks if a temporary is used instead of current actual value. | |
void | setTemporary (bool on_off) |
When true is passed a local temporary value is used instead of current. | |
bool | applyTemporary (bool skip_self=true) const |
Applies the temporary value of this instance. Used mainly in dialogs to apply the changed value to become the actual current one. The 'skip_self' flag is set to true by default because an event was already sent using setCur(). | |
bool | updateTemporary (bool skip_self=false) |
Updates the temporary value with the real value. | |
bool | isTemporaryDifferent () const |
Check if the temporary value differs from the actual value. Used mainly in dialogs to enable an apply button. | |
void | setHandler (VariableHandler *handler) |
Only one link is available at a time. Sets an event handler for this variable, passing NULL wil disable the link. | |
VariableHandler * | getHandler () const |
Gets the link set by setHandler(). | |
size_type | emitEvent (EEvent event, bool skip_self=false) |
Initiate event for all instances of this variable depending on the event value. Returns the amount of effected variables by this call. | |
void | setDesiredId () |
Sets the desired id member variable to the current attached reference id. | |
void | setDesiredId (id_type id) |
Sets the desired id member variable to the passed id. If the passed 'id' is zero the automatic attachment mechanism is disabled. | |
template<typename T > | |
void | setData (T data) |
Sets the data for this instance for user purposes. | |
template<typename T = uint64_t> | |
T | getData () const |
Gets the data for this instance for user purposes Set with setData(). | |
bool | setCur (const Value &value, bool skip_self=false) |
Both return true if there was a change and notify all variables of the same variable id through an event. | |
bool | setCur (const Value &value, bool skip_self=false) const |
Same as setCur() but for const instances objects of this instance. | |
bool | loadCur (const Value &value) const |
Used in settings loading routines which use the owner to Set a new value. Checks if clients have write access and is global before applying the new value. | |
bool | increase (int steps, bool skip_self=false) |
Increase current variable value by step increments also negative values. Emits event veValueChange when a change is flags occurred. | |
bool | unsetFlag (flags_type flag, bool skip_self=false) const |
Unsets a flag or multiple flags of the attached VariableReference. Emits event veValueChange when a change in flags occurred. | |
bool | setFlag (flags_type flag, bool skip_self=false) const |
Sets a flag or multiple flags on the reference. Only for an owner can call this function successful. Emits event veFlagsChange when a change in flags occurred. | |
bool | updateFlags (flags_type flags, bool skip_self=false) const |
Replaces all flags with the passed flags. Only for an owner can call this function successful. Emits event veFlagsChange when a change in flags occurred. | |
flags_type | getFlags () const |
Gets the flags at the time the instance was created. | |
flags_type | getCurFlags () const |
Gets the current flags for this instance. | |
bool | setConvertValues (const std::string &unit, const Value &multiplier, const Value &offset, int digits=std::numeric_limits< int >::max()) const |
Sets the global conversion values and signals the clients. Only with owners a call is successful and effective. The formula is: converted = (current * multiplier) + offset When successful event veConverted emitted. | |
bool | setConvertValues (bool convert=true) const |
Enables or disables unit conversion. Only owners can make this call successfully. Depending on the globally set handler using setConvertHandler() this function calls the handler with event veConvert which then should apply the conversion values using setConvertValues() on the 'call_var' passed. When the global conversion handler has not been set the Makes a call to the unit conversion interface and tries to get conversion values from it. When the global conversion handler not set it uses the locally available conversion values. | |
id_type | getId () const |
Gets the current attached ID. | |
id_type | getDesiredId () const |
Gets the desired id of this instance. | |
std::string | getName (int levels=0) const |
Gets the name or a part of the name of the attached variable. Returns the variable name which is default (level 0) the full variable path name. When levels is 'n' and larger than zero the last 'n' levels are returned. When levels is 'n' and smaller than zero the first 'n' levels are omitted. | |
int | getNameLevelCount () const |
Gets the amount of levels of the full name path. | |
std::string | getUnit () const |
Gets the variable unit. | |
std::string | getUnit (bool converted) const |
Gets variable unit of converted or non-converted value. | |
std::string | getConvertOption () const |
Gets the conversion option string. This string determines how the value is to be converted when exporting. | |
EStringType | getStringType () const |
Gets the string type which is determined by the character(s) in the unit field. The maximum length is determined by the round value in the setup string. | |
std::string | getDescription () const |
Gets the purpose description of the attached variable. | |
bool | isFlag (int flag) const |
Gets if a flag or flags has been set currently. | |
std::string | getCurFlagsString () const |
Gets the current flags in a std::string form. | |
std::string | getFlagsString () const |
Gets the flags at setup in a std::string form. | |
bool | isReadOnly () const |
Checks if variable is allowed to change its value. | |
int | getSigDigits () const |
Gets the normalized decimal point location for this instance. | |
int | getSigDigits (bool converted) const |
Gets the normalized decimal point location for this instance converted or not converted. | |
int | getRequiredDigits () const |
Gets the required digits for this instance based on round, min and max values. Converted or not the value is the same. This method is useful for drawing a scale using numberString() | |
const Value & | getDef () const |
Gets the variable default value. Is converted when converted flag is true. | |
const Value & | getMin () const |
Gets the variable Minimum value. Is converted when converted flag is true. | |
const Value & | getMax () const |
Gets the variable Maximum value. Is converted when converted flag is true. | |
const Value & | getRnd () const |
Gets the variable Rounding value. Converted when converted flag is true. | |
const Value & | getCur () const |
Gets the variable current value. Is converted when converted flag is true. | |
const Value & | getDef (bool converted) const |
Gets the default value converted or not Is converted independent of the conversion flag. | |
const Value & | getMin (bool converted) const |
Gets the Minimum value converted or not converted independent of the conversion flag. | |
const Value & | getMax (bool converted) const |
Gets the Maximum value converted or not converted independent of the conversion flag. | |
const Value & | getRnd (bool converted) const |
Gets the Rounding value converted or not converted independent of the conversion flag. | |
const Value & | getCur (bool converted) const |
Gets the current value converted or not converted independent of the conversion flag. | |
const State::Vector & | getStates () const |
Gets the complete state vector as a reference. | |
size_type | getUsageCount () const |
Gets the usage count of this variable reference. | |
size_type | getStateCount () const |
Gets the state count. | |
size_type | getState (const Value &v) const |
Gets the state index of passed value when it exists. | |
std::string | getStateName (size_type state) const |
Gets the display name of the passed state's index. | |
const Value & | getStateValue (size_type state) const |
Gets the value of the passed state index. | |
Value::EType | getType () const |
Gets current type enumerate of this variable instance. | |
Variable & | operator= (const Variable &v) |
Assignment operator that attaches this instance to the same VariableReference as 'v'. | |
int | operator== (const Variable &v) const |
Comparison operator. | |
std::string | getCurString (bool use_states=true) const |
Gets current converted value in default formatted string or state. When a temporary value is used that value is returned. | |
std::string | getSetupString () const |
Gets the setup std::string for this variable. | |
void | clipRound (Value &value) const |
Clips the passed value between min and max values. | |
Value | convert (const Value &value, bool to_org=false) const |
Gets the passed value converted to new units or back again. | |
bool | writeUpdate (std::ostream &os) const |
Writes id and current value and flags to the stream. | |
bool | write (std::ostream &os) const |
Writes id and current value to the stream. | |
void | operator delete (void *) |
During events no instances should be deleted. The destructor will be called but the data still exist. | |
![]() | |
virtual | ~InformationBase ()=default |
Virtual destructor so derived classes can be destroyed by a pointer of this type. | |
![]() | |
template<typename T > | |
constexpr std::enable_if_t<(sizeof(T)<=sizeof(data_type)), data_type > | toDataType (T value) const |
Casts any type to a data_type value. | |
template<typename T > | |
constexpr std::enable_if_t<(sizeof(T)<=sizeof(data_type)), T > | fromDataType (data_type value) const |
Casts a data_type value to a given type. | |
Static Public Member Functions | |
static void | initialize () |
Must be called to initialize the statics which this class depends on. | |
static void | uninitialize () |
Called when terminating the application. | |
static void | setConvertHandler (VariableHandler *handler) |
Special handler for converting float variables globally. Sets an event handler for this variable, passing NULL wil disable the handler. | |
static VariableHandler * | getConvertHandler () |
Gets the link to the global conversion handler. | |
static std::string | filterString (const std::string &str, EStringType type, size_t max_len) |
Filters the passed string according the given type. | |
static std::string_view | getStringType (EStringType type) |
Gets the description string for passed string type. | |
static EStringType | getStringType (const std::string &flags) |
Gets the string type value of the passed string. | |
static Value::EType | getType (std::string_view type) |
Gets enumerate value of the passed string. | |
static std::string | getType (Value::EType type) |
Gets type string of given enumerate value. | |
static size_type | getCount () |
Gets the amount of variables having different ID's in the system. | |
static size_type | getInstanceCount (bool global_only=true) |
Gets the total amount of variable instances in the system. | |
static PtrVector | getList () |
Retrieves a list of instances available (global + exported). Useful in populating a selection dialog. | |
static std::string | getFieldName (int field) |
Gets the name of the passed field enumerate EField. | |
static const Variable & | getInstanceById (id_type id) |
Gets variable with the given id. When not found it returns the zero variable. | |
static Variable & | getInstanceById (id_type id, PtrVector &list) |
Gets variable with the given id. When not found it returns the zero variable. | |
static const Variable & | getInstanceById (id_type id, const PtrVector &list) |
Gets variable with the given id. When not found it returns the zero variable. | |
static bool | readUpdate (std::istream &is, bool skip_self=false, PtrVector &list=null_ref< PtrVector >()) |
load single current value and flags from stream. If 'list' is other than the default that list is used to seek the according variable instead of the global list. | |
static Definition | getDefinition (const std::string &str) |
static bool | read (std::istream &is, bool skip_self=false, PtrVector &list=null_ref< PtrVector >()) |
static bool | create (std::istream &is, PtrVector &list=null_ref< PtrVector >(), bool global=true, int &err_line=null_ref< int >()) |
Reads multiple variable setup strings from stream separated by newline characters. Gets true when no error occurred during the process. On error returns false and line returns the error line in the stream. If 'list' is other than a NULL_REF the created variables are added to that list. | |
static flags_type | toFlags (const std::string &flags) |
Converts a std::string with flag characters to an integer. | |
static std::string | getFlagsString (flags_type flags) |
Gets the passed flags in a std::string form. | |
static std::string_view | getEventName (EEvent event) |
Gets the event name to make debugging easier. | |
Protected Member Functions | |
Variable (bool global) | |
Creates global or local variable instance depending on the value passed. | |
Friends | |
class | VariableHandler |
class | VariableReference |
class | VariableStatic |
Additional Inherited Members | |
![]() | |
enum | EEvent : int { veConvert = 64000 , veNewId = -32000 , veUserGlobal , veFirstLocal = 0 , veFlagsChange = 1 , veValueChange = 2 , veInvalid = 3 , veConverted = 4 , veUserLocal = 5 , veFirstPrivate = 16000 , veIdChanged = 16001 , veDesiredId = 16002 , veRemove = 16003 , veGetOwner = 16004 , veLostOwner = 16005 , veLinked = 16006 , veUnlinked = 16007 , veSetup = 16008 , veUserPrivate = 16009 } |
Events send to the handler set with sf::Variable::setHandler. More... | |
enum | EField : int { vfId = 0 , vfName , vfUnit , vfFlags , vfDescription , vfType , vfConversionType , vfRound , vfDefault , vfMinimum , vfMaximum , vfFirstState } |
Enumeration of the order of fields in the setup string. More... | |
enum | EFlag : flags_type { flgReadonly = 1 << 0 , flgArchive = 1 << 1 , flgShare = 1 << 2 , flgLink = 1 << 3 , flgFunction = 1 << 4 , flgParameter = 1 << 5 , flgHidden = 1 << 6 , flgExport = 1 << 7 , flgWriteable = 1 << 8 } |
Enumeration type for specifying flags. More... | |
enum | EStringType : int { stNormal = 0 , stMulti , stPath , stDirectory , stFilename , stSubdirectory } |
Enumeration of string types used for filtering. More... | |
typedef TVector< Variable * > | PtrVector |
Vector for pointers to variables. | |
typedef TVector< Variable > | Vector |
Vector for instances of variables. | |
typedef TVector< VariableReference * > | ReferenceVector |
Types for internal use. | |
![]() | |
typedef unsigned long long | id_type |
Type used for the identifying integer (64-bits). | |
typedef int32_t | flags_type |
Type used for the flag integer. | |
typedef size_t | size_type |
Type used for size of vectors. | |
typedef uint64_t | data_type |
Type used for containing a single data element which is the largest integer. | |
typedef int64_t | sdata_type |
Type used for containing a single data element which is the largest signed integer. | |
typedef TVector< id_type > | IdVector |
Vector for lists of information ID's. | |
typedef TVector< InformationBase * > | Vector |
Vector for containing different information base derived classes. | |
![]() | |
static constexpr size_t | npos = std::numeric_limits<size_type>::max() |
Unsigned size value indicating not found or no index. | |
Class for creating and referencing global or local created parameters or settings called variables. This class allows linking of member functions of other classes to handle events generated. See the Example on how to use this class and the 'TVariableHandler' template class.
sf::Variable::Variable | ( | ) |
Default constructor for a default global variable.
|
inline |
Copy constructor. Copies also the Desired ID data member.
|
inline |
Creates an instance having a reference with 'id'.
id | Identifying number. |
set_desired | When true the desired id data member is set to the passed id as well. |
|
explicit |
Creates a variable according to the definition std::string passed to it. The "id" from the definition string is the passed id offset added to form a final id. This used when instances are created from resource strings for multiple instances of the same module.
definition | Definition string. |
id_ofs | offset for the 'id'. |
|
inlineexplicit |
Creates a variable using the passed definition structure.
def | Definition structure. |
id_ofs | offset for the 'id'. |
|
override |
Virtual destructor.
|
explicitprotected |
Creates global or local variable instance depending on the value passed.
global | True when global, false when local. |
bool sf::Variable::applyTemporary | ( | bool | skip_self = true | ) | const |
Applies the temporary value of this instance. Used mainly in dialogs to apply the changed value to become the actual current one. The 'skip_self' flag is set to true by default because an event was already sent using setCur().
skip_self | When 'true' this instance is skipped in emission of events. |
void sf::Variable::clipRound | ( | Value & | value | ) | const |
Clips the passed value between min and max values.
value | Value to be clipped. |
Gets the passed value converted to new units or back again.
value | Value to be converted. |
to_org | Direction of conversion. |
|
static |
Reads multiple variable setup strings from stream separated by newline characters. Gets true when no error occurred during the process. On error returns false and line returns the error line in the stream. If 'list' is other than a NULL_REF the created variables are added to that list.
is | |
list | |
global | |
err_line |
Initiate event for all instances of this variable depending on the event value. Returns the amount of effected variables by this call.
event | |
skip_self | When 'true' this instance is skipped in emission of events. |
|
static |
Filters the passed string according the given type.
str | String to filter. |
type | String type. |
max_len | Maximum length of the string when non-zero. |
|
static |
Gets the link to the global conversion handler.
std::string sf::Variable::getConvertOption | ( | ) | const |
Gets the conversion option string. This string determines how the value is to be converted when exporting.
|
static |
Gets the amount of variables having different ID's in the system.
const Value & sf::Variable::getCur | ( | ) | const |
Gets the variable current value. Is converted when converted flag is true.
const Value & sf::Variable::getCur | ( | bool | converted | ) | const |
Gets the current value converted or not converted independent of the conversion flag.
converted | True when getting the converted value. |
flags_type sf::Variable::getCurFlags | ( | ) | const |
Gets the current flags for this instance.
std::string sf::Variable::getCurFlagsString | ( | ) | const |
Gets the current flags in a std::string form.
std::string sf::Variable::getCurString | ( | bool | use_states = true | ) | const |
Gets current converted value in default formatted string or state. When a temporary value is used that value is returned.
use_states | Determines if a state string name is to be used. |
T sf::Variable::getData | ( | ) | const |
Gets the data for this instance for user purposes Set with setData().
T | Type of the data being retrieved. |
const Value & sf::Variable::getDef | ( | ) | const |
Gets the variable default value. Is converted when converted flag is true.
const Value & sf::Variable::getDef | ( | bool | converted | ) | const |
Gets the default value converted or not Is converted independent of the conversion flag.
converted | True when getting the converted value. |
|
static |
Fills a definition structure from a string. On failure the _valid field is set to false.
str | Definition string |
std::string sf::Variable::getDescription | ( | ) | const |
Gets the purpose description of the attached variable.
|
inline |
Gets the desired id of this instance.
|
static |
Gets the event name to make debugging easier.
event | The event enumerate/number. |
|
static |
Gets the name of the passed field enumerate EField.
flags_type sf::Variable::getFlags | ( | ) | const |
Gets the flags at the time the instance was created.
std::string sf::Variable::getFlagsString | ( | ) | const |
Gets the flags at setup in a std::string form.
|
static |
Gets the passed flags in a std::string form.
flags |
|
inline |
Gets the link set by setHandler().
id_type sf::Variable::getId | ( | ) | const |
Gets the current attached ID.
Gets variable with the given id. When not found it returns the zero variable.
id | Variable id to seek. |
Gets variable with the given id. When not found it returns the zero variable.
id | Variable id to seek. |
list | Vector to use for lookup. |
Gets variable with the given id. When not found it returns the zero variable.
id | Variable id to seek. |
list | Vector to use for lookup. |
|
static |
Gets the total amount of variable instances in the system.
global_only | When true, count only the global ones. |
|
static |
Retrieves a list of instances available (global + exported). Useful in populating a selection dialog.
const Value & sf::Variable::getMax | ( | ) | const |
Gets the variable Maximum value. Is converted when converted flag is true.
const Value & sf::Variable::getMax | ( | bool | converted | ) | const |
Gets the Maximum value converted or not converted independent of the conversion flag.
converted | True when getting the converted value. |
const Value & sf::Variable::getMin | ( | ) | const |
Gets the variable Minimum value. Is converted when converted flag is true.
const Value & sf::Variable::getMin | ( | bool | converted | ) | const |
Gets the Minimum value converted or not converted independent of the conversion flag.
converted | True when getting the converted value. |
std::string sf::Variable::getName | ( | int | levels = 0 | ) | const |
Gets the name or a part of the name of the attached variable. Returns the variable name which is default (level 0) the full variable path name. When levels is 'n' and larger than zero the last 'n' levels are returned. When levels is 'n' and smaller than zero the first 'n' levels are omitted.
levels | Amount of required levels. |
int sf::Variable::getNameLevelCount | ( | ) | const |
Gets the amount of levels of the full name path.
Variable & sf::Variable::getOwner | ( | ) | const |
Gets a reference to the owner/server instance of this variable.
int sf::Variable::getRequiredDigits | ( | ) | const |
Gets the required digits for this instance based on round, min and max values. Converted or not the value is the same. This method is useful for drawing a scale using numberString()
const Value & sf::Variable::getRnd | ( | ) | const |
Gets the variable Rounding value. Converted when converted flag is true.
const Value & sf::Variable::getRnd | ( | bool | converted | ) | const |
Gets the Rounding value converted or not converted independent of the conversion flag.
converted | True when getting the converted value. |
std::string sf::Variable::getSetupString | ( | ) | const |
Gets the setup std::string for this variable.
int sf::Variable::getSigDigits | ( | ) | const |
Gets the normalized decimal point location for this instance.
int sf::Variable::getSigDigits | ( | bool | converted | ) | const |
Gets the normalized decimal point location for this instance converted or not converted.
converted | True when needing the converted amount. |
size_type sf::Variable::getStateCount | ( | ) | const |
Gets the state count.
std::string sf::Variable::getStateName | ( | size_type | state | ) | const |
Gets the display name of the passed state's index.
state | Index of the state. |
const State::Vector & sf::Variable::getStates | ( | ) | const |
Gets the complete state vector as a reference.
Gets the value of the passed state index.
state | Index of the state. |
EStringType sf::Variable::getStringType | ( | ) | const |
Gets the string type which is determined by the character(s) in the unit field. The maximum length is determined by the round value in the setup string.
|
static |
Gets the string type value of the passed string.
flags | String containing flag(s) |
|
static |
Gets the description string for passed string type.
type | Enumerate value. |
Value::EType sf::Variable::getType | ( | ) | const |
Gets current type enumerate of this variable instance.
|
inlinestatic |
Gets enumerate value of the passed string.
type | String representing the type. |
|
inlinestatic |
Gets type string of given enumerate value.
type | Enumerate type. |
std::string sf::Variable::getUnit | ( | ) | const |
Gets the variable unit.
std::string sf::Variable::getUnit | ( | bool | converted | ) | const |
Gets variable unit of converted or non-converted value.
converted | True when getting the converted value. |
size_type sf::Variable::getUsageCount | ( | ) | const |
Gets the usage count of this variable reference.
bool sf::Variable::increase | ( | int | steps, |
bool | skip_self = false |
||
) |
Increase current variable value by step increments also negative values. Emits event veValueChange when a change is flags occurred.
steps | Amount of increments (>0) or decrements (<0) |
skip_self | Skip event on this instance. |
|
static |
Must be called to initialize the statics which this class depends on.
bool sf::Variable::isConverted | ( | ) | const |
Checks if the current instance is converting floating point values.
bool sf::Variable::isExported | ( | ) | const |
Checks if the variable is an exported local variable.
bool sf::Variable::isFlag | ( | int | flag | ) | const |
Gets if a flag or flags has been set currently.
flag | Single value or a multiple of EFlag values. |
|
inline |
Check if this instance is a global variable or not.
bool sf::Variable::isNumber | ( | ) | const |
Checks if the value is a number or not. Result is true when the value type is either Value::vitFloat or Value::vitInteger.
bool sf::Variable::isOwner | ( | ) | const |
Checks if this instance is the owner of this variable.
bool sf::Variable::isReadOnly | ( | ) | const |
Checks if variable is allowed to change its value.
bool sf::Variable::isTemporary | ( | ) | const |
Checks if a temporary is used instead of current actual value.
bool sf::Variable::isTemporaryDifferent | ( | ) | const |
Check if the temporary value differs from the actual value. Used mainly in dialogs to enable an apply button.
bool sf::Variable::isValid | ( | ) | const |
Checks validity of the attached reference and used after a setup call.
bool sf::Variable::loadCur | ( | const Value & | value | ) | const |
Used in settings loading routines which use the owner to Set a new value. Checks if clients have write access and is global before applying the new value.
value |
void sf::Variable::makeOwner | ( | ) |
Makes this instance owner of this variable instance and emits the appropriate events. When the owner really changes instances the new owner handler receives a veGetOwner event and the previous one veLostOwner.
void sf::Variable::operator delete | ( | void * | ) |
During events no instances should be deleted. The destructor will be called but the data still exist.
Assignment operator that attaches this instance to the same VariableReference as 'v'.
|
inline |
Comparison operator.
|
static |
load single current values from stream. If 'list' is other than a NULL_REF that list is used to seek the according variable instead of the global list.
is | |
skip_self | When 'true' this instance is skipped in emission of events. |
list |
|
static |
load single current value and flags from stream. If 'list' is other than the default that list is used to seek the according variable instead of the global list.
is | |
skip_self | When 'true' this instance is skipped in emission of events. |
list |
bool sf::Variable::setConvert | ( | bool | enable | ) |
Enables or disables conversion of floating point values. If a change was triggered a veConverted event was emitted.
enable | To enable pass 'true'. to disable 'false'. |
|
static |
Special handler for converting float variables globally. Sets an event handler for this variable, passing NULL wil disable the handler.
handler | Handler from conversion interface. |
bool sf::Variable::setConvertValues | ( | bool | convert = true | ) | const |
Enables or disables unit conversion. Only owners can make this call successfully.
Depending on the globally set handler using setConvertHandler() this function calls the handler with event veConvert which then should apply the conversion values using setConvertValues() on the 'call_var' passed.
When the global conversion handler has not been set the Makes a call to the unit conversion interface and tries to get conversion values from it.
When the global conversion handler not set it uses the locally available conversion values.
convert | When true conversion is enabled and false disabled. |
bool sf::Variable::setConvertValues | ( | const std::string & | unit, |
const Value & | multiplier, | ||
const Value & | offset, | ||
int | digits = std::numeric_limits< int >::max() |
||
) | const |
Sets the global conversion values and signals the clients. Only with owners a call is successful and effective. The formula is: converted = (current * multiplier) + offset When successful event veConverted emitted.
unit | New unit string. |
multiplier | Multiplier value. |
offset | offset value. |
digits | Significant digits for the new unit. |
bool sf::Variable::setCur | ( | const Value & | value, |
bool | skip_self = false |
||
) |
Both return true if there was a change and notify all variables of the same variable id through an event.
value | Sets a new current value. |
skip_self | When 'true' this instance is skipped in emission of events. |
|
inline |
Same as setCur() but for const instances objects of this instance.
value | Sets a new current value. |
skip_self | When 'true' this instance is skipped in emission of events. |
void sf::Variable::setData | ( | T | data | ) |
Sets the data for this instance for user purposes.
T | Type of the data being set. |
data | Could be a pointer cast value. |
void sf::Variable::setDesiredId | ( | ) |
Sets the desired id member variable to the current attached reference id.
void sf::Variable::setDesiredId | ( | id_type | id | ) |
Sets the desired id member variable to the passed id. If the passed 'id' is zero the automatic attachment mechanism is disabled.
bool sf::Variable::setExport | ( | bool | global | ) |
Makes an owning local variable appear globally. Useful when reading/creating instances from stored files. First as local instances and then making them global.
global | True to export as global and False to revert it. |
bool sf::Variable::setFlag | ( | flags_type | flag, |
bool | skip_self = false |
||
) | const |
Sets a flag or multiple flags on the reference. Only for an owner can call this function successful. Emits event veFlagsChange when a change in flags occurred.
flag | Single or multiple values of EFlag. |
skip_self | Skip event on this instance. |
bool sf::Variable::setGlobal | ( | bool | global | ) |
Sets the variable to be global. This can only happen if it attached to Zero Variable so when the id is zero.
global | True when global and False when local. |
void sf::Variable::setHandler | ( | VariableHandler * | handler | ) |
Only one link is available at a time. Sets an event handler for this variable, passing NULL wil disable the link.
handler |
bool sf::Variable::setId | ( | id_type | id, |
bool | skip_self = false |
||
) | const |
Only for local non exported owning variables to set the id after setup is called using a string. The id can not be zero and attached local variables are notify with a veNewId event.
id | Variable identifier |
skip_self | When false the event to its own handler is skipped to be emitted. |
void sf::Variable::setTemporary | ( | bool | on_off | ) |
When true is passed a local temporary value is used instead of current.
on_off |
bool sf::Variable::setup | ( | const Definition & | definition, |
id_type | id_ofs = 0 |
||
) |
Creates a variable using the definition structure.
definition | Definition structure. |
id_ofs | offset for the 'id'. |
|
inline |
Creates a variable according to the definition std::string passed to it. The passed identifier offset 'id_ofs' is added to the id in the string. This used when instances are created from resource strings for multiple instances of the same module.
definition | Comma separated definition string. |
id_ofs | offset for the 'id'. |
|
inline |
Sets reference to other variable. This is the only way for local variables.
v |
|
inline |
Sets reference to other by id. The global list of references is searched for the passed id and referenced when found. When found event veIdChanged is emitted. When the desired id was set and changed the veDesiredId event is emitted. Cannot be used for local variables.
id | Identifier. |
set_did | When true the desired id is set to the passed 'id'. |
|
static |
Converts a std::string with flag characters to an integer.
flags |
|
static |
Called when terminating the application.
bool sf::Variable::unsetFlag | ( | flags_type | flag, |
bool | skip_self = false |
||
) | const |
Unsets a flag or multiple flags of the attached VariableReference. Emits event veValueChange when a change in flags occurred.
flag | Single or multiple values of EFlag. |
skip_self | When 'true' this instance is skipped in emission of events. |
bool sf::Variable::updateFlags | ( | flags_type | flags, |
bool | skip_self = false |
||
) | const |
Replaces all flags with the passed flags. Only for an owner can call this function successful. Emits event veFlagsChange when a change in flags occurred.
flags | Single or multiple values of EFlag. |
skip_self | When 'true' this instance is skipped in emission of events. |
bool sf::Variable::updateTemporary | ( | bool | skip_self = false | ) |
Updates the temporary value with the real value.
Used mainly in dialogs to update the temporary value with real/actual value.
skip_self | When 'true' this instance is skipped in emission of events. |
bool sf::Variable::write | ( | std::ostream & | os | ) | const |
Writes id and current value to the stream.
os |
bool sf::Variable::writeUpdate | ( | std::ostream & | os | ) | const |
Writes id and current value and flags to the stream.
|
friend |
|
friend |
|
friend |