Public Member Functions

dsim_value Class Reference

Represents the value of a variable or message. More...

List of all members.

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_valueoperator= (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.

Detailed Description

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.


Constructor & Destructor Documentation

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

Parameters:
typeThe type of the value pointed to by ptr
ptrThe 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.

Parameters:
valueThe 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.

Parameters:
valueThe 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.

Parameters:
valueThe 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.

Parameters:
valueThe value to be stored

Member Function Documentation

double dsim_value::double_value (  ) const

Returns the value of this object, if it holds a double data value.

Returns:
The store value, if its type is sd_type_double. If not, returns 0.
int dsim_value::int_value (  ) const

Returns the value of this object, if it holds an integer data value.

Returns:
The store value, if its type is sd_type_int. If not, returns 0.
ml_matrix dsim_value::matrix_value (  ) const

Returns the value of this object, if it holds a matrix data value.

Returns:
The store value, if its type is sd_type_matrix. If not, returns an empty matrix.
void* dsim_value::raw_value (  ) const [inline]

Returns the raw pointer for the value stored in this object.

Returns:
The raw value pointer, or NULL if the object is not valid.
const char * dsim_value::string_value (  ) const

Returns the value of this object, if it holds a string data value.

Returns:
The store value, if its type is sd_type_string. If not, returns NULL.
int dsim_value::type (  ) const [inline]

Returns the value's data type.

Returns:
The data type of the value.
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.

Returns:
The _ptr
 All Classes Files Functions Typedefs Enumerations Enumerator