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
path.h
Go to the documentation of this file.
1 #line 1 "S:/jenkins/workspace/ECP/ufe/ufe-full-python3.10-windows/ufe/include/path.h"
2 #ifndef _ufePath
3 #define _ufePath
4 // ===========================================================================
5 // Copyright 2018 Autodesk, Inc. All rights reserved.
6 //
7 // Use of this software is subject to the terms of the Autodesk license
8 // agreement provided at the time of installation or download, or which
9 // otherwise accompanies this software in either electronic or hard copy form.
10 // ===========================================================================
11 
12 #include "pathSegment.h"
13 
14 #include <vector>
15 
16 UFE_NS_DEF {
17 
18 class PathComponent;
19 
21 
38 {
39 public:
40 
41  typedef std::vector<PathSegment> Segments;
43 
45  Path() = default;
46 
52  Path(const Segments& segments);
53 
59  Path(Segments&& segments) noexcept;
60 
65  Path(const PathSegment& segment);
66 
68  Path(PathSegment&& segment) noexcept;
69 
71  Path(const Path&) = default;
72 
74  Path& operator=(const Path&) = default;
75 
77  Path(Path&&) noexcept;
78 
80  Path& operator=(Path&& rhs) noexcept;
81 
83  Components::size_type size() const;
84 
87  bool empty() const;
88 
90  bool operator==(const Path& rhs) const;
92  bool operator!=(const Path& rhs) const;
94 
96  Path operator+(const PathSegment& rhs) const;
101  Path operator+(const PathComponent& rhs) const;
102  Path operator+(const std::string& rhs) const;
104 
107  Path pop() const;
108 
111  Path popSegment() const;
112 
115  Path popHead() const;
116 
120  Path head(int nbComponents) const;
121 
124  PathComponent back() const;
125 
129  Path sibling(const PathComponent& newTail) const;
130 
134  bool startsWith(const Path& prefix) const;
135 
142  Path replaceComponent(int index, const PathComponent& replacement) const;
143 
154  Path reparent(const Path& originalPrefix, const Path& newPrefix) const;
155 
157  Components::const_iterator cbegin() const;
159  Components::const_iterator begin() const;
160  Components::const_iterator cend() const;
161  Components::const_iterator end() const;
162  Components::iterator begin();
163  Components::iterator end();
165 
167  Rtid runTimeId() const;
168 
170  const Segments& getSegments() const;
171 
173  Segments::size_type nbSegments() const;
174 
176  std::string string() const;
177 
179  std::int32_t hash() const;
180 
181 private:
182 
183  Segments fSegments;
184  // Provide support for component-based access and iteration. This
185  // doubles up space requirements, but components are not expensive
186  // (size of a shared pointer, typically two plain pointers).
187  Components fComponents;
188 
189  // A Path is immutable, so its hash value can be cached once computed.
190  // -1 is an illegal hash value.
191  mutable std::int32_t fHashValue {-1};
192 };
193 
194 }
195 
196 // Allow for use of Path with std::unordered_map.
197 namespace std {
198 template <> struct hash<UFE_VERSIONED_NS::Path> {
199  std::size_t operator()(const UFE_VERSIONED_NS::Path& path) const {return path.hash();}
200 };
201 }
202 
203 #endif /* _ufePath */
A segment of a path within a single runtime.
Definition: pathSegment.h:35
PathSegment::Components Components
Definition: path.h:42
Constant string representation with fixed space and O(1) comparison.
Definition: pathComponent.h:33
Definition: path.h:197
std::vector< PathSegment > Segments
Definition: path.h:41
std::int32_t hash() const
Identify an object or 3D path in the scene.
Definition: path.h:37
uint32_t Rtid
Definition: rtid.h:26
std::vector< PathComponent > Components
Definition: pathSegment.h:39
#define UFE_NS_DEF
Definition: ufe.h:35
Path path(const std::string &pathString)
std::size_t operator()(const Ufe_v4 ::Path &path) const
Definition: path.h:199
#define UFE_VERSIONED_NS
Definition: ufe.h:22
#define UFE_SDK_DECL
Definition: ufeExport.h:36