omni::spectree::v1::ISpecTreeClient

Defined in omni_spectree/Interfaces.h

class ISpecTreeClient

SpecTree is an observable tree hierarchy that provides navigation of nodes.

Public Types

using CopyVisitor_t = std::function<PXR_NS::VtValue(uint64_t newSpecId, PXR_NS::SdfSpecType type, const PXR_NS::SdfPath &path, const PXR_NS::TfToken &fieldName, const ISpecField &fieldValue)>

Public Functions

ISpecTreeClient() = default
virtual ~ISpecTreeClient() = default
ISpecTreeClient(const ISpecTreeClient &other) = delete
ISpecTreeClient(ISpecTreeClient &&other) = delete
ISpecTreeClient &operator=(const ISpecTreeClient &other) = delete
ISpecTreeClient &operator=(ISpecTreeClient &&other) = delete
virtual void Clear() = 0

Erases all nodes from the tree.

virtual bool EraseSpec(const PXR_NS::SdfPath &path) = 0

Removes the node at location path.

Parameters

path – Full pathname of the file.

Returns

True if it succeeds, false if it fails.

virtual bool Equals(const ISpecTreeClient &other) const = 0

Tests if this tree is considered equal to another.

Parameters

other – The constant i specifier tree client& to compare to this object.

Returns

True if the objects are considered equal, false if they are not.

virtual std::shared_ptr<ISpecNode> FindNode(uint64_t specId) const = 0

Finds an node with a unique identifier equivalent to specId.

Parameters

specId – Unique identifier for the node.

Returns

A pointer to a node;

virtual std::shared_ptr<ISpecNode> FindNode(const PXR_NS::SdfPath &path) const = 0

Finds an node with as SdfPath equivalent to path.

Parameters

path – Full pathname of the file.

Returns

A pointer to a node;

virtual const PXR_NS::SdfPath &FindPath(uint64_t specId) const = 0

Returns the SdfPath for the node with a unique identifier equivalent to specId.

Parameters

specId – Identifier for the specifier.

Returns

The found path.

virtual void Flush() = 0

Dispatches and reconciles all uncommitted changes to Nucleus.

virtual uint64_t GetCommittedVersion() const = 0

Gets currently committed version of the tree.

Returns

The base version.

virtual std::string GetString(bool currentValueOnly = false) const = 0

Gets a formatted string representation of the field.

Parameters

currentValueOnly – (Optional) True to format only the current and not the committed value.

Returns

The string.

virtual bool InsertOrAssignSpec(const PXR_NS::SdfPath &path, PXR_NS::SdfSpecType type) = 0

If a node at at SdfPath path already exists in the tree, assigns the SdfSpecType type to the path.

If the node does not exist, inserts the new node of SdfSpecType type.

Parameters
  • path – Full pathname of the file.

  • type – The type.

Returns

True if it succeeds, false if it fails.

virtual bool Move(const PXR_NS::SdfPath &oldPath, const PXR_NS::SdfPath &newPath) = 0

If a node exists at the old SdfPath path, moves the node to the new SdfPath.

Parameters
  • oldPath – Full pathname of the old file.

  • newPath – Full pathname of the new file.

Returns

True if it succeeds, false if it fails.

virtual bool Save() = 0

Saves the the current tree.

Returns

True if it succeeds, false if it fails or the tree’s url is invalid.

virtual bool Save(std::string const &url) = 0

Saves the the current tree to the specified url.

Parameters

url – URL of the resource.

Returns

True if it succeeds, false if it fails.

virtual bool SetFieldValue(const PXR_NS::SdfPath &specPath, const PXR_NS::TfToken &fieldName, const PXR_NS::VtValue &newValue) const = 0

If the node exists at SdfPath specPath and the field identified by fieldName exists in the node then the value will be set.

Parameters
  • specPath – Full pathname of the specifier file.

  • fieldName – Name of the field.

  • newValue – The new value.

Returns

True if it succeeds, false if it fails.

virtual uint64_t CopyAsync(const std::shared_ptr<ISpecNode> &node, const PXR_NS::SdfPath &newPath, CopyVisitor_t visitor) = 0

Copies the specified node to the SdfPath newPath, enabling modifications to the destination node as the visitor recursively enumerates the nodes of the source.

Parameters
  • node – The node.

  • newPath – Full pathname of the new file.

  • visitor – The visitor.

Returns

An uint64_t.

virtual std::shared_ptr<IAsyncBatch> StartAsyncBatch() = 0

Starts an asynchronous batch.

Returns

A pointer to a batch;

virtual void VisitPaths(const std::function<void(const PXR_NS::SdfPath&, uint64_t)> &visitor) const = 0

Visits the paths in the tree.

Parameters

visitor – The visitor.

virtual void VisitSpecs(const std::function<void(uint64_t, const PXR_NS::SdfPath&, const std::shared_ptr<ISpecNode>&)> &visitor) const = 0

Visits node in the tree.

Parameters

visitor – The visitor.

Public Static Functions

static std::shared_ptr<ISpecTreeClient> Create(IInboundChangeDelegate *inboundDelegate, IOutboundChangeDelegate *outboundDelegate)

Creates a detached instance of ISpecTreeClient.

Parameters
  • inboundDelegate – (Optional) The inbound delegate.

  • outboundDelegate – (Optional) The outbound delegate.

Returns

A pointer to ISpecTreeClient.

static bool TryGet(const PXR_NS::SdfLayerRefPtr &layer, std::weak_ptr<ISpecTreeClient> &result)

Attempts to get ISpecTreeClient from the given SdfLayerRefPtr.

Parameters
  • layer – The layer.

  • result[inout] The result.

Returns

True if it succeeds, false if it fails.

static inline std::weak_ptr<ISpecTreeClient> Get(const PXR_NS::SdfLayerRefPtr &layer)