36 #include <boost/variant.hpp>
37 #include <boost/lexical_cast.hpp>
38 #include <json/value.h>
39 #include <json/reader.h>
52 if (
nullptr == boost::get<elements::NullElement>(&node.value())) {
57 if (
nullptr == node.getParent()) {
61 auto const &parent = *node.getParent();
64 boost::get<elements::InterfaceElement>(&(parent.value()))) {
73 void resolveTreeNodeImpl(PathTree &pathTree, std::string
const &path,
74 OriginalSource &source);
81 : boost::static_visitor<>(), m_tree(tree), m_node(node),
93 if (!parsed.isValid()) {
94 OSVR_DEV_VERBOSE(
"Couldn't parse alias: " << elt.
getSource());
98 if (!parsed.isSimple()) {
100 m_source.nestTransform(parsed.getAliasValue());
102 m_recurse(parsed.getLeaf());
109 BOOST_ASSERT_MSG(m_source.isResolved(),
110 "Landing on a sensor means we should have an "
111 "interface and device, exceptions would be thrown "
112 "in Decompose otherwise.");
119 BOOST_ASSERT_MSG(m_source.isResolved(),
120 "Landing on an interface means we should have an "
121 "interface and device, exceptions would be thrown "
122 "in Decompose otherwise.");
126 void m_decompose() { m_source.
decompose(m_node); }
127 void m_recurse(std::string
const &path) {
128 resolveTreeNodeImpl(m_tree, path, m_source);
130 PathTree &m_getPathTree() {
return m_tree; }
134 OriginalSource &m_source;
137 inline void resolveTreeNodeImpl(PathTree &pathTree, std::string
const &path,
138 OriginalSource &source) {
139 auto &node = pathTree.getNodeByPath(path);
145 TreeResolutionVisitor visitor(pathTree, node, source);
146 boost::apply_visitor(visitor, node.value());
149 boost::optional<OriginalSource> resolveTreeNode(PathTree &pathTree,
150 std::string
const &path) {
151 OriginalSource source;
152 resolveTreeNodeImpl(pathTree, path, source);
153 if (source.isResolved()) {
156 return boost::optional<OriginalSource>();
The result of resolving a tree node to a device: either an original source to connect to...
The element type corresponding to a path alias, with a priority level for sorting out whether automat...
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 & getSource()
Get the source of data for this alias.
The element type corresponding to a particular sensor of an interface.
void decompose(PathNode &node)
Decompose a path node representing an original source into its device, interface, and sensor...
The element type corresponding to an interface, which often may have one or more sensors.
void operator()(elements::InterfaceElement const &)
Handle an interface element.
Internal, configured header file for verbosity macros.
void operator()(T const &)
Fallback case.
void ifNullTryInferFromParent(common::PathNode &node)
Given a node, if it's null, try to infer from the parent what it should be.
void operator()(elements::SensorElement const &)
Handle a sensor element.
void operator()(elements::AliasElement const &elt)
Handle an alias element.