Isle
|
MxVariableTable is a specialized hash table for storing key/value string variables used by the LEGO Island engine. More...
#include <mxvariabletable.h>
Public Member Functions | |
MxVariableTable () | |
Constructs an MxVariableTable and sets up the element destroy function. More... | |
void | SetVariable (const char *p_key, const char *p_value) |
Sets a variable by key and value, replacing or updating if it exists. More... | |
void | SetVariable (MxVariable *p_var) |
Sets the given MxVariable pointer in the table, deleting any existing entry with the same key. More... | |
const char * | GetVariable (const char *p_key) |
Returns the value for the variable with a given key, or an empty string if not found. More... | |
MxS8 | Compare (MxVariable *, MxVariable *) override |
Implements the virtual table comparison for two MxVariable pointers. More... | |
MxU32 | Hash (MxVariable *) override |
Hashes the key of the given variable for use in the table. More... | |
![]() | |
MxHashTable () | |
[AI] Default constructor. More... | |
~MxHashTable () override | |
[AI] Destructor. More... | |
void | Resize () |
[AI] Expand/recreates the hash table according to the current resizing policy. More... | |
void | Add (MxVariable *) |
[AI] Inserts a new item into the hash table, possibly resizing if automatic resize is enabled and load threshold is exceeded. More... | |
void | DeleteAll () |
[AI] Removes and destructs all nodes in all hash buckets, clearing the table. More... | |
virtual MxU32 | Hash (MxVariable *) |
[AI] Computes the hash of the given object. More... | |
Static Public Member Functions | |
static void | Destroy (MxVariable *p_obj) |
Destroys an instance of MxVariable, calling its Destroy method. More... | |
Additional Inherited Members | |
![]() | |
enum | Option |
[AI] Enum describing the strategy for resizing the hash table when load increases. More... | |
![]() | |
MxU32 | m_increaseAmount |
double | m_increaseFactor |
![]() | |
void | NodeInsert (MxHashTableNode< MxVariable * > *) |
[AI] Inserts a given node into the relevant hash bucket according to the node's hash value. More... | |
![]() | |
MxCollection () | |
[AI] Constructs an empty collection, initializing count and default element destructor. More... | |
virtual MxS8 | Compare (T a, T b) |
[AI] Compares two elements of the collection (default implementation returns zero; override in subclasses for meaningful comparison). More... | |
~MxCollection () override | |
[AI] Virtual destructor for proper polymorphic destruction. More... | |
void | SetDestroy (void(*p_customDestructor)(T)) |
[AI] Assigns a custom destructor function to be used for elements of this collection. More... | |
![]() | |
MxCore () | |
[AI] Constructs a new MxCore object and assigns it a unique id. More... | |
virtual | ~MxCore () |
[AI] Virtual destructor. Required for correct polymorphic cleanup in derived classes. More... | |
virtual MxLong | Notify (MxParam &p_param) |
[AI] Virtual callback notification mechanism. More... | |
virtual MxResult | Tickle () |
[AI] Called by tickle managers to allow the object to update itself. More... | |
virtual const char * | ClassName () const |
[AI] Returns the runtime class name of this object. More... | |
virtual MxBool | IsA (const char *p_name) const |
[AI] Checks whether this object's class type or parents match the given name. More... | |
MxU32 | GetId () |
[AI] Gets the unique (per-process) id assigned to this object instance. More... | |
![]() | |
static void | Destroy (T obj) |
[AI] Static no-op destroy function; suitable for types that do not need destruction. More... | |
![]() | |
MxHashTableNode< MxVariable * > ** | m_slots |
[AI] Array of pointers to bucket heads; each slot is a chain of nodes (linked list) holding objects with equal (modulo table size) hashes. More... | |
MxU32 | m_numSlots |
[AI] Number of hash buckets in the table; controls how hash values are mapped to buckets. More... | |
MxU32 | m_autoResizeRatio |
[AI] Ratio at which the table will auto-resize (load factor denominator). More... | |
Option | m_resizeOption |
[AI] Strategy currently in use for resizing the table when needed. More... | |
union { | |
MxU32 m_increaseAmount | |
double m_increaseFactor | |
}; | |
[AI] Union holding the setting for table expansion: More... | |
![]() | |
MxU32 | m_count |
[AI] Number of elements currently stored in the collection. More... | |
void(* | m_customDestructor )(T) |
[AI] Function pointer to the custom element destructor used for cleanup of elements. More... | |
MxVariableTable is a specialized hash table for storing key/value string variables used by the LEGO Island engine.
[AI] Forward declaration for the global variable table (string/string), often used in scripting logic.
[AI]
[AI] MxVariableTable manages a table of MxVariable pointers, each storing a string key and a string value. It provides methods to set and get variables by key, and uses custom hash and comparison functions for efficient lookups. The engine uses this system as the "variable table" found on MxOmni and scripting components, usually for storing game, script or global state variables at runtime.
Definition at line 20 of file mxvariabletable.h.
|
inline |
Constructs an MxVariableTable and sets up the element destroy function.
[AI]
Definition at line 25 of file mxvariabletable.h.
|
override |
Implements the virtual table comparison for two MxVariable pointers.
[AI]
[in] | [AI] | First MxVariable pointer. |
[in] | [AI] | Second MxVariable pointer. |
[AI] Compares the key strings via MxString::Compare. Used to determine equality or ordering in the hash table.
Definition at line 5 of file mxvariabletable.cpp.
|
inlinestatic |
Destroys an instance of MxVariable, calling its Destroy method.
[AI]
p_obj | Pointer to the MxVariable to destroy. [AI] |
[AI] Used by the hash table to clean up elements automatically on removal or destruction. Note: This does not delete p_obj itself; the object should be deleted separately as needed.
Definition at line 56 of file mxvariabletable.h.
const char * MxVariableTable::GetVariable | ( | const char * | p_key | ) |
Returns the value for the variable with a given key, or an empty string if not found.
[AI]
p_key | Key to look up. [AI] |
[AI] Ownership of the returned string remains with the table, do not free.
Definition at line 56 of file mxvariabletable.cpp.
|
overridevirtual |
Hashes the key of the given variable for use in the table.
[AI]
[in] | [AI] | Pointer to MxVariable to hash. |
[AI] Sums the ASCII values of all characters in the key string.
Reimplemented from MxHashTable< MxVariable * >.
Definition at line 12 of file mxvariabletable.cpp.
void MxVariableTable::SetVariable | ( | const char * | p_key, |
const char * | p_value | ||
) |
Sets a variable by key and value, replacing or updating if it exists.
[AI]
p_key | Variable key. [AI] |
p_value | Variable value. [AI] |
[AI] If a variable with the specified key already exists, its value will be replaced. Otherwise, a new variable entry is created and inserted.
Definition at line 26 of file mxvariabletable.cpp.
void MxVariableTable::SetVariable | ( | MxVariable * | p_var | ) |
Sets the given MxVariable pointer in the table, deleting any existing entry with the same key.
[AI]
p_var | Pointer to an MxVariable object to be inserted or replaced in the table. [AI] |
[AI] If a variable with the same key already exists, it will be removed and deleted. The new variable is then inserted.
Definition at line 43 of file mxvariabletable.cpp.