| 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); |
nothing calls this directly
no test coverage detected