april  1.0.0
...
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
april::GenericActorFactory Class Reference

A generic actor factory. More...

#include <genericactorfactory.h>

+ Inheritance diagram for april::GenericActorFactory:

Public Types

typedef QMap< ID, DNAIdDnaMap
 a list of ID and DNA values
typedef QMap< ID, DNA >::Iterator IdDnaMapIter
 iterator for a DNA map
typedef QMap< ID, DNA >
::ConstIterator 
IdDnaMapIterC
 constant iterator for a DNA map

Public Member Functions

 GenericActorFactory (World *w)
 constructor
const IdDnaMapdnaList (void) const
 the list of IDs and DNA
void addNewKind (const DNA::InitData &data)
 creates a new kind
DNAdna (ID id)
 get the DNA at a particular index
- Public Member Functions inherited from april::ActorFactory
 ActorFactory (World *w)
 constructor;
virtual void copyDefaultDNA (DNA &destination)
 copies default DNA from internal storage to destination
- Public Member Functions inherited from april::Factory
 Factory (World *w)
 constructor;
Worldworld (void) const
 the world that hosts us;
virtual const QString & name (ID id) const
 name of the element represented by provided ID
virtual QList< qreal > averageDNA (ID id) const
 get the default DNA sequence for a particular ID

Static Public Member Functions

static GenericActorFactoryfindMyself (World *w)
 find the instance (should only be one) of this class in a world
static QString staticName (void)
 the name of this factory

Protected Member Functions

virtual ~GenericActorFactory (void)
 destructor;
virtual FactoryType factoryType (void)
 the generic type of the factory
virtual QString factoryName (void)
 the name used to save this factory
virtual Actorcreate (ID id)
 create a new actor
virtual bool save (QSettings &s) const
 save to a QSettings object
virtual bool load (QSettings &s)
 load from a QSettings object
- Protected Member Functions inherited from april::ActorFactory
virtual ~ActorFactory (void)
 destructor;
DNAdefaultDNA (void)
 allow access to default dna storage
bool addMyself (ID id)
 add this class to the world
void setDNA (Actor *a, const DNA &dna)
 set the DNA in the actor
void setDNA (Actor *a)
 set default DNA in the actor
void initDNA (DNA &dna, const DNA::InitData &init)
 initialise a DNA instance
void initDNA (const DNA::InitData &init)
 initialise default DNA instance
- Protected Member Functions inherited from april::Factory
virtual ~Factory (void)
 destructor;
void setName (const QString &s)
 chang the name of the element represented by provided ID
bool setEnergy (ActorComp *comp, quint64 energy, quint64 cost)
 set the packed energy and the ammount of energy consumed on each time unit

Detailed Description

A generic actor factory.

The factory simply worls with IDs and DNA. For each DNA registered an ID is used.

Member Function Documentation

Actor * GenericActorFactory::create ( ID  id)
protectedvirtual

create a new actor

Looks up the ID in the internal list. If found, the DNA for that ID is used to construct a new Actor.

The caller recieves a reference that should eventually discard.

Parameters
idThe id that is requested
Returns
either a pointer or NULL

Reimplemented from april::ActorFactory.

GenericActorFactory * GenericActorFactory::findMyself ( World w)
static

find the instance (should only be one) of this class in a world

The method returns a reference to the caller that should eventually release it.

Parameters
wthe target world
Returns
always non-null

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