MFMv2.0.10
Movable Feast Machine Simulator 2.0.10
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Data Structures | Public Member Functions | Static Public Attributes
MFM::ElementTable< CC > Class Template Reference

Public Member Functions

void Reinit ()
 
void Insert (const Element< CC > &theElement)
 
u32 GetSize () const
 
s32 GetIndex (u32 elementType) const
 
 ElementTable ()
 
 ~ElementTable ()
 
const Element< CC > * Lookup (u32 elementType) const
 
void Execute (EventWindow< CC > &window)
 
bool RegisterElement (const Element< CC > &e)
 
bool AllocateElementDataSlots (const Element< CC > &e, u32 slots)
 
bool AllocateElementDataSlotsFromType (const u32 elementType, u32 slots)
 
u64 * GetElementDataSlots (const Element< CC > &e, const u32 slots)
 
u64 * GetElementDataSlotsFromType (const u32 elementType, const u32 slots)
 
u64 * GetDataAndRegister (const u32 elementType, u32 slots)
 
u64 * GetDataIfRegistered (const u32 elementType, u32 slots)
 

Static Public Attributes

static const u32 SIZE = (1u<<B) - 3
 

Constructor & Destructor Documentation

template<class CC >
MFM::ElementTable< CC >::ElementTable ( )

Constructs and calls Reinit() on a new new ElementTable.

template<class CC>
MFM::ElementTable< CC >::~ElementTable ( )
inline

Deconstructs this ElementTable.

Member Function Documentation

template<class CC >
bool MFM::ElementTable< CC >::AllocateElementDataSlots ( const Element< CC > &  e,
u32  slots 
)

Allocate SLOTS u64's of element-specific data associated with element E.

Returns false if:

  • E is an unregistered element
  • E is a registered element but has already had a different number of element-specific data slots allocated for it
  • E is a registered element with no priori element-specific data allocation, but less than SLOTS of room for element-specific data remain in this ElementTable.

Returns true otherwise, specifically, if:

  • E is a registered element that already has precisely SLOTS of element-specific data allocated for it, or
  • E is a registered element that previously had no element-specific data but now has SLOTS of element-specific data allocated for it, as a result of this call.

In the case of a true return, note that the resulting slots have no particular values.

template<class CC >
void MFM::ElementTable< CC >::Execute ( EventWindow< CC > &  window)

Executes the behavior method of the Element in the center of a specified EventWindow. This method finds the central Element by the type of the Atom located there, then executes its behavior.

Parameters
windowThe EventWindow to execute an event upon.
template<class CC >
u64 * MFM::ElementTable< CC >::GetElementDataSlots ( const Element< CC > &  e,
const u32  slots 
)

Access the SLOTS u64's of element-specific data associated with element E, if it exists. Returns a pointer to the first (0th) slot, or 0.

Returns 0 if:

  • E is an unregistered element,
  • E is a registered element that has no element-specific data associated with it, or
  • E is a registered element that has more or less than SLOTS of element-specific data associated with it.
template<class CC >
s32 MFM::ElementTable< CC >::GetIndex ( u32  elementType) const

Return -1 if elementType is not stored in this table, otherwise return a number from 0.. GetSize()-1 representing the location of this elementType in this table. Gets the index of this ElementTable where a particular Element (described by a specified type) resides.

Parameters
elementTypeThe type of the Element of which to look up an index for.
Returns
The index of this ElementTable where the Element of type elementType resides, or -1 if elementType is not found in the table.
template<class CC>
u32 MFM::ElementTable< CC >::GetSize ( ) const
inline

Gets the capacity of this ElementTable, in Elements that may be registered.

template<class CC >
void MFM::ElementTable< CC >::Insert ( const Element< CC > &  theElement)

Registers an Element into this ElementTable, allowing Elements of a specified type to exist and act inside a Tile .

Parameters
theElementThe Element to insert into this ElementTable .
template<class CC >
const Element< CC > * MFM::ElementTable< CC >::Lookup ( u32  elementType) const

Gets a pointer to an immutable Element which is stored in this ElementTable by providing a type.

Parameters
elementTypethe type of the Element which will be found in this Table.
Returns
A pointer to an immutable Element which is stored in this table. If an Element with this type is not found in this ElementTable, will return NULL .
template<class CC >
bool MFM::ElementTable< CC >::RegisterElement ( const Element< CC > &  e)

Inserts an Element into this ElementTable.

Parameters
eThe Element to insert into this ElementTable.
Returns
true .
template<class CC >
void MFM::ElementTable< CC >::Reinit ( )

Reinitialize this ElementTable to empty.


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