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 | Protected Types | Protected Member Functions | Protected Attributes | Static Protected Attributes
MFM::AbstractDriver< GC > Class Template Referenceabstract

#include <AbstractDriver.h>

Inheritance diagram for MFM::AbstractDriver< GC >:
MFM::AbstractGUIDriver< GC > MFM::AbstractHeadlessDriver< GC >

Public Member Functions

void AutosaveGrid (u32 epochs)
 
void SaveGrid (const char *filename)
 
void LoadFromConfigurationPath ()
 
const char * GetSimDirPathTemporary (const char *format,...) const
 
void ReloadCurrentConfigurationPath ()
 
virtual void DoEpochEvents (OurGrid &grid, u32 epochs, u32 epochAEPS)
 
void Init (u32 argc, const char **argv)
 
VArgumentsGetVArguments ()
 
void RegisterArgument (const char *description, const char *filter, VArgumentHandleValue func, void *handlerArg, bool runFunc)
 
void RegisterSection (const char *sectionLabel)
 
virtual void AddDriverArguments ()
 
virtual void ReinitUs ()
 
u32 GetHaltAfterAEPS ()
 
double GetAEPS ()
 
double GetAER ()
 
void SetAER (double aer)
 
double GetRecentAER ()
 
void SetRecentAER (double aer)
 
u32 GetAEPSPerFrame ()
 
double GetOverheadPercent ()
 
OurGridGetGrid ()
 
void SetSeed (u32 seed)
 
void Reinit ()
 
void Run ()
 

Protected Types

enum  { W = GC::GRID_WIDTH }
 
enum  { H = GC::GRID_HEIGHT }
 
enum  { R = P::EVENT_WINDOW_RADIUS }
 
typedef GC::CORE_CONFIG CC
 
typedef CC::PARAM_CONFIG P
 
typedef CC::ATOM_TYPE T
 
typedef ElementRegistry< CCOurElementRegistry
 
typedef StdElements< CCOurStdElements
 
typedef Grid< GC > OurGrid
 
typedef ElementTable< CCOurElementTable
 

Protected Member Functions

void NeedElement (Element< CC > *element)
 
void WriteTimeBasedData (FileByteSink &fp, bool exists)
 
void SetIgnoreThreadingProblems (bool value)
 
void WriteTimeBasedData ()
 
void UpdateGrid (OurGrid &grid)
 
void DecrementAEPSPerFrame (u32 amount)
 
void IncrementAEPSPerFrame (u32 amount)
 
virtual void PostReinit (VArguments &args)
 
virtual void ReinitEden ()=0
 
void ReinitPhysics ()
 
virtual void PostReinitPhysics ()
 
virtual void DefineNeededElements ()=0
 
virtual void PostUpdate ()
 
virtual void OnceOnly (VArguments &args)
 
virtual void RunHelper ()
 
void SetAEPSPerEpoch (u32 aeps)
 
u32 GetAEPSPerEpoch () const
 

Protected Attributes

Element< CC > * m_neededElements [MAX_NEEDED_ELEMENTS]
 
u32 m_neededElementCount
 

Static Protected Attributes

static const u32 EVENT_WINDOW_RADIUS = R
 
static const u32 GRID_WIDTH = W
 
static const u32 GRID_HEIGHT = H
 

Detailed Description

template<class GC>
class MFM::AbstractDriver< GC >

An abstract driver from which all MFM drivers should inherit. This should be the highest level structure and contain just about everything needed to run a successful simulation.

Member Typedef Documentation

template<class GC>
typedef GC::CORE_CONFIG MFM::AbstractDriver< GC >::CC
protected

The CoreConfig used to describe templated pieces of the core components.

template<class GC>
typedef ElementRegistry<CC> MFM::AbstractDriver< GC >::OurElementRegistry
protected

Template shortcut for an ElementRegistry with the correct template parameters.

template<class GC>
typedef ElementTable<CC> MFM::AbstractDriver< GC >::OurElementTable
protected

Template shortcut for an ElementTable with the correct template parameters.

template<class GC>
typedef Grid<GC> MFM::AbstractDriver< GC >::OurGrid
protected

Template shortcut for a Grid with the correct template parameters.

template<class GC>
typedef StdElements<CC> MFM::AbstractDriver< GC >::OurStdElements
protected

Template shortcut for an instance of StdElements with the correct template parameters.

template<class GC>
typedef CC::PARAM_CONFIG MFM::AbstractDriver< GC >::P
protected

The ParamConfig used to configure several templated pieces of the core components.

template<class GC>
typedef CC::ATOM_TYPE MFM::AbstractDriver< GC >::T
protected

The type of every Atom used in this simulation.

Member Enumeration Documentation

template<class GC>
anonymous enum
protected

Exported from the GridConfiguration, the enumerated width of the Grid used by this simulation.

template<class GC>
anonymous enum
protected

Exported from the GridConfiguration, the enumerated height of the Grid used by this simulation.

template<class GC>
anonymous enum
protected

Exported from the GridConfiguration, the enumerated size of every EventWindow used by this simulation.

Member Function Documentation

template<class GC>
virtual void MFM::AbstractDriver< GC >::AddDriverArguments ( )
inlinevirtual

Adds any command-line arguments desired, by calling #RegisterArgument with appropriate arguments. Note: (Sub-)subclasses of AbstractDriver should always override this method, even if they do not wish to add command-line arguments, and begin their overriding method with Super::AddDriverArguments(). Such chaining lets all levels of abstraction define command-line arguments, with the most abstract going first.

Reimplemented in MFM::AbstractGUIDriver< GC >, MFM::AbstractGUIDriver< OurGridConfig >, MFM::MFMSimSBarDemo, MFM::AbstractHeadlessDriver< GC >, MFM::MFMSimQBDemo, MFM::MFMSimDHSDemo, and MFM::MFMSimDHSDemo.

