omni::spectree::v1::ISpecNode

Defined in live/include/omni_spectree/Interfaces.h

class ISpecNode

SpecNode is a non-copyable representation of a node in the tree hierarchy that maintains a consistent link to the data regardless of tree placement or removal from the tree.

Public Types

using FieldConditional_t = std::pair<ISpecField*, bool>

Public Functions

ISpecNode() = default
virtual ~ISpecNode() = default
ISpecNode(const ISpecNode &other) = delete
ISpecNode(ISpecNode &&other) = delete
ISpecNode &operator=(const ISpecNode &other) = delete
ISpecNode &operator=(ISpecNode &&other) = delete
virtual FieldConditional_t EmplaceField(const PXR_NS::TfToken &fieldName) const = 0

Inserts a new field into the spec if there is no element with the fieldName in the spec.

Parameters

fieldName – The field key token. eg. SdfFieldKeys->Default.

Returns

Returns a pair consisting of pointer to the inserted field, or the already-existing field if no insertion happened, and a bool denoting whether the insertion took place (true if insertion happened, false if it did not).

virtual size_t EraseField(const PXR_NS::TfToken &fieldName) const = 0

Removes the field (if one exists) with the key equivalent to fieldName.

Parameters

fieldName – The field key token. eg. SdfFieldKeys->Default.

Returns

A size_t.

virtual void EraseTimeSample(double time) const = 0

Removes the time-sample (if one exists) at the specified time.

Parameters

time – The time.

virtual const ISpecField *FindField(const PXR_NS::TfToken &fieldName) const = 0

Finds a field with key equivalent to fieldName.

Parameters

fieldName – Name of the field.

Returns

Null if it fails, else the found field.

virtual std::shared_ptr<ISpecNode> GetChildNode(PXR_NS::SdfSpecType childrenType, const PXR_NS::TfToken &childName) const = 0

Gets the node (if one exists) from the children container where the type is equivalent childrenType and the field token name is equivalent to childName.

Parameters
  • childrenType – Type for the children container. eg. SdfSpecTypeAttribute

  • childName – Name token of the child.

Returns

The child node.

virtual const PXR_NS::VtValue &GetFieldValue(const PXR_NS::TfToken &field) const = 0

Gets field value.

Returns an empty VtValue if the field does not exist.

Parameters

field – The field name token.

Returns

The field value.

virtual const std::string &GetName() const = 0

Gets the name of the node.

This is the equivalent to the ElementString of an SdfPath.

Returns

The name.

virtual uint64_t GetParentId() const = 0

Gets the parent identifier for the node.

Returns

The parent’s unique identifier.

virtual const PXR_NS::SdfPath &GetPath() const = 0

Gets the SdfPath for the node.

Returns

The path.

virtual uint64_t GetSpecId() const = 0

Gets identifier for the node.

Returns

The unique identifier.

virtual std::string GetString() const = 0

Gets a formatted string representation of the node.

Returns

The string.

virtual PXR_NS::SdfSpecType GetType() const = 0

Gets the SdfSpecType for the node.

eg. SdfSpecTypeAttribute, SdfSpecTypePrim

Returns

The type.

virtual const PXR_NS::TfToken &GetTypeName() const = 0

Gets the value of the SdfFieldKeys->TypeName field in the node.

Returns

The type name.

virtual PXR_NS::SdfValueTypeName GetValueTypeName() const = 0

Gets type name for the value held in the SdfFieldKeys->Default field of the node.

Returns

The value type name.

virtual uint64_t GetVersion() const = 0

Gets the current version of the node.

A value of 0 indicates that the node is a local modification pending reconciliation. Any other value represents the sequence number that Nucleus assigned when committed.

Returns

The version.

virtual bool HasField(const PXR_NS::TfToken &field) const = 0

Checks if there is an field with a TfToken equivalent to field in the container.

Parameters

field – The field token name.

Returns

True if field, false if not.

virtual void InsertOrAssignTimeSample(double time, const PXR_NS::VtValue &value) const = 0

If a sample at time already exists in samples, assigns the value at time.

If the sample does not exist, inserts the new value at time.

Parameters
  • time – The time.

  • value – The value.

virtual bool IsChildrenField(const PXR_NS::TfToken &fieldName) const = 0

Query if ‘fieldName’ is child.

Parameters

fieldName – Name of the field.

Returns

True if child, false if not.

virtual bool IsDetached() const = 0

Query if this node is detached from the tree hierarchy.

Note: IsValid() is true when this is false.

Returns

True if detached, false if not.

virtual bool IsEmpty() const = 0

Query if this node contains no fields.

Returns

True if detached, false if not.

virtual bool IsValid() const = 0

Query if this node is valid.

Note: IsDetached() is true when this is false.

Returns

True if valid, false if not.

virtual bool TryGetFieldValue(const PXR_NS::TfToken &field, const PXR_NS::VtValue **value) const = 0

Attempts to get field value for the given TfToken.

Parameters
  • field – The field.

  • value – The value.

Returns

True if it succeeds, false if it fails.

virtual bool TryGetChildFieldValue(PXR_NS::SdfSpecType childrenType, const PXR_NS::TfToken &childName, const PXR_NS::TfToken &fieldName, const PXR_NS::VtValue **value) const = 0

Gets the value (if one exists) for the field name token from the children container where the container type is equivalent to childrenType and the child key is equivalent to childName.

Parameters
  • childrenType – Type of the children.

  • childName – Name of the child.

  • fieldName – The field.

  • value – The value.

Returns

True if it succeeds, false if it fails.

virtual void VisitChildren(const PXR_NS::TfToken &childrenKey, std::function<bool(std::shared_ptr<ISpecNode>)> visitor) const = 0

Visits the children in the container where the key is equivalent to childrenKey.

Parameters
  • childrenKey – The children key.

  • visitor – The visitor.

virtual void VisitChildren(std::function<bool(std::shared_ptr<ISpecNode>)> visitor) const = 0

Visits the children in all containers in the node.

Parameters

visitor – The visitor.

virtual void VisitChildrenAsync(const PXR_NS::TfToken &childrenKey, std::function<void(std::shared_ptr<ISpecNode>)> visitor) const = 0

Asynchronously visits the children in the container where the key is equivalent to childrenKey.

The method will execute a parallel_for when the number of children in the container exceeds a parallel threshold of 100.

Parameters
  • childrenKey – The children key.

  • visitor – The visitor.

virtual void VisitFields(const std::function<bool(const PXR_NS::TfToken&, const ISpecField&)> &visitor, bool includeChildren = false) const = 0

Visit fields in the node.

Parameters
  • visitor – The visitor.

  • includeChildren – (Optional) True to include, false to exclude the children.

template<class T>
inline const T &GetFieldValue(const PXR_NS::TfToken &field, const T &defaultVal) const

Gets the typed field value from any of the children containers with the given TfToken field name.

If the field does not exist or the value is not of type T, then the default value will be returned.

Template Parameters

T – Generic type parameter.

Parameters
  • field – The field.

  • defaultVal – The default value.

Returns

The field value.

template<class T>
inline bool TryGetFieldValue(const PXR_NS::TfToken &field, const T **value) const

Attempts to get the typed field value from any of the children containers with the given TfToken field name.

If the field does not exist or the value is not of type T, then the pointer to value will be undeterministic and false is returned.

Template Parameters

T – Generic type parameter.

Parameters
  • field – The field.

  • value – The value.

Returns

True if it succeeds, false if it fails.

template<class T>
inline const T &GetAttributeValue(const PXR_NS::TfToken &field, const T &defaultVal) const

Gets the typed field value from the SdfSpecTypeAttribute children container with the given TfToken field name.

If the container or field does not exist or if the value is not of type T, then the default value will be returned.

Template Parameters

T – Generic type parameter.

Parameters
  • field – The field.

  • defaultVal – The default value.

Returns

The attribute value.

inline bool TryGetAttributeValue(const PXR_NS::TfToken &field, const PXR_NS::VtValue **value) const

Attempts to get the field value from the SdfSpecTypeAttribute children container with the given TfToken field name.

If the container or field does not exist, then the pointer to value will be undeterministic and false is returned.

Parameters
  • field – The field.

  • value – The value.

Returns

True if it succeeds, false if it fails.

template<class T>
inline bool TryGetAttributeValue(const PXR_NS::TfToken &field, const T **value) const

Attempts to get the typed field value from the SdfSpecTypeAttribute children container with the given TfToken field name.

If the container or field does not exist or if the value is not of type T, then the pointer to value will be undeterministic and false is returned.

Template Parameters

T – Generic type parameter.

Parameters
  • field – The field.

  • value – The value.

Returns

True if it succeeds, false if it fails.