Isle
Loading...
Searching...
No Matches
MxVariableTable Class Reference

MxVariableTable is a specialized hash table for storing key/value string variables used by the LEGO Island engine. More...

#include <mxvariabletable.h>

Inheritance diagram for MxVariableTable:
Collaboration diagram for MxVariableTable:

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...
 
- Public Member Functions inherited from MxHashTable< MxVariable * >
 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

- Public Types inherited from MxHashTable< MxVariable * >
enum  Option
 [AI] Enum describing the strategy for resizing the hash table when load increases. More...
 
- Public Attributes inherited from MxHashTable< MxVariable * >
MxU32 m_increaseAmount
 
double m_increaseFactor
 
- Protected Member Functions inherited from MxHashTable< MxVariable * >
void NodeInsert (MxHashTableNode< MxVariable * > *)
 [AI] Inserts a given node into the relevant hash bucket according to the node's hash value. More...
 
- Protected Member Functions inherited from MxCollection< T >
 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...
 
- Protected Member Functions inherited from MxCore
 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 Protected Member Functions inherited from MxCollection< T >
static void Destroy (T obj)
 [AI] Static no-op destroy function; suitable for types that do not need destruction. More...
 
- Protected Attributes inherited from MxHashTable< MxVariable * >
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...
 
- Protected Attributes inherited from MxCollection< T >
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...
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ MxVariableTable()

MxVariableTable::MxVariableTable ( )
inline

Constructs an MxVariableTable and sets up the element destroy function.

[AI]

Definition at line 25 of file mxvariabletable.h.

Member Function Documentation

◆ Compare()

MxS8 MxVariableTable::Compare ( MxVariable p_var0,
MxVariable p_var1 
)
override

Implements the virtual table comparison for two MxVariable pointers.

[AI]

Parameters
[in][AI]First MxVariable pointer.
[in][AI]Second MxVariable pointer.
Returns
MxS8 Result of the comparison: usually <0, 0, >0 as per standard compare.

[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.

◆ Destroy()

static void MxVariableTable::Destroy ( MxVariable p_obj)
inlinestatic

Destroys an instance of MxVariable, calling its Destroy method.

[AI]

Parameters
p_objPointer 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.

◆ GetVariable()

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]

Parameters
p_keyKey to look up. [AI]
Returns
const char* Value string of the variable, or "" if the key is not defined. [AI]

[AI] Ownership of the returned string remains with the table, do not free.

Definition at line 56 of file mxvariabletable.cpp.

◆ Hash()

MxU32 MxVariableTable::Hash ( MxVariable p_var)
overridevirtual

Hashes the key of the given variable for use in the table.

[AI]

Parameters
[in][AI]Pointer to MxVariable to hash.
Returns
MxU32 The calculated hash value based on its key. [AI]

[AI] Sums the ASCII values of all characters in the key string.

Reimplemented from MxHashTable< MxVariable * >.

Definition at line 12 of file mxvariabletable.cpp.

◆ SetVariable() [1/2]

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]

Parameters
p_keyVariable key. [AI]
p_valueVariable 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.

◆ SetVariable() [2/2]

void MxVariableTable::SetVariable ( MxVariable p_var)

Sets the given MxVariable pointer in the table, deleting any existing entry with the same key.

[AI]

Parameters
p_varPointer 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.


The documentation for this class was generated from the following files: