HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Value Class Referenceabstract

A generic, discriminated value, whose type may be queried dynamically. More...

#include <Value.h>

+ Inheritance diagram for Value:

Public Types

enum  FloatFormat { FloatFormatDefault = 0, FloatFormatFixed = 1, FloatFormatScientific = 2 }
 Float formats to use when converting values to strings. More...
 

Public Member Functions

 Value ()
 
virtual ~Value ()
 
virtual ValuePtr copy () const =0
 Create a deep copy of the value. More...
 

Static Public Member Functions

template<class T >
static ValuePtr createValue (const T &data)
 Create a new value from an object of any valid MaterialX type. More...
 
static ValuePtr createValue (const char *data)
 
static ValuePtr createValueFromStrings (const string &value, const string &type)
 

Data Accessors

using CreatorFunction = ValuePtr(*)(const string &)
 Return true if this value is of the given type. More...
 
using CreatorMap = std::unordered_map< string, CreatorFunction >
 Return true if this value is of the given type. More...
 
template<class T >
class ValueRegistry
 Return true if this value is of the given type. More...
 
template<class T >
bool isA () const
 Return true if this value is of the given type. More...
 
template<class T >
const TasA () const
 
virtual const stringgetTypeString () const =0
 Return the type string for this value. More...
 
virtual string getValueString () const =0
 Return the value string for this value. More...
 
static void setFloatFormat (FloatFormat format)
 
static void setFloatPrecision (int precision)
 Set float precision for converting values to strings. More...
 
static FloatFormat getFloatFormat ()
 Return the current float format. More...
 
static int getFloatPrecision ()
 Return the current float precision. More...
 

Detailed Description

A generic, discriminated value, whose type may be queried dynamically.

Definition at line 44 of file Value.h.

Member Typedef Documentation

using Value::CreatorFunction = ValuePtr (*)(const string&)
protected

Return true if this value is of the given type.

Definition at line 127 of file Value.h.

using Value::CreatorMap = std::unordered_map<string, CreatorFunction>
protected

Return true if this value is of the given type.

Definition at line 128 of file Value.h.

Member Enumeration Documentation

Float formats to use when converting values to strings.

Enumerator
FloatFormatDefault 
FloatFormatFixed 
FloatFormatScientific 

Definition at line 48 of file Value.h.

Constructor & Destructor Documentation

Value::Value ( )
inline

Definition at line 56 of file Value.h.

virtual Value::~Value ( )
inlinevirtual

Definition at line 59 of file Value.h.

Member Function Documentation

template<class T >
const T& Value::asA ( ) const

Return our underlying data as an object of the given type. If the given type doesn't match our own data type, then an exception is thrown.

virtual ValuePtr Value::copy ( ) const
pure virtual

Create a deep copy of the value.

Implemented in TypedValue< T >.

template<class T >
static ValuePtr Value::createValue ( const T data)
inlinestatic

Create a new value from an object of any valid MaterialX type.

Definition at line 62 of file Value.h.

static ValuePtr Value::createValue ( const char *  data)
inlinestatic

Definition at line 68 of file Value.h.

static ValuePtr Value::createValueFromStrings ( const string value,
const string type 
)
static

Create a new value instance from value and type strings.

Returns
A shared pointer to a typed value, or an empty shared pointer if the conversion to the given data type cannot be performed.
static FloatFormat Value::getFloatFormat ( )
inlinestatic

Return the current float format.

Definition at line 113 of file Value.h.

static int Value::getFloatPrecision ( )
inlinestatic

Return the current float precision.

Definition at line 119 of file Value.h.

virtual const string& Value::getTypeString ( ) const
pure virtual

Return the type string for this value.

Implemented in TypedValue< T >.

virtual string Value::getValueString ( ) const
pure virtual

Return the value string for this value.

Implemented in TypedValue< T >.

template<class T >
bool Value::isA ( ) const

Return true if this value is of the given type.

static void Value::setFloatFormat ( FloatFormat  format)
inlinestatic

Set float formatting for converting values to strings. Formats to use are FloatFormatFixed, FloatFormatScientific or FloatFormatDefault to set default format.

Definition at line 101 of file Value.h.

static void Value::setFloatPrecision ( int  precision)
inlinestatic

Set float precision for converting values to strings.

Definition at line 107 of file Value.h.

Friends And Related Function Documentation

template<class T >
friend class ValueRegistry
friend

Return true if this value is of the given type.

Definition at line 125 of file Value.h.


The documentation for this class was generated from the following file: