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

Function getSensorNumberHelper

src/osvr/Common/OriginalSource.cpp:106–121  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

104
105 template <typename T>
106 inline boost::optional<T>
107 getSensorNumberHelper(OriginalSource const &self) {
108 BOOST_ASSERT_MSG(self.isResolved(),
109 "Only makes sense when called on a resolved source.");
110 boost::optional<T> ret;
111 if (nullptr == self.getSensor()) {
112 return ret;
113 }
114 try {
115 ret = boost::lexical_cast<T>(self.getSensor()->getName());
116 } catch (boost::bad_lexical_cast &) {
117 // Just means we can't convert to the type, so returning an empty
118 // optional is fine.
119 }
120 return ret;
121 }
122
123 boost::optional<int> OriginalSource::getSensorNumber() const {
124 return getSensorNumberHelper<int>(*this);

Callers

nothing calls this directly

Calls 3

isResolvedMethod · 0.80
getNameMethod · 0.80
getSensorMethod · 0.45

Tested by

no test coverage detected