MCPcopy Create free account
hub / github.com/OSVR/OSVR-Core / osvrToStream

Function osvrToStream

apps/PathTreeExport/PathTreeExport.cpp:53–120  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

51 bool showTree = true;
52};
53int osvrToStream(std::ostream &os, Options const &opts) {
54 osvr::clientkit::ClientContext context("com.osvr.tools.pathtreexport");
55
56 /// Get a non-const copy of the path tree.
57 osvr::common::PathTree pathTree;
58 osvr::common::clonePathTree(context.get()->getPathTree(), pathTree);
59
60 /// Resolve all aliases
61 osvr::common::resolveFullTree(pathTree);
62 {
63 auto graph = GraphOutputInterface::createGraphOutputInterface(
64 os, opts.graphOutputType);
65 using namespace osvr::common;
66
67 /// Now traverse for tree node output
68 bool fullPaths = opts.fullPaths;
69 osvr::util::traverseWith(
70 pathTree.getRoot(),
71 [&graph, &pathTree, fullPaths](osvr::common::PathNode const &node) {
72 auto parent = node.getParent();
73 if (nullptr == parent) {
74 return;
75 }
76 auto fullPath = getFullPath(node);
77 auto &graphNode = graph->addNode(
78 fullPaths ? fullPath : ("/" + node.getName()), fullPath,
79 getTypeName(node));
80 });
81
82 if (opts.showTree) {
83 /// Now traverse for parent link output
84 graph->enableTreeOrganization();
85 osvr::util::traverseWith(
86 pathTree.getRoot(), [&graph, &pathTree, fullPaths](
87 osvr::common::PathNode const &node) {
88 auto parent = node.getParent();
89 if (nullptr == parent) {
90 return;
91 }
92 auto fullPath = getFullPath(node);
93 auto &graphNode = graph->getNode(getFullPath(node));
94 graph->addEdge(graph->getNode(getFullPath(*parent)),
95 graphNode, "child");
96 });
97 }
98 if (opts.showAliases) {
99 /// Now traverse for aliases
100 osvr::util::traverseWith(
101 pathTree.getRoot(),
102 [&graph, &pathTree](osvr::common::PathNode const &node) {
103 auto alias =
104 boost::get<elements::AliasElement>(&node.value());
105 if (nullptr == alias) {
106 return;
107 }
108 auto fullPath = getFullPath(node);
109 ParsedAlias parsed(alias->getSource());
110 auto &graphNode = graph->getNode(fullPath);

Callers 1

mainFunction · 0.85

Calls 15

clonePathTreeFunction · 0.85
resolveFullTreeFunction · 0.85
traverseWithFunction · 0.85
getFullPathFunction · 0.85
getParentMethod · 0.80
getNameMethod · 0.80
addEdgeMethod · 0.80
valueMethod · 0.80
getLeafMethod · 0.80
isSimpleMethod · 0.80
getAliasMethod · 0.80

Tested by

no test coverage detected