OSVR Framework (Internal Development Docs)  0.6-1962-g59773924
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
ResolveFullTree.cpp
Go to the documentation of this file.
1 
11 // Copyright 2015 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 // Internal Includes
29 #include <osvr/Common/PathNode.h>
31 
32 // Library/third-party includes
33 #include <boost/variant.hpp>
34 
35 // Standard includes
36 // - none
37 
38 namespace osvr {
39 namespace common {
40  inline bool isNodeAnAlias(PathNode const &node) {
41  return boost::get<elements::AliasElement>(&node.value()) != nullptr;
42  }
43 
44  std::vector<std::string> resolveFullTree(PathTree &tree) {
45  std::vector<std::string> badPaths;
47  tree.getRoot(), [&tree, &badPaths](PathNode const &node) {
48  auto fullPath = getFullPath(node);
49  auto result = resolveTreeNode(tree, fullPath);
50  if (!result && isNodeAnAlias(node)) {
51  // OK, so this is an alias (it should have resolved) and yet
52  // it didn't. Add the path to the list of bad paths.
53  badPaths.emplace_back(std::move(fullPath));
54  }
55  });
56  return badPaths;
57  }
58 } // namespace common
59 } // namespace osvr
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
Header including PathTree.h and all additional headers needed to define related types.
std::string getFullPath(PathNode const &node)
Gets the absolute path for the given node.
Definition: PathNode.cpp:42
void traverseWith(T &node, F &&functor)
A method to handle visiting every node in a tree with a lambda or other by-value function object...
std::vector< std::string > resolveFullTree(PathTree &tree)
Traverse the given path tree, resolving all aliases found to fully populate any generated sensor targ...
Header.