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

Method GetValueAsBool

cpp/src/Manager.cpp:2116–2161  ·  view source on GitHub ↗

----------------------------------------------------------------------------- Gets a value as a bool -----------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

2114// Gets a value as a bool
2115//-----------------------------------------------------------------------------
2116bool Manager::GetValueAsBool
2117(
2118 ValueID const& _id,
2119 bool* o_value
2120)
2121{
2122 bool res = false;
2123
2124 if( o_value )
2125 {
2126 if( ValueID::ValueType_Bool == _id.GetType() )
2127 {
2128 if( Driver* driver = GetDriver( _id.GetHomeId() ) )
2129 {
2130 LockGuard LG(driver->m_nodeMutex);
2131 if( ValueBool* value = static_cast<ValueBool*>( driver->GetValue( _id ) ) )
2132 {
2133 *o_value = value->GetValue();
2134 value->Release();
2135 res = true;
2136 } else {
2137 OZW_ERROR(OZWException::OZWEXCEPTION_INVALID_VALUEID, "Invalid ValueID passed to GetValueAsBool");
2138 }
2139 }
2140 }
2141 else if( ValueID::ValueType_Button == _id.GetType() )
2142 {
2143 if( Driver* driver = GetDriver( _id.GetHomeId() ) )
2144 {
2145 LockGuard LG(driver->m_nodeMutex);
2146 if( ValueButton* value = static_cast<ValueButton*>( driver->GetValue( _id ) ) )
2147 {
2148 *o_value = value->IsPressed();
2149 value->Release();
2150 res = true;
2151 } else {
2152 OZW_ERROR(OZWException::OZWEXCEPTION_INVALID_VALUEID, "Invalid ValueID passed to GetValueAsBool");
2153 }
2154 }
2155 } else {
2156 OZW_ERROR(OZWException::OZWEXCEPTION_CANNOT_CONVERT_VALUEID, "ValueID passed to GetValueAsBool is not a Bool or Button Value");
2157 }
2158 }
2159
2160 return res;
2161}
2162
2163//-----------------------------------------------------------------------------
2164// <Manager::GetValueAsByte>

Callers

nothing calls this directly

Calls 3

IsPressedMethod · 0.80
GetValueMethod · 0.45
ReleaseMethod · 0.45

Tested by

no test coverage detected