OSVR Framework (Internal Development Docs)  0.6-1962-g59773924
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
PathTree.h
Go to the documentation of this file.
1 
11 // Copyright 2014 Sensics, Inc.
12 //
13 // Licensed under the Apache License, Version 2.0 (the "License");
14 // you may not use this file except in compliance with the License.
15 // You may obtain a copy of the License at
16 //
17 // http://www.apache.org/licenses/LICENSE-2.0
18 //
19 // Unless required by applicable law or agreed to in writing, software
20 // distributed under the License is distributed on an "AS IS" BASIS,
21 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 // See the License for the specific language governing permissions and
23 // limitations under the License.
24 
25 #ifndef INCLUDED_PathTree_h_GUID_8C6C691A_AAB1_4586_64DD_BD3F870C9071
26 #define INCLUDED_PathTree_h_GUID_8C6C691A_AAB1_4586_64DD_BD3F870C9071
27 
28 // Internal Includes
29 #include <osvr/Common/PathTree_fwd.h> // IWYU pragma: export
30 #include <osvr/Common/Export.h>
32 
33 // Library/third-party includes
34 #include <boost/noncopyable.hpp>
35 
36 // Standard includes
37 #include <string>
38 
39 namespace osvr {
40 namespace common {
43  class PathTree : boost::noncopyable {
44  public:
46  OSVR_COMMON_EXPORT PathTree();
47 
51  template <typename F> void visitTree(F &functor) { functor(*m_root); }
52 
55  template <typename F> void visitConstTree(F &functor) const {
56  functor(const_cast<PathNode const &>(*m_root));
57  }
59 
65  OSVR_COMMON_EXPORT PathNode &getNodeByPath(std::string const &path);
66 
71  OSVR_COMMON_EXPORT PathNode const &
72  getNodeByPath(std::string const &path) const;
73 
78  OSVR_COMMON_EXPORT PathNode &
79  getNodeByPath(std::string const &path,
80  PathElement const &finalComponentDefault);
81 
83  OSVR_COMMON_EXPORT void reset();
84 
85  PathNode &getRoot() { return *m_root; }
86 
87  PathNode const &getRoot() const { return *m_root; }
88 
89  private:
91  PathNodePtr m_root;
92  };
93 
100  OSVR_COMMON_EXPORT bool
101  addAlias(PathNode &node, std::string const &source,
102  AliasPriority priority = ALIASPRIORITY_MANUAL);
103 
113  OSVR_COMMON_EXPORT bool
114  addAliasFromRoute(PathNode &node, std::string const &route,
115  AliasPriority priority = ALIASPRIORITY_MANUAL);
116 
118  PathNode &node, std::string const &source, std::string const &dest,
119  AliasPriority priority = ALIASPRIORITY_MANUAL);
120 
121  bool isPathAbsolute(std::string const &source);
122 
126  OSVR_COMMON_EXPORT void clonePathTree(PathTree const &src, PathTree &dest);
127 
128 } // namespace common
129 } // namespace osvr
130 
131 #endif // INCLUDED_PathTree_h_GUID_8C6C691A_AAB1_4586_64DD_BD3F870C9071
A tree representation, with path/url syntax, of the known OSVR system.
Definition: PathTree.h:43
::osvr::util::TreeNode< PathElement > PathNode
The specific tree node type that contains a path element.
Definition: PathNode_fwd.h:42
PathTree()
Constructor.
Definition: PathTree.cpp:46
PathNode & getNodeByPath(std::string const &path)
Returns the node indicated by the path, which must be absolute (begin with a /). Any non-existent nod...
Definition: PathTree.cpp:47
void reset()
Reset the path tree to a new, empty root node.
Definition: PathTree.cpp:65
void visitConstTree(F &functor) const
Visit the tree, with const nodes, starting at the root, with the given functor.
Definition: PathTree.h:55
bool addAlias(PathNode &node, std::string const &source, AliasPriority priority)
Definition: PathTree.cpp:103
Automatically-generated export header - do not edit!
::osvr::util::TreeNodePointer< PathElement >::type PathNodePtr
The ownership pointer of the specific tree node.
Definition: PathNode_fwd.h:45
void visitTree(F &functor)
Visitation.
Definition: PathTree.h:51
boost::variant< NullElement, AliasElement, SensorElement, InterfaceElement, DeviceElement, PluginElement, StringElement > PathElement
The variant type containing a particular kind of path element.
bool addAliasFromSourceAndRelativeDest(PathNode &node, std::string const &source, std::string const &dest, AliasPriority priority=ALIASPRIORITY_MANUAL)
Definition: PathTree.cpp:135