283 template<
typename T = u
int64_t>
300 [[nodiscard]]
bool setCur(
const Value& value,
bool skip_self =
false)
const;
380 bool setConvertValues(
const std::string& unit,
const Value& multiplier,
const Value& offset,
int digits = std::numeric_limits<int>::max())
const;
416 [[nodiscard]] std::string
getName(
int levels = 0)
const;
435 [[nodiscard]] std::string
getUnit(
bool converted)
const;
476 [[nodiscard]]
bool isFlag(
int flag)
const;
747 static bool readUpdate(std::istream& is,
bool skip_self =
false,
PtrVector& list = null_ref<PtrVector>());
772 static bool read(std::istream& is,
bool skip_self =
false,
PtrVector& list = null_ref<PtrVector>());
785 static bool create(std::istream& is,
PtrVector& list = null_ref<PtrVector>(),
bool global =
true,
int& err_line = null_ref<int>());
812 void operator delete(
void*);
833 bool updateValue(
const Value& value,
bool skip_self)
const;
839 bool updateTempValue(
const Value& value,
bool skip_self);
847 [[maybe_unused]]
size_type emitLocalEvent(
EEvent event,
bool skip_self =
true)
const;
855 [[maybe_unused]]
size_type emitGlobalEvent(
EEvent event,
bool skip_self =
true)
const;
903 bool _converted{
false};
907 Value* _temporary{
nullptr};
911 VariableHandler* _handler{
nullptr};
915 id_type _desiredId{0};
946#include <gii/gen/Variable.hpp>
Value container class able to performing arithmetic functions.
Definition Value.h:19
EType
Enumerate for available types.
Definition Value.h:34
Base class used for giving a Variable instance access to a member functions of a derived class....
Definition VariableHandler.h:14
Base class of the sf::Variable having all global static data members.
Definition VariableStatic.h:15
This base class contains all local types of used in the Variable class. Multiple inheritance makes th...
Definition VariableTypes.h:26
EStringType
Enumeration of string types used for filtering.
Definition VariableTypes.h:254
EEvent
Events send to the handler set with sf::Variable::setHandler.
Definition VariableTypes.h:130
Class for creating and referencing global or local created parameters or settings called variables....
Definition Variable.h:16
const Value & getCur(bool converted) const
Gets the current value converted or not converted independent of the conversion flag.
int getNameLevelCount() const
Gets the amount of levels of the full name path.
const Value & getMax() const
Gets the variable Maximum value. Is converted when converted flag is true.
bool setConvertValues(bool convert=true) const
Enables or disables unit conversion. Only owners can make this call successfully. Depending on the g...
static std::string filterString(const std::string &str, EStringType type, size_t max_len)
Filters the passed string according the given type.
const Value & getMin(bool converted) const
Gets the Minimum value converted or not converted independent of the conversion flag.
bool setCur(const Value &value, bool skip_self=false) const
Same as setCur() but for const instances objects of this instance.
bool increase(int steps, bool skip_self=false)
Increase current variable value by step increments also negative values. Emits event veValueChange wh...
bool isReadOnly() const
Checks if variable is allowed to change its value.
bool isOwner() const
Checks if this instance is the owner of this variable.
size_type getState(const Value &v) const
Gets the state index of passed value when it exists.
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 ev...
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 defa...
void setData(T data)
Sets the data for this instance for user purposes.
bool setGlobal(bool global)
Sets the variable to be global. This can only happen if it attached to Zero Variable so when the id i...
std::string getStateName(size_type state) const
Gets the display name of the passed state's index.
Variable(id_type id, bool set_desired)
Creates an instance having a reference with 'id'.
std::string getDescription() const
Gets the purpose description of the attached variable.
std::string getSetupString() const
Gets the setup std::string for this variable.
static void uninitialize()
Called when terminating the application.
const Value & getCur() const
Gets the variable current value. Is converted when converted flag is true.
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....
Value convert(const Value &value, bool to_org=false) const
Gets the passed value converted to new units or back again.
static Variable & getInstanceById(id_type id, PtrVector &list)
Gets variable with the given id. When not found it returns the zero variable.
bool updateTemporary(bool skip_self=false)
Updates the temporary value with the real value.
bool isFlag(int flag) const
Gets if a flag or flags has been set currently.
static size_type getCount()
Gets the amount of variables having different ID's in the system.
Value::EType getType() const
Gets current type enumerate of this variable instance.
int getSigDigits() const
Gets the normalized decimal point location for this instance.
const Value & getRnd(bool converted) const
Gets the Rounding value converted or not converted independent of the conversion flag.
~Variable() override
Virtual destructor.
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 use...
Variable(const Definition &def, id_type id_ofs=0)
Creates a variable using the passed definition structure.
bool isNumber() const
Checks if the value is a number or not. Result is true when the value type is either Value::vitFloat ...
Variable & operator=(const Variable &v)
Assignment operator that attaches this instance to the same VariableReference as 'v'.
flags_type getFlags() const
Gets the flags at the time the instance was created.
const Value & getDef() const
Gets the variable default value. Is converted when converted flag is true.
bool setup(const Variable &v)
Sets reference to other variable. This is the only way for local variables.
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....
bool setExport(bool global)
Makes an owning local variable appear globally. Useful when reading/creating instances from stored fi...
static std::string_view getEventName(EEvent event)
Gets the event name to make debugging easier.
int operator==(const Variable &v) const
Comparison operator.
static void initialize()
Must be called to initialize the statics which this class depends on.
flags_type getCurFlags() const
Gets the current flags for this instance.
static std::string_view getStringType(EStringType type)
Gets the description string for passed string type.
bool applyTemporary(bool skip_self=true) const
Applies the temporary value of this instance. Used mainly in dialogs to apply the changed value to be...
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...
const State::Vector & getStates() const
Gets the complete state vector as a reference.
static Value::EType getType(std::string_view type)
Gets enumerate value of the passed string.
static EStringType getStringType(const std::string &flags)
Gets the string type value of the passed string.
size_type getUsageCount() const
Gets the usage count of this variable reference.
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...
VariableHandler * getHandler() const
Gets the link set by setHandler().
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 c...
size_type getStateCount() const
Gets the state count.
std::string getConvertOption() const
Gets the conversion option string. This string determines how the value is to be converted when expor...
id_type getId() const
Gets the current attached ID.
Variable()
Default constructor for a default global variable.
const Value & getMax(bool converted) const
Gets the Maximum value converted or not converted independent of the conversion flag.
std::string getCurString(bool use_states=true) const
Gets current converted value in default formatted string or state. When a temporary value is used tha...
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...
static Definition getDefinition(const std::string &str)
std::string getUnit() const
Gets the variable unit.
bool writeUpdate(std::ostream &os) const
Writes id and current value and flags to the stream.
void setTemporary(bool on_off)
When true is passed a local temporary value is used instead of current.
T getData() const
Gets the data for this instance for user purposes Set with setData().
std::string getCurFlagsString() const
Gets the current flags in a std::string form.
static VariableHandler * getConvertHandler()
Gets the link to the global conversion handler.
std::string getFlagsString() const
Gets the flags at setup in a std::string form.
std::string getUnit(bool converted) const
Gets variable unit of converted or non-converted value.
bool loadCur(const Value &value) const
Used in settings loading routines which use the owner to Set a new value. Checks if clients have writ...
static std::string getFieldName(int field)
Gets the name of the passed field enumerate EField.
EStringType getStringType() const
Gets the string type which is determined by the character(s) in the unit field. The maximum length is...
static const Variable & getInstanceById(id_type id, const PtrVector &list)
Gets variable with the given id. When not found it returns the zero variable.
bool write(std::ostream &os) const
Writes id and current value to the stream.
int getSigDigits(bool converted) const
Gets the normalized decimal point location for this instance converted or not converted.
static std::string getFlagsString(flags_type flags)
Gets the passed flags in a std::string form.
static std::string getType(Value::EType type)
Gets type string of given enumerate value.
const Value & getStateValue(size_type state) const
Gets the value of the passed state index.
id_type getDesiredId() const
Gets the desired id of this instance.
static PtrVector getList()
Retrieves a list of instances available (global + exported). Useful in populating a selection dialog.
void setHandler(VariableHandler *handler)
Only one link is available at a time. Sets an event handler for this variable, passing NULL wil disab...
bool setup(const Definition &definition, id_type id_ofs=0)
Creates a variable using the definition structure.
Variable & getOwner() const
Gets a reference to the owner/server instance of this variable.
bool setConvert(bool enable)
Enables or disables conversion of floating point values. If a change was triggered a veConverted even...
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 ...
static bool read(std::istream &is, bool skip_self=false, PtrVector &list=null_ref< PtrVector >())
void clipRound(Value &value) const
Clips the passed value between min and max values.
void makeOwner()
Makes this instance owner of this variable instance and emits the appropriate events....
Variable(const Variable &v)
Copy constructor. Copies also the Desired ID data member.
const Value & getRnd() const
Gets the variable Rounding value. Converted when converted flag is true.
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 refere...
bool isExported() const
Checks if the variable is an exported local variable.
static flags_type toFlags(const std::string &flags)
Converts a std::string with flag characters to an integer.
const Value & getDef(bool converted) const
Gets the default value converted or not Is converted independent of the conversion flag.
static const Variable & getInstanceById(id_type id)
Gets variable with the given id. When not found it returns the zero variable.
void setDesiredId(id_type id)
Sets the desired id member variable to the passed id. If the passed 'id' is zero the automatic attach...
bool isTemporaryDifferent() const
Check if the temporary value differs from the actual value. Used mainly in dialogs to enable an apply...
void setDesiredId()
Sets the desired id member variable to the current attached reference id.
bool isConverted() const
Checks if the current instance is converting floating point values.
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....
bool isTemporary() const
Checks if a temporary is used instead of current actual value.
static size_type getInstanceCount(bool global_only=true)
Gets the total amount of variable instances in the system.
static void setConvertHandler(VariableHandler *handler)
Special handler for converting float variables globally. Sets an event handler for this variable,...
int getRequiredDigits() const
Gets the required digits for this instance based on round, min and max values. Converted or not the v...
bool isGlobal() const
Check if this instance is a global variable or not.
bool isValid() const
Checks validity of the attached reference and used after a setup call.
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....
Variable(bool global)
Creates global or local variable instance depending on the value passed.
const Value & getMin() const
Gets the variable Minimum value. Is converted when converted flag is true.
#define _GII_CLASS
Definition gii/global.h:38
#define _GII_FUNC
Definition gii/global.h:37
Definition Application.h:10
_GII_FUNC std::istream & operator>>(std::istream &is, ResultData &)
Stream operator for setting up this instance with a setup std::string.
_GII_FUNC std::ostream & operator<<(std::ostream &os, const ResultData &)
Stream operator for the setup std::string.
Definition VariableReference.h:13
Structure used to set up a variable The method Variable::getDefinition() transforms the definition st...
Definition VariableTypes.h:274