MCPcopy Create free account
hub / github.com/OpenZWave/open-zwave / GetValueAsInt

Method GetValueAsInt

cpp/src/Manager.cpp:2240–2288  ·  view source on GitHub ↗

----------------------------------------------------------------------------- Gets a value as a 32-bit signed integer -----------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

2238// Gets a value as a 32-bit signed integer
2239//-----------------------------------------------------------------------------
2240bool Manager::GetValueAsInt
2241(
2242 ValueID const& _id,
2243 int32* o_value
2244)
2245{
2246 bool res = false;
2247
2248 if( o_value )
2249 {
2250 if( Driver* driver = GetDriver( _id.GetHomeId() ) )
2251 {
2252 LockGuard LG(driver->m_nodeMutex);
2253
2254 if( ValueID::ValueType_Int == _id.GetType() )
2255 {
2256 if( ValueInt* value = static_cast<ValueInt*>( driver->GetValue( _id ) ) )
2257 {
2258 *o_value = value->GetValue();
2259 value->Release();
2260 res = true;
2261 }
2262 else
2263 {
2264 OZW_ERROR(OZWException::OZWEXCEPTION_INVALID_VALUEID, "Invalid ValueID passed to GetValueAsInt");
2265 }
2266 }
2267 else if (ValueID::ValueType_BitSet == _id.GetType() )
2268 {
2269 if (ValueBitSet* value = static_cast<ValueBitSet*>( driver->GetValue( _id ) ) )
2270 {
2271 *o_value = value->GetValue();
2272 value->Release();
2273 res = true;
2274 }
2275 else
2276 {
2277 OZW_ERROR(OZWException::OZWEXCEPTION_INVALID_VALUEID, "Invalid ValueID passed to GetValueAsInt");
2278 }
2279 }
2280 else
2281 {
2282 OZW_ERROR(OZWException::OZWEXCEPTION_CANNOT_CONVERT_VALUEID, "ValueID passed to GetValueAsInt is not a Int or BitSet Value");
2283 }
2284 }
2285 }
2286
2287 return res;
2288}
2289
2290//-----------------------------------------------------------------------------
2291// <Manager::GetValueAsRaw>

Callers

nothing calls this directly

Calls 2

GetValueMethod · 0.45
ReleaseMethod · 0.45

Tested by

no test coverage detected