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

#include <Element.h>

Inheritance diagram for MFM::Element< CC >:
MFM::AbstractElement_ForkBomb< CC > MFM::AbstractElement_Reprovert< CC > MFM::AbstractElement_Wanderer< CC > MFM::AbstractElement_WaPat< CC > MFM::AbstractElement_Xtal< CC > MFM::Element_AntiForkBomb< CC > MFM::Element_Bar< CC > MFM::Element_Block< CC > MFM::Element_Boids< CC > MFM::Element_CheckerForkBlue< CC > MFM::Element_CheckerForkRed< CC > MFM::Element_Collector< CC > MFM::Element_Creg< CC > MFM::Element_Data< CC > MFM::Element_DBar< CC > MFM::Element_Dmover< CC > MFM::Element_Dreg< CC > MFM::Element_Empty< CC > MFM::Element_Indexed< CC > MFM::Element_Mover< CC > MFM::Element_Mover< CC > MFM::Element_MQBar< CC > MFM::Element_MQBar< CC > MFM::Element_QBar< CC > MFM::Element_Res< CC > MFM::Element_Rocket< CC > MFM::Element_SBar< CC > MFM::Element_Sorter< CC > MFM::Element_Template< CC > MFM::Element_Wall< CC >

Public Member Functions

 Element (const UUID &uuid)
 
void AllocateType ()
 
u32 GetType () const
 
const char * GetAtomicSymbol () const
 
const char * GetName () const
 
virtual void AppendDescription (const T *atom, OString64 &desc) const
 
bool IsType (u32 type) const
 
const UUIDGetUUID () const
 
virtual void Behavior (EventWindow< CC > &window) const =0
 
virtual const T & GetDefaultAtom () const
 
virtual u32 PhysicsColor () const
 
virtual const char * GetDescription () const
 
virtual u32 DefaultPhysicsColor () const =0
 
virtual u32 DefaultLowlightColor () const
 
void ToggleLowlightPhysicsColor ()
 
virtual u32 LocalPhysicsColor (const T &atom, u32 selector) const
 
virtual u32 Diffusability (EventWindow< CC > &ew, SPoint nowAt, SPoint maybeAt) const
 
u32 NoDiffusability (EventWindow< CC > &ew, SPoint nowAt, SPoint maybeAt) const
 
const ElementParameters< CC > & GetElementParameters () const
 
ElementParameters< CC > & GetElementParameters ()
 
const AtomicParameters< CC > & GetAtomicParameters () const
 
AtomicParameters< CC > & GetAtomicParameters ()
 

Static Public Attributes

static const u32 COMPLETE_DIFFUSABILITY = 1000
 

Protected Member Functions

virtual T BuildDefaultAtom () const
 
const BitVector
< P::BITS_PER_ATOM > & 
GetBits (const T &atom) const
 
BitVector< P::BITS_PER_ATOM > & GetBits (T &atom) const
 
bool IsValidAtomicSymbol (const char *symbol)
 
void SetAtomicSymbol (const char *symbol)
 
void SetName (const char *name)
 
void Diffuse (EventWindow< CC > &window) const
 
virtual u32 PercentMovable (const T &you, const T &me, const SPoint &offset) const =0
 

Detailed Description

template<class CC>
class MFM::Element< CC >

An Element describes how a given type of Atom behaves.

Constructor & Destructor Documentation

template<class CC>
MFM::Element< CC >::Element ( const UUID uuid)
inline

Constructs a new Element with a given UUID .

Parameters
uuidThe UUID of this Element, used for various operations. It is vital that this UUID be unique, but this constructor does not check for that.

Member Function Documentation

template<class CC>
void MFM::Element< CC >::AllocateType ( )
inline

Assigns the type of this Element using the U16StaticLoader . This type is only assigned if it has not been assigned already. Once this type has been allocated, the default Atom of this Element is constructed and an Atom of this Element may be placed.

See Also
StaticLoader;
template<class CC>
virtual void MFM::Element< CC >::AppendDescription ( const T *  atom,
OString64 desc 
) const
inlinevirtual

Appends a short description of the data held by an Atom of this Element.

Parameters
atomA pointer to an Atom (guaranteed to be an instance of this Element ) to append a description of.
descThe OverflowabeleCharBufferByteSink to append the description to.

Reimplemented in MFM::Element_Sorter< CC >, and MFM::Element_Data< CC >.

template<class CC>
virtual void MFM::Element< CC >::Behavior ( EventWindow< CC > &  window) const
pure virtual
template<class CC>
virtual T MFM::Element< CC >::BuildDefaultAtom ( ) const
inlineprotectedvirtual

Describes how the default Atom of this Element should be constructed. The default behavior of this method builds an atom with the type of this Element and otherwise empty fields.

