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

Function ifNullTryInferFromParent

src/osvr/Common/ResolveTreeNode.cpp:51–70  ·  view source on GitHub ↗

@brief Given a node, if it's null, try to infer from the parent what it should be. Right now can only infer that the children of an interface are sensors.

Source from the content-addressed store, hash-verified

49 ///
50 /// Right now can only infer that the children of an interface are sensors.
51 inline void ifNullTryInferFromParent(common::PathNode &node) {
52 if (nullptr == boost::get<elements::NullElement>(&node.value())) {
53 /// Not null.
54 return;
55 }
56
57 if (nullptr == node.getParent()) {
58 // couldn't help, no parent.
59 return;
60 }
61 auto const &parent = *node.getParent();
62
63 if (nullptr ==
64 boost::get<elements::InterfaceElement>(&(parent.value()))) {
65 return; // parent isn't an interface.
66 }
67 // So if we get here, parent is present and an interface, which means
68 // that we're a sensor.
69 node.value() = elements::SensorElement();
70 }
71
72 // Forward declaration
73 void resolveTreeNodeImpl(PathTree &pathTree, std::string const &path,

Callers 1

resolveTreeNodeImplFunction · 0.85

Calls 3

valueMethod · 0.80
getParentMethod · 0.80
SensorElementClass · 0.50

Tested by

no test coverage detected