ufe  4.2
Universal Front End is a DCC-agnostic component that will allow a DCC to browse and edit data in multiple data models
Ufe::Path Class Reference

Identify an object or 3D path in the scene. More...

#include <path.h>

Public Types

typedef std::vector< PathSegmentSegments
 
typedef PathSegment::Components Components
 

Public Member Functions

 Path ()=default
 Default constructor. Creates an empty path. More...
 
 Path (const Segments &segments)
 
 Path (Segments &&segments) noexcept
 
 Path (const PathSegment &segment)
 
 Path (PathSegment &&segment) noexcept
 Move constructor. More...
 
 Path (const Path &)=default
 Default copy constructor. More...
 
Pathoperator= (const Path &)=default
 Default assignment operator. More...
 
 Path (Path &&) noexcept
 Move construction. Right hand side becomes empty. More...
 
Pathoperator= (Path &&rhs) noexcept
 Move assignment. Right hand side becomes empty. More...
 
Components::size_type size () const
 
bool empty () const
 
Path pop () const
 
Path popSegment () const
 
Path popHead () const
 
Path head (int nbComponents) const
 
PathComponent back () const
 
Path sibling (const PathComponent &newTail) const
 
bool startsWith (const Path &prefix) const
 
Path replaceComponent (int index, const PathComponent &replacement) const
 
Path reparent (const Path &originalPrefix, const Path &newPrefix) const
 
Rtid runTimeId () const
 
const SegmentsgetSegments () const
 
Segments::size_type nbSegments () const
 
std::string string () const
 
std::int32_t hash () const
 
bool operator== (const Path &rhs) const
 Unfortunately no compiler-generated default equality operators. More...
 
bool operator!= (const Path &rhs) const
 Unfortunately no compiler-generated default equality operators. More...
 
Path operator+ (const PathSegment &rhs) const
 
Path operator+ (const PathComponent &rhs) const
 
Path operator+ (const std::string &rhs) const
 
Components::const_iterator cbegin () const
 Iteration interface on PathComponents. More...
 
Components::const_iterator begin () const
 Iteration interface on PathComponents. More...
 
Components::const_iterator cend () const
 Iteration interface on PathComponents. More...
 
Components::const_iterator end () const
 Iteration interface on PathComponents. More...
 
Components::iterator begin ()
 Iteration interface on PathComponents. More...
 
Components::iterator end ()
 Iteration interface on PathComponents. More...
 

Private Attributes

Segments fSegments
 
Components fComponents
 
std::int32_t fHashValue {-1}
 

Detailed Description

Identify an object or 3D path in the scene.

A path consists of one or more path segments that identify an object in the scene. The objects are identified by name.

A path can represent containment, through compound nodes that recursively contain other nodes, or a 3D hierarchy, through parent nodes down to a child.

The runtime of a path is defined to be the runtime of its node, which is the runtime of the final segment.

The following examples show how to create a path.

pathComponents = [ufe.PathComponent("c0"), ufe.PathComponent("c1"), ufe.PathComponent("c2"), ufe.PathComponent("c3")]
ps2 = ufe.PathSegment(pathComponents, 1234, '/')
singleSegmentPath = ufe.Path(ps2)
# Resulting path:
# /c0/c1/c2/c3
self.assertEqual(len(singleSegmentPath), 4)
pathSegments = [ufe.PathSegment("/pathSegment/with/multiple/components", 1234, '/'), ufe.PathSegment(".another.pathSegment.different.separator", 5678, '.'), ufe.PathSegment("|yet|another|pathSegment|pipeSeparator", 9012, '|')]
p2 = ufe.Path(pathSegments)
# Resulting path:
# /pathSegment/with/multiple/components.another.pathSegment.different.separator|yet|another|pathSegment|pipeSeparator
self.assertEqual(len(p2), 12)
self.assertEqual(p2.nbSegments(), 3)

Definition at line 37 of file path.h.

Member Typedef Documentation

◆ Components

Definition at line 42 of file path.h.