template<class GC>
void MFM::AbstractDriver< GC >::DecrementAEPSPerFrame ( u32  amount)
inlineprotected

Subtracts m_aepsPerFrame (or, the number of AEPS which should elapse every call to UpdateGrid() ) by one, keeping it above 0 at all times.

Parameters
amountThe amount of AEPS per frame to decrement by.
template<class GC>
virtual void MFM::AbstractDriver< GC >::DefineNeededElements ( )
protectedpure virtual

To be defined by the top level driver only. This allows all Elements to be known by this AbstractDriver before they are inserted into its sub-drivers .

Implemented in MFM::MFMSimSBarDemo, MFM::MFMSimQBDemo, MFM::MFMSimDHSDemo, and MFM::MFMSimDHSDemo.

template<class GC>
virtual void MFM::AbstractDriver< GC >::DoEpochEvents ( OurGrid grid,
u32  epochs,
u32  epochAEPS 
)
inlinevirtual

Method to do end-of-epoch processing. Base class recounts the grid and handles –gridImage and –tileImage processing here, so all subclasses should override this method and do Super::DoEpochEvents to ensure all methods are called.

Reimplemented in MFM::AbstractGUIDriver< GC >, and MFM::AbstractGUIDriver< OurGridConfig >.

template<class GC>
const char* MFM::AbstractDriver< GC >::GetSimDirPathTemporary ( const char *  format,
  ... 
) const
inline

Gets a formatted string representing a working path to the assets directory of this simulation. This is where the local copy of the res/ directory is kept and should be used for finding any assets in that location.

Parameters
formatThe formatting string used to parse the arguments that follow it into a reasonable format.
Returns
format , with the location of the local resources directory prepended to it.
template<class GC>
void MFM::AbstractDriver< GC >::IncrementAEPSPerFrame ( u32  amount)
inlineprotected

Adds one to m_aepsPerFrame (or, the number of AEPS which should elapse every call to UpdateGrid() ), keeping it below 1000 at all times.

Parameters
amountThe amount of AEPS per frame to increment by.
template<class GC>
virtual void MFM::AbstractDriver< GC >::OnceOnly ( VArguments args)
inlineprotectedvirtual

To be run during first initialization, only once. This runs after all standard argument parsing and is available to extend that behavior. Any overrides of this method should be certain to call Super::OnceOnly (probably at the beginning, but in any case, sometime) during their execution, so more abstract levels can do any processing they need to.

Parameters
argsThe VArguments , which should have been gotten from the command line. These allow this method to configure itself properly from the command line arguments.

Reimplemented in MFM::AbstractGUIDriver< GC >, MFM::AbstractGUIDriver< OurGridConfig >, MFM::MFMSimSBarDemo, MFM::AbstractHeadlessDriver< GC >, MFM::MFMSimQBDemo, MFM::MFMSimDHSDemo, and MFM::MFMSimDHSDemo.

template<class GC>
virtual void MFM::AbstractDriver< GC >::PostReinit ( VArguments args)
inlineprotectedvirtual

Called at the end of the Reinit() call. This is for custom initialization behavior.

Parameters
argsThe VArguments , which should have been gotten from the command line, which will be processed again during this call.

Reimplemented in MFM::AbstractGUIDriver< GC >, and MFM::AbstractGUIDriver< OurGridConfig >.

template<class GC>
virtual void MFM::AbstractDriver< GC >::PostReinitPhysics ( )
inlineprotectedvirtual

Used by GUI Drivers to register Elements in places needed.

Reimplemented in MFM::AbstractGUIDriver< GC >, and MFM::AbstractGUIDriver< OurGridConfig >.

template<class GC>
virtual void MFM::AbstractDriver< GC >::PostUpdate ( )
inlineprotectedvirtual

To be run at the end of a frame update.

Reimplemented in MFM::AbstractGUIDriver< GC >, MFM::AbstractGUIDriver< OurGridConfig >, and MFM::AbstractHeadlessDriver< GC >.

template<class GC>
virtual void MFM::AbstractDriver< GC >::ReinitEden ( )
protectedpure virtual

Establish the Garden of Eden configuration on the grid.

Implemented in MFM::MFMSimSBarDemo, MFM::MFMSimQBDemo, MFM::MFMSimDHSDemo, and MFM::MFMSimDHSDemo.

template<class GC>
void MFM::AbstractDriver< GC >::ReinitPhysics ( )
inlineprotected

Register any element types needed for the run.

template<class GC>
virtual void MFM::AbstractDriver< GC >::RunHelper ( )
inlineprotectedvirtual

The main loop which runs this simulation.

Reimplemented in MFM::AbstractGUIDriver< GC >, and MFM::AbstractGUIDriver< OurGridConfig >.

template<class GC>
void MFM::AbstractDriver< GC >::UpdateGrid ( OurGrid grid)
inlineprotected

Runs the held Grid and all its associated threads for a brief amount of time, letting about m_aepsPerFrame AEPS occur before pausing. This also learns about how long an AEPS takes to elapse, making subsequent calls more accurate in duration.

Parameters
gridThe Grid which is updated during this call.

Field Documentation

template<class GC>
const u32 MFM::AbstractDriver< GC >::EVENT_WINDOW_RADIUS = R
staticprotected

The size of every EventWindow used by this simulation.

template<class GC>
const u32 MFM::AbstractDriver< GC >::GRID_HEIGHT = H
staticprotected

The height of the Grid used by this simulation.

template<class GC>
const u32 MFM::AbstractDriver< GC >::GRID_WIDTH = W
staticprotected

The width of the Grid used by this simulation.


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