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

Method AddValue

cpp/src/value_classes/ValueStore.cpp:58–87  ·  view source on GitHub ↗

----------------------------------------------------------------------------- Add a value to the store -----------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

56// Add a value to the store
57//-----------------------------------------------------------------------------
58bool ValueStore::AddValue
59(
60 Value* _value
61)
62{
63 if( !_value )
64 {
65 return false;
66 }
67 uint32 key = _value->GetID().GetValueStoreKey();
68 map<uint32,Value*>::iterator it = m_values.find( key );
69 if( it != m_values.end() )
70 {
71 // There is already a value in the store with this key, so we give up.
72 return false;
73 }
74
75 m_values[key] = _value;
76 _value->AddRef();
77
78 // Notify the watchers of the new value
79 if( Driver* driver = Manager::Get()->GetDriver( _value->GetID().GetHomeId() ) )
80 {
81 Notification* notification = new Notification( Notification::Type_ValueAdded );
82 notification->SetValueId( _value->GetID() );
83 driver->QueueNotification( notification );
84 }
85
86 return true;
87}
88
89//-----------------------------------------------------------------------------
90// <ValueStore::RemoveValue>

Callers

nothing calls this directly

Calls 6

findMethod · 0.80
AddRefMethod · 0.80
QueueNotificationMethod · 0.80
GetFunction · 0.50
endMethod · 0.45
GetDriverMethod · 0.45

Tested by

no test coverage detected