24 #ifndef PXR_USD_SDF_ABSTRACT_DATA_H
25 #define PXR_USD_SDF_ABSTRACT_DATA_H
28 #include "pxr/usd/sdf/path.h"
31 #include "pxr/base/vt/value.h"
40 #include <type_traits>
42 PXR_NAMESPACE_OPEN_SCOPE
50 #define SDF_DATA_TOKENS \
51 ((TimeSamples, "timeSamples"))
85 virtual void CopyFrom(
const SdfAbstractDataConstPtr& source);
112 virtual bool Equals(
const SdfAbstractDataRefPtr &rhs)
const;
171 VtValue *value = NULL)
const = 0;
207 const TfToken& fieldName)
const = 0;
218 virtual std::type_info
const &
243 virtual std::vector<TfToken>
List(
const SdfPath& path)
const = 0;
249 const T& defaultValue = T())
const;
263 virtual bool HasDictKey(
const SdfPath& path,
268 virtual bool HasDictKey(
const SdfPath& path,
285 virtual void SetDictValueByKey(
const SdfPath& path,
290 virtual void SetDictValueByKey(
const SdfPath& path,
299 virtual void EraseDictValueByKey(
const SdfPath& path,
307 virtual std::vector<TfToken> ListDictKeys(
const SdfPath& path,
326 virtual std::set<double>
327 ListAllTimeSamples()
const = 0;
330 virtual std::set<double>
331 ListTimeSamplesForPath(
const SdfPath& path)
const = 0;
335 GetBracketingTimeSamples(
double time,
double* tLower,
double* tUpper)
const = 0;
339 GetNumTimeSamplesForPath(
const SdfPath& path)
const = 0;
343 GetBracketingTimeSamplesForPath(
const SdfPath& path,
345 double* tLower,
double* tUpper)
const = 0;
349 QueryTimeSample(
const SdfPath& path,
double time,
350 VtValue *optionalValue = NULL)
const = 0;
353 QueryTimeSample(
const SdfPath& path,
double time,
358 SetTimeSample(
const SdfPath& path,
double time,
363 EraseTimeSample(
const SdfPath& path,
double time) = 0;
380 const TfToken& field,
const T& defaultVal)
const
397 virtual bool StoreValue(
const VtValue& value) = 0;
400 bool StoreValue(
const T& v)
403 *
static_cast<T*
>(value) = v;
417 const std::type_info& valueType;
424 , valueType(valueType_)
425 , isValueBlock(
false)
426 , typeMismatch(
false)
451 virtual bool StoreValue(
const VtValue& v)
455 if (std::is_same<T, SdfValueBlock>::value) {
480 virtual bool GetValue(
VtValue* value)
const = 0;
482 template <
class T>
bool GetValue(T* v)
const
485 *v = *
static_cast<const T*
>(value);
491 virtual bool IsEqual(
const VtValue& value)
const = 0;
494 const std::type_info& valueType;
498 const std::type_info& valueType_)
500 , valueType(valueType_)
526 virtual bool GetValue(
VtValue* v)
const
532 virtual bool IsEqual(
const VtValue& v)
const
538 const T& _GetValue()
const
540 return *
static_cast<const T*
>(value);
551 typedef char CharArray[N];
585 PXR_NAMESPACE_CLOSE_SCOPE
587 #endif // PXR_USD_SDF_ABSTRACT_DATA_H
virtual SDF_API void EraseSpec(const SdfPath &path)=0
Erase the spec at path and any fields that are on it.
virtual SDF_API void Done(const SdfAbstractData &data)=0
SdfAbstractData::VisitSpecs will call this after visitation is complete, even if some VisitSpec() ret...
T const & UncheckedGet() const
Returns a const reference to the held object if the held object is of type T.
Standard pointer typedefs.
Base class for objects used to visit specs in an SdfAbstractData object.
A type-erased container for a const field value in an SdfAbstractData.
The fully-typed container for a field value in an SdfAbstractData.
A type-erased container for a field value in an SdfAbstractData.
virtual SDF_API std::type_info const & GetTypeid(const SdfPath &path, const TfToken &fieldName) const
Return the type of the value for fieldName on spec path.
T GetAs(const SdfPath &path, const TfToken &fieldName, const T &defaultValue=T()) const
Return the value for the given path and fieldName.
bool IsHolding() const
Return true if this value is holding an object of type T, false otherwise.
SDF_API void VisitSpecs(SdfAbstractDataSpecVisitor *visitor) const
Visits every spec in this SdfAbstractData object with the given visitor.
A special value type that can be used to explicitly author an opinion for an attribute's default valu...
#define TF_DECLARE_WEAK_AND_REF_PTRS(type)
Define standard weak, ref, and vector pointer types.
virtual SDF_API bool HasSpec(const SdfPath &path) const =0
Return true if this data has a spec for path.
Enable a concrete base class for use with TfRefPtr.
virtual SDF_API void CreateSpec(const SdfPath &path, SdfSpecType specType)=0
Create a new spec at path with the given specType.
virtual SDF_API bool VisitSpec(const SdfAbstractData &data, const SdfPath &path)=0
SdfAbstractData::VisitSpecs calls this function for every entry it contains, passing itself as data a...
Token for efficient comparison, assignment, and hashing of known strings.
virtual SDF_API void CopyFrom(const SdfAbstractDataConstPtr &source)
Copy the data in source into this data object.
virtual SdfSpecType GetSpecType(const SdfPath &path) const =0
Return the spec type for the spec at path.
virtual SDF_API void WriteToStream(std::ostream &out) const
Writes the contents of this data object to out.
#define TF_DECLARE_PUBLIC_TOKENS(...)
Macro to define public tokens.
The fully-typed container for a field value in an SdfAbstractData.
virtual SDF_API bool Equals(const SdfAbstractDataRefPtr &rhs) const
Returns true if this data object contains the same specs and fields as lhs, false otherwise...
A path value used to locate objects in layers or scenegraphs.
virtual SDF_API VtValue Get(const SdfPath &path, const TfToken &fieldName) const =0
Return the value for the given path and fieldName.
virtual SDF_API bool HasSpecAndField(const SdfPath &path, const TfToken &fieldName, SdfAbstractDataValue *value, SdfSpecType *specType) const
Fill specType (which cannot be nullptr) as if by a call to GetSpecType(path).
This file defines some macros that are useful for declaring and using static TfTokens.
SdfSpecType
An enum that specifies the type of an object.
virtual SDF_API bool Has(const SdfPath &path, const TfToken &fieldName, SdfAbstractDataValue *value) const =0
Returns whether a value exists for the given path and fieldName.
virtual SDF_API void MoveSpec(const SdfPath &oldPath, const SdfPath &newPath)=0
Move the spec at oldPath to newPath, including all the fields that are on it.
virtual SDF_API void _VisitSpecs(SdfAbstractDataSpecVisitor *visitor) const =0
Visits every spec in this SdfAbstractData object with the given visitor.
virtual SDF_API void Set(const SdfPath &path, const TfToken &fieldName, const VtValue &value)=0
Set the value of the given path and fieldName.
virtual SDF_API bool StreamsData() const =0
Returns true if this data object streams its data to and from its serialized data store on demand...
virtual SDF_API void Erase(const SdfPath &path, const TfToken &fieldName)=0
Remove the field at path and fieldName, if one exists.
virtual SDF_API bool IsEmpty() const
Returns true if this data object has no specs, false otherwise.
Enable a concrete base class for use with TfWeakPtr.
virtual SDF_API std::vector< TfToken > List(const SdfPath &path) const =0
Return the names of all the fields that are set at path.
Provides a container which may hold any type, and provides introspection and iteration over array typ...
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...
Interface for scene description data storage.
bool TfSafeTypeCompare(const std::type_info &t1, const std::type_info &t2)
Safely compare std::type_info structures.