40 #include <boost/program_options.hpp>
41 #include <boost/variant.hpp>
48 std::string graphOutputType =
"dot";
49 bool fullPaths =
false;
50 bool showAliases =
false;
58 osvr::common::clonePathTree(context.
get()->
getPathTree(), pathTree);
64 os, opts.graphOutputType);
68 bool fullPaths = opts.fullPaths;
72 auto parent = node.getParent();
73 if (
nullptr == parent) {
77 auto &graphNode = graph->addNode(
78 fullPaths ? fullPath : (
"/" + node.getName()), fullPath,
84 graph->enableTreeOrganization();
86 pathTree.getRoot(), [&graph, &pathTree, fullPaths](
88 auto parent = node.getParent();
89 if (
nullptr == parent) {
93 auto &graphNode = graph->getNode(
getFullPath(node));
94 graph->addEdge(graph->getNode(
getFullPath(*parent)),
98 if (opts.showAliases) {
104 boost::get<elements::AliasElement>(&node.value());
105 if (
nullptr == alias) {
110 auto &graphNode = graph->getNode(fullPath);
112 PathNode &source = pathTree.getNodeByPath(parsed.getLeaf());
114 graphNode, graph->getNode(
getFullPath(source)),
"alias",
115 parsed.isSimple() ? std::string() : parsed.getAlias());
122 int main(
int argc,
char *argv[]) {
123 std::ostream *stream = &std::cout;
127 namespace po = boost::program_options;
129 po::options_description desc(
"Options");
131 (
"help,h",
"produce help message")
132 (
"output,O", po::value<std::string>(),
"output file (defaults to standard out)")
134 (
"show-tree,t", po::value<bool>(&opt.showTree)->default_value(
true),
"Whether or not to show the path tree structure")
135 (
"show-aliases,a", po::value<bool>(&opt.showAliases)->default_value(
false),
"Whether or not to show the alias links")
136 (
"full-paths,p", po::value<bool>(&opt.fullPaths)->default_value(
false),
"Whether or not to use a node's full path as its label")
139 po::variables_map vm;
142 po::store(po::command_line_parser(argc, argv).options(desc).run(),
145 }
catch (std::exception &e) {
146 std::cerr <<
"\nError parsing command line: " << e.what()
150 if (usage || vm.count(
"help")) {
152 <<
"\nTraverses the path tree and outputs it as input data "
153 "for a graph software package\n";
154 std::cerr <<
"Usage: " << argv[0] <<
" [options]\n";
155 std::cerr << desc <<
"\n";
159 if (vm.count(
"output")) {
160 file.open(vm[
"output"].as<std::string>().c_str());
162 std::cerr <<
"Error opening output file." << std::endl;
Handles spatial transformations.
Client context object: Create and keep one in your application. Handles lifetime management and provi...
A tree representation, with path/url syntax, of the known OSVR system.
::osvr::util::TreeNode< PathElement > PathNode
The specific tree node type that contains a path element.
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.
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...
static osvr::unique_ptr< GraphOutputInterface > createGraphOutputInterface(std::ostream &os, std::string const &type)
Factory method.
osvr::common::PathTree const & getPathTree() const
Accessor for the path tree.
OSVR_ClientContext get()
Gets the bare OSVR_ClientContext.
int osvrToStream(std::ostream &os, Options const &opts)
const char * getTypeName(PathNode const &node)
Gets an identifying string for the node value type.
std::vector< std::string > resolveFullTree(PathTree &tree)
Traverse the given path tree, resolving all aliases found to fully populate any generated sensor targ...
Internal, configured header file for verbosity macros.