![]() |
Shadowrun: Awakened 29 September 2011 - Build 871
|
#include <ManagedDictionary.h>
Inheritance diagram for ManagedDictionary< Key, Value >:Public Member Functions | |
| __inline bool | getManaged () const |
| ManagedDictionary () | |
| ManagedDictionary (bool manageMemory) | |
| ManagedDictionary (bool manageMemory, Value *defaultValue) | |
| __inline void | setManaged (bool val) |
| ~ManagedDictionary () | |
Protected Attributes | |
| bool | _manageMemory |
An extension of the Dictionary class This will optionally 'manage' memory by deleting all values still contained when the object is destroyed NOTE: By default, memory management is NOT enabled The value for this dictionary is always held as a pointer, get/set type operations treat the Value as a pointer EG ManagedDictionary<int, Command> will use int as the key and Command* as the value NOTE: When calling getSafe(Key), NULL is returned if no match for the key is found
Definition at line 17 of file ManagedDictionary.h.
| ManagedDictionary< Key, Value >::ManagedDictionary | ( | ) | [inline] |
Constructor
Definition at line 26 of file ManagedDictionary.h.
: _manageMemory(false) { setDefaultValue(NULL); }
| ManagedDictionary< Key, Value >::ManagedDictionary | ( | bool | manageMemory | ) | [inline] |
Constructor Sets whether or not memory is managed by this dictionary
Definition at line 35 of file ManagedDictionary.h.
: _manageMemory(manageMemory) { setDefaultValue(NULL); }
| ManagedDictionary< Key, Value >::ManagedDictionary | ( | bool | manageMemory, |
| Value * | defaultValue | ||
| ) | [inline] |
Constructor Sets whether or not memory is managed and the default value returned by this dictionary
Definition at line 44 of file ManagedDictionary.h.
: _manageMemory(manageMemory) { setDefaultValue(defaultValue); }
| ManagedDictionary< Key, Value >::~ManagedDictionary | ( | ) | [inline] |
Destructor If "managed" is true, then this will delete all values in this dictionary
Definition at line 53 of file ManagedDictionary.h.
{
//if we are not managing memory, then abort
if(!_manageMemory)
return;
//if we are managing memory, then delete all objects in the map
std::map<Key, Value*>::const_iterator iter = begin();
while(iter != end())
{
delete (iter->second);
++iter;
}
}
| __inline bool ManagedDictionary< Key, Value >::getManaged | ( | ) | const [inline] |
Definition at line 69 of file ManagedDictionary.h.
| __inline void ManagedDictionary< Key, Value >::setManaged | ( | bool | val | ) | [inline] |
Definition at line 70 of file ManagedDictionary.h.
bool ManagedDictionary< Key, Value >::_manageMemory [protected] |
Definition at line 20 of file ManagedDictionary.h.
Referenced by ManagedDictionary< std::string, StopwatchAccumulator >::~ManagedDictionary().
Copyright © 2007-2010 by The Shadowrun: Awakened Team. This work is licensed under the GNU Lesser General Public License 3.