![]() |
Scanframe Modular Application 0.1.0
|
Script object for exporting GII parameters to a script object. More...
#include <VariableScriptObject.h>
Public Member Functions | |
VariableScriptObject (const Parameters ¶ms) | |
std::string | getStatusText () override |
Overloaded from base class. | |
![]() | |
ScriptObject (const char *type_name, ScriptObject *parent=nullptr) | |
virtual | ~ScriptObject ()=default |
Virtual destructor which can be overloaded to clean up objects. | |
int | getRefCount () const |
Gets the reference count. | |
operator Value () const | |
Cast operator to be able to return this instance as a Value. | |
std::string | getTypeName () const |
Returns the type name Set at the constructor. | |
ScriptObject * | getParent () |
Gets the script object owner. | |
const ScriptObject * | getParent () const |
Gets the script object owner. | |
ScriptObject * | castToObject (const Value &value) |
Casts a sf::Value::vitCustom typed sf::Value to a ScriptObject typed pointer. | |
![]() | |
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. | |
Protected Member Functions | |
const IdInfo * | getInfo (const std::string &name) const override |
Overloaded from base class. | |
void | destroyObject (bool &should_delete) override |
Overloaded from base class. | |
bool | getSetValue (const IdInfo *info, Value *value, Value::vector_type *params, bool flag_set) override |
Overloaded from base class. | |
![]() | |
void | makeParent (ScriptObject *so) |
Makes this object the owner of the other object. | |
void | setParent (ScriptObject *parent) |
Sets the owner to the pass script object. | |
![]() | |
Variable (bool global) | |
Creates global or local variable instance depending on the value passed. | |
Additional Inherited Members | |
![]() | |
enum | EIdentifier { idUnknown = 0 , idConstant , idVariable , idFunction , idTypedef , idKeyword } |
Keyword identifiers. More... | |
typedef std::string::size_type | pos_type |
Source position type. | |
typedef ssize_t | ip_type |
Instruction pointer type. | |
![]() | |
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 const IdInfo * | getInfoUnknown () |
Returns the static Info structure for unknowns. | |
![]() | |
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. | |
![]() | |
static constexpr size_t | npos = std::numeric_limits<size_type>::max() |
Unsigned size value indicating not found or no index. | |
Script object for exporting GII parameters to a script object.
|
explicit |
|
inlineoverrideprotectedvirtual |
Overloaded from base class.
Implements sf::ScriptObject.
|
overrideprotectedvirtual |
Overloaded from base class.
Implements sf::ScriptObject.
|
overrideprotectedvirtual |
Overloaded from base class.
Implements sf::ScriptObject.
|
overridevirtual |
Overloaded from base class.
Reimplemented from sf::ScriptObject.