----------------------------------------------------------------------------- Add a value to the store -----------------------------------------------------------------------------
| 56 | // Add a value to the store |
| 57 | //----------------------------------------------------------------------------- |
| 58 | bool 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> |