6 #ifndef MATERIALX_VALUE_H
7 #define MATERIALX_VALUE_H
50 FloatFormatDefault = 0,
52 FloatFormatScientific = 2
64 return std::make_shared<TypedValue<T>>(
data);
85 template <
class T>
bool isA()
const;
90 template <
class T>
const T& asA()
const;
96 virtual string getValueString()
const = 0;
121 return _floatPrecision;
125 template <
class T>
friend class ValueRegistry;
128 using CreatorMap = std::unordered_map<string, CreatorFunction>;
133 static int _floatPrecision;
153 return Value::createValue<T>(_data);
vector< bool > BoolVec
A vector of booleans.
std::unordered_map< string, CreatorFunction > CreatorMap
Return true if this value is of the given type.
#define MATERIALX_NAMESPACE_BEGIN
OIIO_UTIL_API bool copy(string_view from, string_view to, std::string &err)
virtual string getValueString() const =0
Return the value string for this value.
GLsizei const GLfloat * value
SYS_FORCE_INLINE bool isA(const InstancablePtr *o)
static FloatFormat getFloatFormat()
Return the current float format.
shared_ptr< const Value > ConstValuePtr
A shared pointer to a const Value.
MATERIALX_NAMESPACE_BEGIN MX_CORE_API const string EMPTY_STRING
static ValuePtr createValue(const char *data)
MX_CORE_API const string & getTypeString()
Return the type string associated with the given data type.
The class template for typed subclasses of Value.
void setData(const T &value)
Set stored data object.
static void setFloatFormat(FloatFormat format)
virtual const string & getTypeString() const =0
Return the type string for this value.
void setData(const TypedValue< T > &value)
Set stored data object.
A generic, discriminated value, whose type may be queried dynamically.
GLint GLint GLsizei GLint GLenum format
vector< float > FloatVec
A vector of floats.
MX_CORE_API T fromValueString(const string &value)
static int getFloatPrecision()
Return the current float precision.
GLenum GLint GLint * precision
MX_CORE_EXTERN_TEMPLATE(TypedValue< int >)
ValuePtr(*)(const string &) CreatorFunction
Return true if this value is of the given type.
Exception(const string &msg)
ValuePtr copy() const override
Create a deep copy of the value.
const T & getData() const
Return stored data object.
#define MATERIALX_NAMESPACE_END
static ValuePtr createValue(const T &data)
Create a new value from an object of any valid MaterialX type.
vector< int > IntVec
A vector of integers.
shared_ptr< Value > ValuePtr
A shared pointer to a Value.
static void setFloatPrecision(int precision)
Set float precision for converting values to strings.
TypedValue(const T &value)
FloatFormat
Float formats to use when converting values to strings.
MX_CORE_API string toValueString(const T &data)
Convert the given data value to a value string.