◆ Segments

typedef std::vector<PathSegment> Ufe::Path::Segments

Definition at line 41 of file path.h.

Constructor & Destructor Documentation

◆ Path() [1/7]

Ufe::Path::Path ( )
default

Default constructor. Creates an empty path.

◆ Path() [2/7]

Ufe::Path::Path ( const Segments segments)

Create a Path by copying a vector of PathSegment.

Parameters
segmentsPathSegments vector of PathSegment.

◆ Path() [3/7]

Ufe::Path::Path ( Segments &&  segments)
noexcept

Create a Path by moving a vector of PathSegment.

Parameters
segmentsPathSegments vector of PathSegment.

◆ Path() [4/7]

Ufe::Path::Path ( const PathSegment segment)

Convenience to create a Path from a single PathSegment.

Parameters
segmentPathSegment.

◆ Path() [5/7]

Ufe::Path::Path ( PathSegment &&  segment)
noexcept

Move constructor.

◆ Path() [6/7]

Ufe::Path::Path ( const Path )
default

Default copy constructor.

◆ Path() [7/7]

Ufe::Path::Path ( Path &&  )
noexcept

Move construction. Right hand side becomes empty.

Member Function Documentation

◆ back()

PathComponent Ufe::Path::back ( ) const
Returns
The PathComponent at the tail of the Path.
Exceptions
InvalidOperationOnPathIf Path is empty.

Referenced by Ufe::Trie< T >::move().

Here is the caller graph for this function:

◆ begin() [1/2]

Components::const_iterator Ufe::Path::begin ( ) const

Iteration interface on PathComponents.

◆ begin() [2/2]

Components::iterator Ufe::Path::begin ( )

Iteration interface on PathComponents.

◆ cbegin()

Components::const_iterator Ufe::Path::cbegin ( ) const

Iteration interface on PathComponents.

Referenced by Ufe::Trie< T >::containsAncestorHelper().

Here is the caller graph for this function:

◆ cend()

Components::const_iterator Ufe::Path::cend ( ) const

Iteration interface on PathComponents.

Referenced by Ufe::Trie< T >::containsAncestorHelper().

Here is the caller graph for this function:

◆ empty()

bool Ufe::Path::empty ( ) const

Convenience method for size() == 0.

Returns
True if the path is empty.

Referenced by Ufe::Trie< T >::containsAncestorHelper(), and Ufe::Trie< T >::containsDescendantHelper().

Here is the caller graph for this function:

◆ end() [1/2]

Components::const_iterator Ufe::Path::end ( ) const

Iteration interface on PathComponents.

◆ end() [2/2]

Components::iterator Ufe::Path::end ( )

Iteration interface on PathComponents.

◆ getSegments()

const Segments& Ufe::Path::getSegments ( ) const
Returns
PathSegments of Path.

◆ hash()

std::int32_t Ufe::Path::hash ( ) const
Returns
An integer hash value for the Path. This can be used to add Paths to hash maps.

Referenced by std::hash< Ufe_v4 ::Path >::operator()().

Here is the caller graph for this function:

◆ head()

Path Ufe::Path::head ( int  nbComponents) const
Parameters
nbComponentsThe first n PathComponent to retrieve.
Returns
A copy of the Path that includes only the first n PathComponent. If n is negative, the last n PathComponent are removed.
Exceptions
InvalidOperationOnPathIf argument is 0, > size(), <= -size().

◆ nbSegments()

Segments::size_type Ufe::Path::nbSegments ( ) const
Returns
The number of segments in the Path.

◆ operator!=()

bool Ufe::Path::operator!= ( const Path rhs) const

Unfortunately no compiler-generated default equality operators.

◆ operator+() [1/3]

Path Ufe::Path::operator+ ( const PathSegment rhs) const

Return a copy of the path with the argument appended. Versions with a path component or string argument throw InvalidOperationOnPath if the path is empty, as adding a component must be done to a segment with a valid runtime ID.

◆ operator+() [2/3]

