11 #ifndef __APEX_FLEXIBLEDICT_H__
12 #define __APEX_FLEXIBLEDICT_H__
57 static const bool clearNeedsDestruction =
true;
83 : myExternalBuffer(external)
90 mergeUtOptions(opt,
true);
94 : myExternalBuffer(other.myExternalBuffer)
95 , myDataId(other.myDataId)
103 myBuffer = UTmakeUnique<APEX_Buffer>();
113 myExternalBuffer = other.myExternalBuffer;
114 myDataId = other.myDataId;
116 if (myExternalBuffer)
124 myBuffer = UTmakeUnique<APEX_Buffer>();
134 myBuffer = UTmakeUnique<APEX_Buffer>();
135 myExternalBuffer =
nullptr;
136 mergeUtOptions(opt,
true);
141 return myMap.contains(key);
146 return myMap.empty();
158 template <
typename T>
161 auto it = myMap.find(key);
164 return castArg<T>(&it->second);
167 template <
typename T>
170 auto it = myMap.find(key);
173 return castArg<T>(&it->second);
180 if (
const Bool *
val = get<Bool>(key))
181 return UTmakeOptional<Bool>(*val);
182 else if (
const Int *val = get<Int>(key))
183 return UTmakeOptional<Bool>(*val != 0);
188 template <
typename T>
191 auto value = get<T>(key);
197 template <
typename T>
201 bool add_missing =
true,
202 bool allow_type_change =
false,
203 bool bump_data_id =
true)
205 if (!isValidKey(key))
208 msg.
format(
"set() called with invalid key {}", key);
213 auto it = myMap.find(key);
225 myMap[key] = appendTrackedArgument(type_defn);
233 if (!allow_type_change)
240 it->second = appendTrackedArgument(type_defn);
254 bool add_missing =
true,
255 bool allow_type_change =
false,
256 bool force_update =
false,
257 bool bump_data_id =
true,
258 bool bump_data_id_on_conversion =
true);
263 bool add_missing =
true,
264 bool allow_type_change =
false,
265 bool force_update =
false,
266 bool bump_data_id =
true,
267 bool bump_data_id_on_conversion =
true);
287 bool add_missing =
false,
288 bool allow_type_change =
false,
289 bool force_copy =
false,
291 bool bump_data_id_on_conversion =
true);
295 bool add_missing =
true,
296 bool allow_type_change =
true,
298 void updateUtOptions(
301 bool include_geometry =
false,
302 bool include_typeinfo =
true)
const;
303 void updateUtOptions(
306 bool include_geometry =
false,
307 bool include_typeinfo =
true)
const;
315 if (!myExternalBuffer)
334 int64 getMemoryUsage()
const;
337 template <
typename T>
338 void setReinterpretFloatArray(
343 static_assert(std::is_same_v<typename T::value_type, Float>);
346 set<ApexArray<T>>(name, tmp, add_missing,
false,
false);
349 APEX_TrackedArgument appendTrackedArgument(
const APEX_TypeDefinitionBase *type_defn)
351 APEX_Argument
arg =
buffer()->append(type_defn);
352 return {{arg.buffer, arg.type_defn, arg.offset}, };
357 APEX_Buffer *myExternalBuffer =
nullptr;
377 const ApexArray<Dict> &
v);
379 template <
typename T>
380 static std::type_index
383 return std::type_index(
typeid(T));
390 const APEX_Argument &
arg,
391 bool include_geometry =
false,
392 bool include_typeinfo =
true);
396 #endif // header guard
GLenum GLuint GLsizei bufsize
static APEX_DataID nextDataId()
Get a new unique data ID.
APEX_ParmDict(APEX_Buffer *external)
APEX_ParmDict & operator=(const APEX_ParmDict &other)
GLsizei const GLfloat * value
APEX_ParmDict(const APEX_ParmDict &other)
size_t UTformatBuffer(char *buffer, size_t bufsize, const ApexArray< T > &v)
SYS_FORCE_INLINE const char * buffer() const
void setUtOption(UT_Options &opt, const UT_StringRef &key, const APEX_Argument &arg, bool include_geometry=false, bool include_typeinfo=true)
bool contains(const UT_StringRef &key) const
auto arg(const Char *name, const T &arg) -> detail::named_arg< Char, T >
Holds all of the memory for execution state of a compiled APEX graph.
std::optional< T > UT_Optional
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
void operator=(const UT_OptionsHolder &opt)
#define UT_ASSERT_MSG(ZZ,...)
const UT_ArrayStringMap< APEX_TrackedArgument > & map() const
APEX_COWHandle< APEX_ParmDict > Dict
static void clear(apex::APEX_TrackedArgument &v)
APEX_DataID dataId() const
static void clearConstruct(apex::APEX_TrackedArgument *p)
constexpr auto set(type rhs) -> int
const APEX_TypeDefinitionBase * type_defn
UT_ArrayStringMap< APEX_TrackedArgument > & map()
GLuint const GLchar * name
UT_UniquePtr< T > UTmakeUnique(REST &&...args)
A map of string to various well defined value types.
size_t format(const char *fmt, const Args &...args)
void copyDataId(const APEX_ParmDict &other)
void set(const UT_StringRef &key, const T &value, bool add_missing=true, bool allow_type_change=false, bool bump_data_id=true)
T getValueOr(const UT_StringRef &key, T defValue) const
APEX_ParmDict(const UT_OptionsHolder &opt)
const UT_Optional< Bool > getBoolOrInt(const UT_StringRef &key) const
Helper function to extract a boolean value from either an int or bool dict value. ...
Represents a location for a single object inside of an APEX_Buffer.
static bool isClear(const apex::APEX_TrackedArgument &v)
APEX_API size_t UTformatBuffer< Dict >(char *buffer, size_t bufsize, const ApexArray< Dict > &v)