Represents the value of a variable or message. More...
Public Member Functions | |
dsim_value () | |
Default constructor, producing an invalid value. | |
dsim_value (const dsim_value &base) | |
Copy constructor. | |
dsim_value (int type, void *ptr) | |
Generic data constructor. | |
dsim_value (int value) | |
Integer value constructor. | |
dsim_value (double value) | |
Double value constructor. | |
dsim_value (const ml_matrix &value) | |
Matrix value constructor. | |
dsim_value (const char *value) | |
String value constructor. | |
dsim_value & | operator= (const dsim_value &base) |
Assignment operator. | |
bool | valid () const |
Tests to see whether or not the value is valid. | |
int | type () const |
Returns the value's data type. | |
void * | raw_value () const |
Returns the raw pointer for the value stored in this object. | |
int | int_value () const |
Returns the value of this object, if it holds an integer data value. | |
double | double_value () const |
Returns the value of this object, if it holds a double data value. | |
ml_matrix | matrix_value () const |
Returns the value of this object, if it holds a matrix data value. | |
const char * | string_value () const |
Returns the value of this object, if it holds a string data value. |
Represents the value of a variable or message.
A dsim_value object is a generic wrapper for dealing with any of the data types that can be stored in variables or sent via messages. Each object has associated with it a data type and a value of that type.
A dsim_value object may or may not have "captured" the value provided to it any time. If the value has not been captured, then the original pointer provided to the value must remain valid until the value is no longer needed. See capture() and is_captured() for more information.
Like variables, a dsim_value may or may not be valid. Values created with the default constructor are not valid until a valid value has been assigned to them. You can (and should) check to see if a value is valid before using it with the valid() function.
dsim_value::dsim_value | ( | ) |
Default constructor, producing an invalid value.
A dsim_value constructed with the default construct begins in the invalid state, and can only be made valid by having a valid value assigned to it.
dsim_value::dsim_value | ( | int | type, |
void * | ptr | ||
) |
Generic data constructor.
Constructs a new value with a specified type and from a pointer to the value to be encapsulated
type | The type of the value pointed to by ptr |
ptr | The value to be stored. |
dsim_value::dsim_value | ( | int | value ) |
Integer value constructor.
Constructs a new value with type sd_type_int and the provided value.
value | The value to be stored |
dsim_value::dsim_value | ( | double | value ) |
Double value constructor.
Constructs a new value with type sd_type_double and the provided value.
value | The value to be stored |
dsim_value::dsim_value | ( | const ml_matrix & | value ) |
Matrix value constructor.
Constructs a new value with type sd_type_matrix and the provided value.
value | The value to be stored |
dsim_value::dsim_value | ( | const char * | value ) |
String value constructor.
Constructs a new value with type sd_type_string and the provided value.
value | The value to be stored |
double dsim_value::double_value | ( | ) | const |
Returns the value of this object, if it holds a double data value.
int dsim_value::int_value | ( | ) | const |
Returns the value of this object, if it holds an integer data value.
ml_matrix dsim_value::matrix_value | ( | ) | const |
Returns the value of this object, if it holds a matrix data value.
void* dsim_value::raw_value | ( | ) | const [inline] |
Returns the raw pointer for the value stored in this object.
const char * dsim_value::string_value | ( | ) | const |
Returns the value of this object, if it holds a string data value.
int dsim_value::type | ( | ) | const [inline] |
Returns the value's data type.
bool dsim_value::valid | ( | ) | const |
Tests to see whether or not the value is valid.
As values can be invalid, all values should be checked for validity before being used. Some functions return invalid values to indicate error conditions.