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;
102 static void setFloatFormat(FloatFormat
format);
105 static void setFloatPrecision(
int precision);
108 static FloatFormat getFloatFormat();
111 static int getFloatPrecision();
117 template <
class T>
friend class ValueRegistry;
120 using CreatorMap = std::unordered_map<string, CreatorFunction>;
143 return Value::createValue<T>(_data);
173 if (!other || !other->isA<
T>())
177 return _data == other->asA<
T>();
209 auto result = createAggregateValue(_typeName);
210 for (
const auto&
val : _data)
220 _data.emplace_back(valuePtr);
250 return std::make_shared<AggregateValue>(typeName);
256 const string _typeName;
258 vector<ConstValuePtr> _data;
vector< bool > BoolVec
A vector of booleans.
MX_CORE_API ValuePtr copy() const override
Create a deep copy of the value.
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.
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 MX_CORE_API const string TYPE
shared_ptr< const Value > ConstValuePtr
A shared pointer to a const Value.
virtual MX_CORE_API ~TypedValue()
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.
MX_CORE_API bool isEqual(ConstValuePtr other) const override
Return true if this value is of the given type.
MX_CORE_API const string & getTypeString() const override
Return type string.
MX_CORE_API TypedValue(const T &value)
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)
virtual bool isEqual(ConstValuePtr other) const =0
Return true if this value is of the given type.
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)
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.
MX_CORE_API 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.
MX_CORE_API string getValueString() const override
Return value string.
vector< int > IntVec
A vector of integers.
shared_ptr< Value > ValuePtr
A shared pointer to a Value.
FloatFormat
Float formats to use when converting values to strings.
static MX_CORE_API ValuePtr createFromString(const string &value)
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.
MX_CORE_API void setData(const TypedValue< T > &value)
Set stored data object.
virtual ~AggregateValue()
MX_CORE_API void setData(const T &value)
Set stored data object.