    

 ## On this page

  

 

 # ValueTypeEnum Class Reference

 Last update: 16.07.2025 

Identifies a set of values as an enumration of strings type and an associated set of optional attributes (for instance minimum and maximum value). It provides conversion routines between floating point and string representation. [More...](class_value_type_enum.xhtml#details)

## <a name="pub-types"></a>Public Types

<a id="a12f8ec8f0e7a4584b9fe481bb53fa60e"></a>enum [eType](class_value_type.xhtml#a12f8ec8f0e7a4584b9fe481bb53fa60e) { **DOUBLE** = 1, **INT** = 2, **BOOL** = 3, **ENUM** = 4 } Enumeration of all available value types. Returned by [type()](class_value_type.xhtml#a04b0a9497332985d1c7386b487924e85 "Get the Type of this ValueType. ") method. Used to identify from which derived class the shared base class [ValueType](class_value_type.xhtml "Represents a type of value and a set of properties. ValueType is intended to be associated with a set...") object has been created.   
 ## <a name="pub-methods"></a>Public Member Functions

string [\_\_str\_\_](class_value_type.xhtml#a44139caf93a3463ea4f2a6671cdce842) () Function to allow printing instances of this class in python. [More...](#a44139caf93a3463ea4f2a6671cdce842)  
 number [attribute](class_value_type.xhtml#a4fe78fe23647b841774a467f7115e242) (string attribute) Returns the value of the given attribute. An attribute is a named value, to specify the behavior of the [ValueType](class_value_type.xhtml "Represents a type of value and a set of properties. ValueType is intended to be associated with a set..."). For instance min/max. See [ValueType](class_value_type.xhtml "Represents a type of value and a set of properties. ValueType is intended to be associated with a set...") derived classes for documentation of available attributes. [More...](#a4fe78fe23647b841774a467f7115e242)  
 number [attribute](class_value_type.xhtml#a945190dbb867b410997fa2d77a1a629f) (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](class_value_type.xhtml "Represents a type of value and a set of properties. ValueType is intended to be associated with a set..."). For instance min/max. See [ValueType](class_value_type.xhtml "Represents a type of value and a set of properties. ValueType is intended to be associated with a set...") derived classes for documentation of available attributes. [More...](#a945190dbb867b410997fa2d77a1a629f)  
 <a id="abc6417bd7b50620ce73098bd5859540d"></a>bool [attributeExists](class_value_type.xhtml#abc6417bd7b50620ce73098bd5859540d) (string [attribute](class_value_type.xhtml#a4fe78fe23647b841774a467f7115e242)) Check whether an attribute is defined.   
 <a id="a166e44f3030115668a91a35ffb81ff11"></a>string [description](class_value_type.xhtml#a166e44f3030115668a91a35ffb81ff11) () Get the description of this [ValueType](class_value_type.xhtml "Represents a type of value and a set of properties. ValueType is intended to be associated with a set...").   
 bool [eraseAttribute](class_value_type.xhtml#a39693bcee84d3daf689384219bd7e89c) (string [attribute](class_value_type.xhtml#a4fe78fe23647b841774a467f7115e242)) Removes an attribute. [More...](#a39693bcee84d3daf689384219bd7e89c)  
 <a id="aa62b508d2c0e7d9cec12924965276eb5"></a>string [name](class_value_type.xhtml#aa62b508d2c0e7d9cec12924965276eb5) () Get the unique name of this [ValueType](class_value_type.xhtml "Represents a type of value and a set of properties. ValueType is intended to be associated with a set...").   
 <a id="a7fe700521405d7e9ecb39f9c20eb2589"></a>bool [operator!=](class_value_type.xhtml#a7fe700521405d7e9ecb39f9c20eb2589) ([ValueType](class_value_type.xhtml) b) Returns false if both types have equal name, value type, attributes and description.   
 <a id="a99b4ecb5a908b5fb78fddad314091737"></a>bool [operator==](class_value_type.xhtml#a99b4ecb5a908b5fb78fddad314091737) ([ValueType](class_value_type.xhtml) b) Returns true if both types have equal name, value type, attributes and description.   
 <a id="a3355fe903707accf684bf8ca5dd30f34"></a>bool [operator&gt;](class_value_type.xhtml#a3355fe903707accf684bf8ca5dd30f34) ([ValueType](class_value_type.xhtml) b) Sort by name.   
  [setAttribute](class_value_type.xhtml#a8bdd98028a4fcad8345fb72becb3c0d4) (string [attribute](class_value_type.xhtml#a4fe78fe23647b841774a467f7115e242), number value) Define an attribute. Existing attributes are overwritten. [More...](#a8bdd98028a4fcad8345fb72becb3c0d4)  
 number [toDouble](class_value_type_enum.xhtml#a3feb53908f4c019f35111daf04a190b8) (string str) override Convert string to floating point value Enumeration \["glass", "wood", "concrete"\]: "glass" -&gt; 0.0 "wood" -&gt; 1.0 "concrete" -&gt; 2.0. [More...](#a3feb53908f4c019f35111daf04a190b8)  
 string [toString](class_value_type_enum.xhtml#afe98eed581fb1712f5b265fcce59dfda) (number value) override Convert number value to its string representation Enumeration \["glass", "wood", "concrete"\]: 0.0 -&gt; "glass" -&gt; 0.0 1.0 -&gt; "wood" 2.0 -&gt; "concrete" Always returns "glass" if value &lt;= 0 Always returns "concrete" if value &gt;= 2 Value is floored ( 0.6 -&gt; "glass"). [More...](#afe98eed581fb1712f5b265fcce59dfda)  
 <a id="a04b0a9497332985d1c7386b487924e85"></a>[eType](class_value_type.xhtml#a12f8ec8f0e7a4584b9fe481bb53fa60e) [type](class_value_type.xhtml#a04b0a9497332985d1c7386b487924e85) () Get the Type of this [ValueType](class_value_type.xhtml "Represents a type of value and a set of properties. ValueType is intended to be associated with a set...").   
 ## <a name="pub-static-methods"></a>Static Public Member Functions

static std::shared\_ptr&lt; [ValueType](class_value_type.xhtml) &gt; [create](class_value_type_enum.xhtml#a5759d5b685b07907b22bba0d257f1488) ([ValueTypeManager](class_value_type_manager.xhtml) manager, string [name](class_value_type.xhtml#aa62b508d2c0e7d9cec12924965276eb5), std::vector&lt; string &gt; strings, string [description](class_value_type.xhtml#a166e44f3030115668a91a35ffb81ff11)="Enumeration of strings type.") Default destructor. [More...](#a5759d5b685b07907b22bba0d257f1488)  
 <a id="details" name="details"></a>## Detailed Description

Identifies a set of values as an enumration of strings type 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](class_value_type_manager.xhtml "Keeps track of all unique ValueTypes. Required to create new ValueType shared resource instances...") for [Script](group__script.xhtml "Define custom scripts ("macros"). Build macro-based custom solvers and export (FMU/SDB). ") example usage. NoteConstructor is private, use the [create()](class_value_type_enum.xhtml#a5759d5b685b07907b22bba0d257f1488 "Default destructor. ") method to create new instances as a shared resource.class [ValueTypeEnum](class_value_type_enum.xhtml "Identifies a set of values as an enumration of strings type and an associated set of optional attribu...") : public [ValueType](class_value_type.xhtml "Represents a type of value and a set of properties. ValueType is intended to be associated with a set...")

## Member Function Documentation

<a id="a44139caf93a3463ea4f2a6671cdce842"></a>## [◆ ](#a44139caf93a3463ea4f2a6671cdce842)\_\_str\_\_()

 string \_\_str\_\_  ( )   inherited 

Function to allow printing instances of this class in python.

ReturnsThe unique name of this [ValueType](class_value_type.xhtml "Represents a type of value and a set of properties. ValueType is intended to be associated with a set...") 



<a id="a4fe78fe23647b841774a467f7115e242"></a>## [◆ ](#a4fe78fe23647b841774a467f7115e242)attribute() \[1/2\]

 number attribute  ( string  *attribute*)   inherited 

Returns the value of the given attribute. An attribute is a named value, to specify the behavior of the [ValueType](class_value_type.xhtml "Represents a type of value and a set of properties. ValueType is intended to be associated with a set..."). For instance min/max. See [ValueType](class_value_type.xhtml "Represents a type of value and a set of properties. ValueType is intended to be associated with a set...") derived classes for documentation of available attributes.

Parameters attributeAttribute to search for Exceptions Ifattribute is undefined 



<a id="a945190dbb867b410997fa2d77a1a629f"></a>## [◆ ](#a945190dbb867b410997fa2d77a1a629f)attribute() \[2/2\]

 number attribute  ( string  *attribute*,    number  *default\_value*   )   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](class_value_type.xhtml "Represents a type of value and a set of properties. ValueType is intended to be associated with a set..."). For instance min/max. See [ValueType](class_value_type.xhtml "Represents a type of value and a set of properties. ValueType is intended to be associated with a set...") derived classes for documentation of available attributes.

Parameters attributeAttribute to search for. default\_valueValue returned if attribute is undefined. 



<a id="a5759d5b685b07907b22bba0d257f1488"></a>## [◆ ](#a5759d5b685b07907b22bba0d257f1488)create()

 static std::shared\_ptr&lt;[ValueType](class_value_type.xhtml)&gt; create  ( [ValueTypeManager](class_value_type_manager.xhtml)  *manager*,    string  *name*,    std::vector&lt; string &gt;  *strings*,    string  *description* = `"Enumeration of strings type."`   )   static 

Default destructor.

Create a new instances as a shared resources, which is stored at the [ValueTypeManager](class_value_type_manager.xhtml "Keeps track of all unique ValueTypes. Required to create new ValueType shared resource instances..."). Static method, access in script: value\_type = sos.ValueTypeDouble.create(manager, \["glass", "wood", "concrete"\], "my\_number\_value\_type") Sets the "min" attribute to 0 Sets the "max" attribute to (number of unique strings - 1)

Parameters manager[ValueTypeManager](class_value_type_manager.xhtml "Keeps track of all unique ValueTypes. Required to create new ValueType shared resource instances...") where the shared resource is stored at. nameUnique name of this [ValueType](class_value_type.xhtml "Represents a type of value and a set of properties. ValueType is intended to be associated with a set..."). stringsVector of strings the enumeration type consists of. Duplicate strings are omitted. The order of strings remains unchanged. description\[optional\] Short description string of this [ValueType](class_value_type.xhtml "Represents a type of value and a set of properties. ValueType is intended to be associated with a set...") attributes\[optional\] Map of named number precision attributes ReturnsShared resource of [ValueType](class_value_type.xhtml "Represents a type of value and a set of properties. ValueType is intended to be associated with a set...") base class. 



<a id="a39693bcee84d3daf689384219bd7e89c"></a>## [◆ ](#a39693bcee84d3daf689384219bd7e89c)eraseAttribute()

 bool eraseAttribute  ( string  *attribute*)   inherited 

Removes an attribute.

Parameters attributeThe attribute to remove ReturnsTrue if the attribute was removed. False if the attribute was undefined. 



<a id="a8bdd98028a4fcad8345fb72becb3c0d4"></a>## [◆ ](#a8bdd98028a4fcad8345fb72becb3c0d4)setAttribute()

 setAttribute  ( string  *attribute*,    number  *value*   )   inherited 

Define an attribute. Existing attributes are overwritten.

Parameters attributeName of the attribute. valueValue of the attribute. 



<a id="a3feb53908f4c019f35111daf04a190b8"></a>## [◆ ](#a3feb53908f4c019f35111daf04a190b8)toDouble()

 number toDouble  ( string  *str*)   overridevirtual 

Convert string to floating point value Enumeration \["glass", "wood", "concrete"\]: "glass" -&gt; 0.0 "wood" -&gt; 1.0 "concrete" -&gt; 2.0.

Parameters strThe string to convert ReturnsThe converted value Exceptions ifthe string is not part of this enumeration type. Implements [ValueType](class_value_type.xhtml#a0f53106b13e55a9126710549e5d91fd0).





<a id="afe98eed581fb1712f5b265fcce59dfda"></a>## [◆ ](#afe98eed581fb1712f5b265fcce59dfda)toString()

 string toString  ( number  *value*)   overridevirtual 

Convert number value to its string representation Enumeration \["glass", "wood", "concrete"\]: 0.0 -&gt; "glass" -&gt; 0.0 1.0 -&gt; "wood" 2.0 -&gt; "concrete" Always returns "glass" if value &lt;= 0 Always returns "concrete" if value &gt;= 2 Value is floored ( 0.6 -&gt; "glass").

Parameters valuethe number value to convert ReturnsThe string representation of the converted value Implements [ValueType](class_value_type.xhtml#ac64491e7d149ef1fdb6bc14df52a27d1).