Returns
The default Atom of this Element, to be stored in m_defaultAtom .

Reimplemented in MFM::Element_MQBar< CC >, MFM::Element_MQBar< CC >, MFM::Element_Emitter< CC >, and MFM::Element_Consumer< CC >.

template<class CC>
virtual u32 MFM::Element< CC >::DefaultLowlightColor ( ) const
inlinevirtual
template<class CC>
virtual u32 MFM::Element< CC >::DefaultPhysicsColor ( ) const
pure virtual
template<class CC>
virtual u32 MFM::Element< CC >::Diffusability ( EventWindow< CC > &  ew,
SPoint  nowAt,
SPoint  maybeAt 
) const
inlinevirtual

On entry, the Atom at nowAt will be an instance of the type of this Element. How much does that atom like the idea that it should be moved to (or remain at; the two SPoints might be equal) location maybeAt? Return 0 to flat-out veto the idea, or from 0 up to COMPLETE_DIFFUSABILITY to request that fraction of diffusability. (Values larger than COMPLETE_DIFFUSABILITY are treated as equal to it.) Note that nowAt and maybeAt are both relative to the EventWindow ew, but neither is necessarily the center atom!

By default all atoms are considered diffusable, and they return COMPLETE_DIFFUSABILITY chances for every suggested move

Reimplemented in MFM::Element_MQBar< CC >, MFM::Element_QBar< CC >, MFM::Element_DBar< CC >, MFM::Element_MQBar< CC >, MFM::Element_SBar< CC >, MFM::Element_Shark< CC >, MFM::AbstractElement_Xtal< CC >, MFM::AbstractElement_Reprovert< CC >, MFM::Element_Fish< CC >, MFM::Element_Rocket< CC >, MFM::Element_Wall< CC >, and MFM::Element_Block< CC >.

template<class CC>
void MFM::Element< CC >::Diffuse ( EventWindow< CC > &  window) const
protected

Diffuses the central Atom of a given EventWindow based on the empty places around the Atom and the odds that the central Atom can be diffused.

Parameters
windowThe EventWindow of which the central Atom should attempt to be diffused.
template<class CC>
const char* MFM::Element< CC >::GetAtomicSymbol ( ) const
inline

Gets the Atomic Symbol of this Element . If this has not been set, the default Atomic Symbol is the invalid symbol "!!" .

Returns
The Atomic Symbol of this Element .
template<class CC>
const BitVector<P::BITS_PER_ATOM>& MFM::Element< CC >::GetBits ( const T &  atom) const
inlineprotected

Retrieves the read-only BitVector held inside a specified Atom .

Parameters
atomThe Atom to retrieve the held BitVector from.
Returns
The BitVector held inside atom .
template<class CC>
BitVector<P::BITS_PER_ATOM>& MFM::Element< CC >::GetBits ( T &  atom) const
inlineprotected

Retrieves the writable BitVector held inside a specified Atom .

Parameters
atomThe Atom to retrieve the held BitVector from.
Returns
The BitVector held inside atom .
template<class CC>
virtual const T& MFM::Element< CC >::GetDefaultAtom ( ) const
inlinevirtual

Gets the default Atom of this Element . If this Element has not been assigned a type through AllocateType() , this will FAIL with ILLEGAL_STATE. NOTE: The defaultAtom returned here will have been constructed by Element::BuildDefaultAtom, which leaves all state bits zero. If this is not desirable, element subclasses should override this to provide their own default atom initialization.

Returns
The default Atom of this Element.
See Also
BuildDefaultAtom

Reimplemented in MFM::Element_QBar< CC >, MFM::Element_MQBar< CC >, MFM::Element_DBar< CC >, MFM::Element_SBar< CC >, MFM::Element_MQBar< CC >, MFM::Element_Bar< CC >, MFM::Element_Indexed< CC >, MFM::Element_Sorter< CC >, MFM::Element_Data< CC >, MFM::Element_Shark< CC >, MFM::Element_Fish< CC >, MFM::Element_Rocket< CC >, MFM::Element_Xtal_General< CC >, MFM::Element_Block< CC >, MFM::Element_Wall< CC >, MFM::Element_Mover< CC >, MFM::Element_Mover< CC >, MFM::Element_Collector< CC >, MFM::Element_Boids1< CC >, and MFM::Element_Boids2< CC >.

template<class CC>
virtual const char* MFM::Element< CC >::GetDescription ( ) const
inlinevirtual

Gets a string of a short description of the behavior of this Element . This will be displayed in some way when a user needs help with this Element . This string must not include newlines; they will be added when they are needed.

Returns
A helpful description string breifely describing the behavior of this Element.

