ValueTypeInt Class Reference
Last update: 16.07.2025Identifies a set of values as integer values and an associated set of optional attributes (for instance minimum and maximum value). It provides conversion routines between floating point and string representation. More...
Public Types | |
| enum | eType { DOUBLE = 1, INT = 2, BOOL = 3, ENUM = 4 } |
| Enumeration of all available value types. Returned by type() method. Used to identify from which derived class the shared base class ValueType object has been created. | |
Public Member Functions | |
| string | __str__ () |
| Function to allow printing instances of this class in python. More... | |
| number | attribute (string attribute) |
| Returns the value of the given attribute. An attribute is a named value, to specify the behavior of the ValueType. For instance min/max. See ValueType derived classes for documentation of available attributes. More... | |
| number | attribute (string attribute, number default_value) |
| Returns the value of the given attribute. Default value is returned if the attribute is undefined. An attribute is a named value, to specify the behavior of the ValueType. For instance min/max. See ValueType derived classes for documentation of available attributes. More... | |
| bool | attributeExists (string attribute) |
| Check whether an attribute is defined. | |
| string | description () |
| Get the description of this ValueType. | |
| bool | eraseAttribute (string attribute) |
| Removes an attribute. More... | |
| string | name () |
| Get the unique name of this ValueType. | |
| bool | operator!= (ValueType b) |
| Returns false if both types have equal name, value type, attributes and description. | |
| bool | operator== (ValueType b) |
| Returns true if both types have equal name, value type, attributes and description. | |
| bool | operator> (ValueType b) |
| Sort by name. | |
| setAttribute (string attribute, number value) | |
| Define an attribute. Existing attributes are overwritten. More... | |
| number | toDouble (string str) override |
| Convert string to floating point value. More... | |
| string | toString (number value) override |
| Convert number value to its string representation Double value is casted to integer before conversion to string. 1.6 -> "1". More... | |
| eType | type () |
| Get the Type of this ValueType. | |
Static Public Member Functions | |
| static std::shared_ptr< ValueType > | create (ValueTypeManager manager, string name, string description="Integer type.", std::map< string, number > attributes={}) |
| Default destructor. More... | |
Detailed Description
Identifies a set of values as integer values and an associated set of optional attributes (for instance minimum and maximum value). It provides conversion routines between floating point and string representation.
- See also
- ValueTypeManager for Script example usage.
- Note
- Constructor is private, use the create() method to create new instances as a shared resource.
Member Function Documentation
◆ __str__()
|
inherited |
Function to allow printing instances of this class in python.
- Returns
- The unique name of this ValueType
◆ attribute() [1/2]
|
inherited |
◆ attribute() [2/2]
|
inherited |
Returns the value of the given attribute. Default value is returned if the attribute is undefined. An attribute is a named value, to specify the behavior of the ValueType. For instance min/max. See ValueType derived classes for documentation of available attributes.
- Parameters
-
attribute Attribute to search for. default_value Value returned if attribute is undefined.
◆ create()
|
static |
Default destructor.
Create a new instances as a shared resources, which is stored at the ValueTypeManager. Static method, access in script: value_type = sos.ValueTypeInt.create(manager, "my_int_value_type")
- Parameters
-
manager ValueTypeManager where the shared resource is stored at. name Unique name of this ValueType. description [optional] Short description string of this ValueType attributes [optional] Map of named number precision attributes
- Returns
- Shared resource of ValueType base class.
◆ eraseAttribute()
|
inherited |
Removes an attribute.
- Parameters
-
attribute The attribute to remove
- Returns
- True if the attribute was removed. False if the attribute was undefined.
◆ setAttribute()
|
inherited |
Define an attribute. Existing attributes are overwritten.
- Parameters
-
attribute Name of the attribute. value Value of the attribute.
◆ toDouble()
|
overridevirtual |
Convert string to floating point value.
- Parameters
-
str The string to convert
- Returns
- The converted value
- Exceptions
-
if conversion to number fails
Implements ValueType.
◆ toString()
|
overridevirtual |
Convert number value to its string representation Double value is casted to integer before conversion to string. 1.6 -> "1".
- Parameters
-
value the number value to convert
- Returns
- The string representation of the converted value
Implements ValueType.