6 #ifndef MATERIALX_VALUE_H
7 #define MATERIALX_VALUE_H
51 FloatFormatDefault = 0,
53 FloatFormatScientific = 2
65 return std::make_shared<TypedValue<T>>(
data);
86 template <
class T>
bool isA()
const;
91 template <
class T>
const T& asA()
const;
97 virtual string getValueString()
const = 0;
122 return _floatPrecision;
126 template <
class T>
friend class ValueRegistry;
129 using CreatorMap = std::unordered_map<string, CreatorFunction>;
134 static int _floatPrecision;
154 return Value::createValue<T>(_data);
210 auto result = createAggregateValue(_typeName);
211 for (
const auto&
val : _data)
221 _data.emplace_back(valuePtr);
248 return std::make_shared<AggregateValue>(typeName);
254 const string _typeName;
256 vector<ConstValuePtr> _data;
vector< bool > BoolVec
A vector of booleans.
shared_ptr< const TypeDef > ConstTypeDefPtr
A shared pointer to a const TypeDef.
std::unordered_map< string, CreatorFunction > CreatorMap
Return true if this value is of the given type.
ValuePtr copy() const override
Create a deep copy of the value.
const vector< ConstValuePtr > & getMembers() const
#define MATERIALX_NAMESPACE_BEGIN
vector< string > StringVec
A vector of strings.
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)
**But if you need a result
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.
GLint GLint GLsizei GLint GLenum GLenum type
A generic, discriminated value, whose type may be queried dynamically.
shared_ptr< AggregateValue > AggregateValuePtr
A shared pointer to an Aggregate Value.
static AggregateValuePtr createAggregateValue(const string &typeName)
Create a new value from an object of any valid MaterialX type.
AggregateValue(const string &typeName)
void appendValue(ConstValuePtr valuePtr)
Append a member value to the aggregate.
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.
ConstValuePtr getMemberValue(size_t index) const
Query an indexed member value from the aggregate.
ValuePtr copy() const override
Create a deep copy of the value.
const T & getData() const
Return stored data object.
MX_CORE_API StringVec parseStructValueString(const string &value)
const string & getTypeString() const override
Return type string.
shared_ptr< const AggregateValue > ConstAggregateValuePtr
A shared pointer to a const Aggregate Value.
#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.
A subclass for aggregate values with multiple members.
MX_CORE_API string toValueString(const T &data)
Convert the given data value to a value string.
virtual ~AggregateValue()