Path Ufe::Path::operator+ ( const PathComponent rhs) const

Return a copy of the path with the argument appended. Versions with a path component or string argument throw InvalidOperationOnPath if the path is empty, as adding a component must be done to a segment with a valid runtime ID.

◆ operator+() [3/3]

Path Ufe::Path::operator+ ( const std::string &  rhs) const

Return a copy of the path with the argument appended. Versions with a path component or string argument throw InvalidOperationOnPath if the path is empty, as adding a component must be done to a segment with a valid runtime ID.

◆ operator=() [1/2]

Path& Ufe::Path::operator= ( const Path )
default

Default assignment operator.

◆ operator=() [2/2]

Path& Ufe::Path::operator= ( Path &&  rhs)
noexcept

Move assignment. Right hand side becomes empty.

◆ operator==()

bool Ufe::Path::operator== ( const Path rhs) const

Unfortunately no compiler-generated default equality operators.

◆ pop()

Path Ufe::Path::pop ( ) const
Returns
A copy of the Path with the tail PathComponent removed.
Exceptions
InvalidOperationOnPathIf Path is empty.

Referenced by Ufe::Trie< T >::move().

Here is the caller graph for this function:

◆ popHead()

Path Ufe::Path::popHead ( ) const
Returns
A copy of the Path with the head PathComponent removed.
Exceptions
InvalidOperationOnPathIf Path is empty.

◆ popSegment()

Path Ufe::Path::popSegment ( ) const
Returns
A copy of the Path with the tail PathSegment removed.
Exceptions
InvalidOperationOnPathIf Path is empty.

◆ reparent()

Path Ufe::Path::reparent ( const Path originalPrefix,
const Path newPrefix 
) const

Create a copy of the path, with the originalPrefix replaced by newPrefix. If the last PathSegment of newPrefix and the first PathSegment of *this which follows originalPrefix share a runTimeId and separator then those PathSegments will be merged into a single segment. If originalPrefix is empty then reparent appends *this to newPrefix.

Parameters
originalPrefixPath of *this to be replaced. startsWith(originalPrefix) must return true or originalPrefix must be empty.
newPrefixPath which replaces originalPrefix.
Returns
A copy of the path with originalPrefix replaced with newPrefix.
Exceptions
InvalidOperationOnPathIf originalPrefix is not empty and *this does not begin with originalPrefix.

◆ replaceComponent()

Path Ufe::Path::replaceComponent ( int  index,
const PathComponent replacement 
) const

Create a copy of the path, with the path component at index replaced with the argument.

Parameters
indexIndex of component to replace.
replacementNew component.
Returns
A copy of the path with a single component replaced.
Exceptions
InvalidOperationOnPathIf index is < 0 or >= size().

◆ runTimeId()

Rtid Ufe::Path::runTimeId ( ) const
Returns
The runtime ID of the final PathSegment. If the Path is empty, returns a 0 (invalid) ID.

◆ sibling()

Path Ufe::Path::sibling ( const PathComponent newTail) const
Parameters
newTailThe tail component of the sibling path.
Returns
A copy of the Path with its tail component set to newTail.
Exceptions
InvalidOperationOnPathIf Path is empty.

◆ size()

Components::size_type Ufe::Path::size ( ) const
Returns
The number of components in the path.

◆ startsWith()

bool Ufe::Path::startsWith ( const Path prefix) const

Checks if the path begins with the given prefix. Will return true if the two paths are equal.

Returns
True if path starts with the prefix.

◆ string()

std::string Ufe::Path::string ( ) const
Returns
The string representation of the Path.

Member Data Documentation

◆ fComponents

Components Ufe::Path::fComponents
private

Definition at line 187 of file path.h.

◆ fHashValue

std::int32_t Ufe::Path::fHashValue {-1}
mutableprivate

Definition at line 191 of file path.h.

◆ fSegments

Segments Ufe::Path::fSegments
private

Definition at line 183 of file path.h.


The documentation for this class was generated from the following file: