A generic actor factory. More...
#include <genericactorfactory.h>
Inheritance diagram for april::GenericActorFactory:Public Types | |
| typedef QMap< ID, DNA > | IdDnaMap |
| 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 IdDnaMap & | dnaList (void) const |
| the list of IDs and DNA | |
| void | addNewKind (const DNA::InitData &data) |
| creates a new kind | |
| DNA & | dna (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; | |
| World * | world (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 GenericActorFactory * | findMyself (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 Actor * | create (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; | |
| DNA & | defaultDNA (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 | |
A generic actor factory.
The factory simply worls with IDs and DNA. For each DNA registered an ID is used.
|
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.
| id | The id that is requested |
Reimplemented from april::ActorFactory.
|
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.
| w | the target world |