Reimplemented in MFM::Element_Data< CC >, MFM::Element_Sorter< CC >, MFM::Element_Consumer< CC >, MFM::Element_Indexed< CC >, MFM::Element_Template< CC >, MFM::Element_Dmover< CC >, MFM::Element_Dreg< CC >, MFM::Element_Emitter< CC >, MFM::Element_Creg< CC >, MFM::Element_Res< CC >, MFM::Element_Wall< CC >, MFM::Element_CheckerForkBlue< CC >, MFM::Element_CheckerForkRed< CC >, and MFM::Element_Empty< CC >.

template<class CC>
const char* MFM::Element< CC >::GetName ( ) const
inline

Gets the English name of this Element , which is normally used for display purposes. The default is the string "UNNAMED" .

Returns
The English name of this Element .
template<class CC>
u32 MFM::Element< CC >::GetType ( ) const
inline

Gets the unique type of this Element . If the type has not been assigned yet (by using AllocateType() ), this will FAIL with ILLEGAL_STATE .

Returns
The unique type of this Element .
template<class CC>
const UUID& MFM::Element< CC >::GetUUID ( ) const
inline

Gets the UUID of this Element .

Returns
The UUID of this Element.
template<class CC>
bool MFM::Element< CC >::IsType ( u32  type) const
inline

Checks to see if this Element is of a specified type.

Parameters
typeThe type of which to check against they type of this Element.
Returns
true if this Element is of type type, else false.
template<class CC>
bool MFM::Element< CC >::IsValidAtomicSymbol ( const char *  symbol)
inlineprotected

Checks to see if a specified Atomic Symbol is a valid symbol. A valid symbol must be either a single capital letter, or a capital letter followed by a single lowercase letter.

Parameters
symbolThe string to check symbolic validity of.
Returns
true If symbol is a valid atomic symbol, else false .
template<class CC>
virtual u32 MFM::Element< CC >::LocalPhysicsColor ( const T &  atom,
u32  selector 
) const
inlinevirtual

Used during rendering, will select a color for any Atom of this Element to be rendered with. This should be overridden if wanting to use a gradient or some other variable color based on the body of the specified Atom .

Parameters
atomThe Atom of this element of which to find a color for.
selectorAn additional argument which may be used to determine the color of which to render atom
Returns
The 32-bit ARGB color of which to render atom with.

Reimplemented in MFM::Element_MQBar< CC >, MFM::Element_QBar< CC >, MFM::Element_DBar< CC >, MFM::Element_SBar< CC >, MFM::Element_MQBar< CC >, MFM::Element_Bar< CC >, MFM::Element_Sorter< CC >, MFM::Element_Data< CC >, MFM::Element_Xtal_General< CC >, MFM::Element_AntiForkBomb< CC >, MFM::Element_Indexed< CC >, MFM::Element_ForkBomb3< CC >, MFM::Element_ForkBomb1< CC >, MFM::Element_ForkBomb2< CC >, MFM::Element_Xtal_L12< CC >, MFM::Element_Xtal_Sq1< CC >, and MFM::AbstractElement_ForkBomb< CC >.

template<class CC>
u32 MFM::Element< CC >::NoDiffusability ( EventWindow< CC > &  ew,
SPoint  nowAt,
SPoint  maybeAt 
) const
inline

A utility method available to subclasses that specifies no diffusion is allowed, by specifying a 0 value for the Diffusability of every position except when nowAt == maybeAt.

template<class CC>
virtual u32 MFM::Element< CC >::PercentMovable ( const T &  you,
const T &  me,
const SPoint offset 
) const
protectedpure virtual
template<class CC>
virtual u32 MFM::Element< CC >::PhysicsColor ( ) const
inlinevirtual

Gets the current 32-bit ARGB color which this all Atoms of this Element should be rendered with.

Parameters
Theselected current 32-bit ARGB color which is suggested to render any Atom of this Element with.
template<class CC>
void MFM::Element< CC >::SetAtomicSymbol ( const char *  symbol)
inlineprotected

Sets the Atomic Symbol of this Element, which is mainly used during the rendering of this Element .

Parameters
symbolThe string representing the Atomic Symbol of this Element. If this symbol is not valid (in terms of the IsValidAtomicSymbol() method), this will FAIL with ILLEGAL_ARGUMENT .
template<class CC>
void MFM::Element< CC >::SetName ( const char *  name)
inlineprotected

Sets the English name of this Element which is used for inspection purposes.

Parameters
nameThe new English name of this Element .
template<class CC>
void MFM::Element< CC >::ToggleLowlightPhysicsColor ( )
inline

Toggles the lowlight / normal rendering of all Atoms of this Element.

Field Documentation

template<class CC>
const u32 MFM::Element< CC >::COMPLETE_DIFFUSABILITY = 1000
static

A standard basis for specifying degrees of diffusability.


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