Isle
|
Template container associating string names with object pointers, optional lifetime management. More...
#include <legocontainer.h>
Public Member Functions | |
LegoContainer () | |
Default constructor, sets this container to own its elements. More... | |
virtual | ~LegoContainer () |
Destructor. More... | |
void | Clear () |
Remove and delete all mapped objects; preserves key strings. More... | |
T * | Get (const char *p_name) |
Retrieve the element mapped to the given name, or nullptr if missing. More... | |
void | Add (const char *p_name, T *p_value) |
Add an element mapped to the given name, replacing existing item if present. More... | |
void | SetOwnership (LegoBool p_ownership) |
Set whether this container owns/deletes its objects (and name strings) on removal/destruction. More... | |
Protected Attributes | |
LegoBool | m_ownership |
If TRUE, container owns objects and keys; else no cleanup on destruction. [AI]. More... | |
LegoContainerInfo< T > | m_map |
Underlying map from name strings to objects. [AI]. More... | |
Template container associating string names with object pointers, optional lifetime management.
[AI]
T | Object type, used as pointer. [AI] |
[AI] Manages a mapping from names (C-strings) to pointers to objects of type T. Supports adding, retrieving, and clearing objects, and can optionally manage the deletion of both key strings and mapped objects depending on m_ownership. Used for centrally managing game resources by name. [AI]
Definition at line 40 of file legocontainer.h.
|
inline |
Default constructor, sets this container to own its elements.
[AI]
[AI] By default, the container will delete objects and name strings when destroyed. [AI]
Definition at line 46 of file legocontainer.h.
|
inlinevirtual |
Destructor.
Cleans up all key strings and objects depending on ownership flag. [AI]
[AI] Iterates map and deletes both key string and object pointer. [AI]
Definition at line 52 of file legocontainer.h.
|
inline |
Add an element mapped to the given name, replacing existing item if present.
[AI]
p_name | Name to map. Will be allocated/copied if new. [AI] |
p_value | Pointer to object to store. [AI] |
[AI] If the key exists, the old object is deleted (if ownership is set). Key strings are managed by this container and freed in the destructor. [AI]
Definition at line 115 of file legocontainer.h.
|
inline |
Remove and delete all mapped objects; preserves key strings.
[AI]
[AI] Iterates through the map, deleting objects (but not C-string keys) from memory. [AI]
Definition at line 74 of file legocontainer.h.
|
inline |
Retrieve the element mapped to the given name, or nullptr if missing.
[AI]
p_name | Name of the element (C-string). [AI] |
[AI] Looks up the map for the name (using comparator). [AI]
Definition at line 92 of file legocontainer.h.
|
inline |
Set whether this container owns/deletes its objects (and name strings) on removal/destruction.
[AI]
p_ownership | If TRUE, container owns the memory and is responsible for cleanup. [AI] |
Definition at line 143 of file legocontainer.h.
|
protected |
Underlying map from name strings to objects. [AI].
Definition at line 147 of file legocontainer.h.
|
protected |
If TRUE, container owns objects and keys; else no cleanup on destruction. [AI].
Definition at line 146 of file legocontainer.h.