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

Function main

apps/osvr_dump_tree_json.cpp:40–84  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

38#include <chrono>
39
40int main(int argc, char *argv[]) {
41 namespace po = boost::program_options;
42 // clang-format off
43 po::options_description desc("Options");
44 desc.add_options()
45 ("help,h", "produce help message")
46 ;
47 // clang-format on
48 po::variables_map vm;
49 bool usage = false;
50 try {
51 po::store(po::command_line_parser(argc, argv).options(desc).run(), vm);
52 po::notify(vm);
53 } catch (std::exception &e) {
54 std::cerr << "\nError parsing command line: " << e.what() << "\n\n";
55 usage = true;
56 }
57 if (usage || vm.count("help")) {
58 std::cerr << "\n Dumps the serialized JSON format of the path tree.\n";
59 std::cerr << "Usage: " << argv[0] << "\n\n";
60 return 1;
61 }
62
63 {
64 /// We only actually need the client open for long enough to get the
65 /// path tree and serialize it.
66 osvr::clientkit::ClientContext context("com.osvr.tools.dumptreejson");
67
68 if (!context.checkStatus()) {
69 std::cerr << "Client context has not yet started up - waiting. "
70 "Make sure the server is running."
71 << std::endl;
72 do {
73 std::this_thread::sleep_for(std::chrono::milliseconds(1));
74 context.update();
75 } while (!context.checkStatus());
76 std::cerr << "OK, client context ready. Proceeding." << std::endl;
77 }
78
79 /// Serialize
80 auto nodes = osvr::common::pathTreeToJson(context.get()->getPathTree());
81 std::cout << nodes.toStyledString() << std::endl;
82 }
83 return 0;
84}

Callers

nothing calls this directly

Calls 5

pathTreeToJsonFunction · 0.85
checkStatusMethod · 0.80
runMethod · 0.45
updateMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected