ufe  2.0
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/ufe-full-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 
58  Path(const PathSegment& segment);
59 
61  Path(PathSegment&& segment) noexcept;
62 
64  Path(const Path&) = default;
65 
67  Path& operator=(const Path&) = default;
68 
70  Path(Path&&) noexcept;
71 
73  Path& operator=(Path&& rhs) noexcept;
74 
76  Components::size_type size() const;
77 
80  bool empty() const;
81 
83  bool operator==(const Path& rhs) const;
85  bool operator!=(const Path& rhs) const;
87 
89  Path operator+(const PathSegment& rhs) const;
94  Path operator+(const PathComponent& rhs) const;
95  Path operator+(const std::string& rhs) const;
97 
100  Path pop() const;
101 
104  Path popSegment() const;
105 
108  Path popHead() const;
109 
113  Path head(int nbComponents) const;
114 
117  PathComponent back() const;
118 
122  Path sibling(const PathComponent& newTail) const;
123 
127  bool startsWith(const Path& prefix) const;
128 
135  Path replaceComponent(int index, const PathComponent& replacement) const;
136 
138  Components::const_iterator cbegin() const;
140  Components::const_iterator begin() const;
141  Components::const_iterator cend() const;
142  Components::const_iterator end() const;
143  Components::iterator begin();
144  Components::iterator end();
146 
148  Rtid runTimeId() const;
149 
151  const Segments& getSegments() const;
152 
154  Segments::size_type nbSegments() const;
155 
157  std::string string() const;
158 
160  std::int32_t hash() const;
161 
162 private:
163 
164  Segments fSegments;
165  // Provide support for component-based access and iteration. This
166  // doubles up space requirements, but components are not expensive
167  // (size of a shared pointer, typically two plain pointers).
168  Components fComponents;
169 
170  // A Path is immutable, so its hash value can be cached once computed.
171  // -1 is an illegal hash value.
172  mutable std::int32_t fHashValue {-1};
173 };
174 
175 }
176 
177 // Allow for use of Path with std::unordered_map.
178 namespace std {
179 template <> struct hash<UFE_VERSIONED_NS::Path> {
180  std::size_t operator()(const UFE_VERSIONED_NS::Path& path) const {return path.hash();}
181 };
182 }
183 
184 #endif /* _ufePath */
std::size_t operator()(const Ufe_v2 ::Path &path) const
Definition: path.h:180
A segment of a path within a single run-time.
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:178
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)
#define UFE_VERSIONED_NS
Definition: ufe.h:22
#define UFE_SDK_DECL
Definition: ufeExport.h:36