A world hosts agents, events, environment. More...
#include <world.h>
Public Member Functions | |
World (const QString &name, quint64 tot_energ) | |
constructor; general use | |
const QString & | name (void) const |
the name of this world | |
quint64 | currentTime (void) const |
current time in this world | |
void | advance (void) |
one unit of time passed | |
virtual QString | factoryName (void) const |
name of the factory that created this instance | |
const QString & | associatedFile (void) const |
associated file | |
bool | hasAssociatedFile (void) const |
has associated file | |
void | setAssociatedFile (const QString &s_val) |
change associated file | |
void | actorDies (Actor *actor) |
informed when the life of an actor ended | |
Director | |
Director * | director (void) const |
get the director | |
bool | setDirector (Director *new_val) |
change the director (the world will get a new reference for it) | |
Factories | |
const QMap< ID, ActorFactory * > & | actorFactories (void) const |
the list of actor factories | |
const QMap< ID, ActuatorFactory * > & | actuatorFactories (void) const |
the list of actuator factories | |
const QMap< ID, BrainFactory * > & | brainFactories (void) const |
the list of brain factories | |
const QMap< ID, SensorFactory * > & | sensorFactories (void) const |
the list of sensor factories | |
const QMap< ID, EventFactory * > & | eventFactories (void) const |
the list of event factories | |
const QMap< ID, ReflexFactory * > & | reflexFactories (void) const |
the list of reflex factories | |
ActorFactory * | actorFactory (ID id) const |
the actor factory for specified ID | |
ActuatorFactory * | actuatorFactory (ID id) const |
the actuator factory for specified ID | |
BrainFactory * | brainFactory (ID id) const |
the brain factory for specified ID | |
SensorFactory * | sensorFactory (ID id) const |
the sensor factory for specified ID | |
EventFactory * | eventFactory (ID id) const |
the event factory for specified ID | |
ReflexFactory * | reflexFactory (ID id) const |
the event factory for specified ID | |
Unique Id's | |
ID | idValue (const QString &s_name) |
get the id associated with a name | |
void | insertId (ID id, const QString &s_name) |
insert a new ID or update the string associated with one | |
ID | addNewId (const QString &s_name=QString()) |
allocate a new unique id and assign provided description | |
ID | checkAddId (const QString &s_name) |
check if provided description exists; create a new one if not | |
void | checkAddId (ID id, const QString &s_name) |
check if provided description exists; set this one if not | |
QString | nameForId (ID id) |
get the string associated with an identifier | |
bool | sameUId (World *other) const |
tell if the two unique ID provides are the same | |
QString | createIdName (const QString &s_pattern) |
generate an unique name based on a pattern | |
QList< ID > | allocatedIds (void) const |
allocated ids | |
bool | isIDAssigned (ID id) const |
tell if an ID is assigned | |
Factories added, removed and searched here | |
bool | addActorFactory (ActorFactory *factory, ID id) |
add one to the list of actor factories | |
bool | addActuatorFactory (ActuatorFactory *factory, ID id) |
add one to the list of actuator factories | |
bool | addSensorFactory (SensorFactory *factory, ID id) |
add one to the list of sensor factories | |
bool | addBrainFactory (BrainFactory *factory, ID id) |
add one to the list of brain factories | |
bool | addEventFactory (EventFactory *factory, ID id) |
add one to the list of event factories | |
bool | addReflexFactory (ReflexFactory *factory, ID id) |
add one to the list of event factories | |
bool | remActorFactory (ActorFactory *factory, ID id) |
add one to the list of actor factories | |
bool | remActuatorFactory (ActuatorFactory *factory, ID id) |
add one to the list of actuator factories | |
bool | remSensorFactory (SensorFactory *factory, ID id) |
add one to the list of sensor factories | |
bool | remBrainFactory (BrainFactory *factory, ID id) |
add one to the list of brain factories | |
bool | remEventFactory (EventFactory *factory, ID id) |
add one to the list of event factories | |
bool | remReflexFactory (ReflexFactory *factory, ID id) |
add one to the list of event factories | |
ActorFactory * | findActorFactory (const QString &s_name) |
add one to the list of actor factories | |
ActuatorFactory * | findActuatorFactory (const QString &s_name) |
add one to the list of actuator factories | |
SensorFactory * | findSensorFactory (const QString &s_name) |
add one to the list of sensor factories | |
BrainFactory * | findBrainFactory (const QString &s_name) |
add one to the list of brain factories | |
EventFactory * | findEventFactory (const QString &s_name) |
add one to the list of event factories | |
ReflexFactory * | findReflexFactory (const QString &s_name) |
add one to the list of event factories | |
Components are created here | |
Actor * | createActor (ID id_kind) |
create an actor | |
Actuator * | createActuator (Actor *actor, ID id) |
create an actuator | |
Brain * | createBrain (Actor *actor, ID id) |
create a brain | |
Sensor * | createSensor (Actor *actor, ID id) |
create a brain | |
EventSource * | createEvent (ID id) |
create a brain | |
Reflex * | createReflex (Actor *actor, ID id) |
create a reflex | |
Save and load the world | |
virtual bool | save (QSettings &stg) const |
save the world (only when the world is stopped) | |
virtual bool | load (QSettings &stg) |
load the world (only when the world is stopped) | |
virtual bool | saveAsStg (const QString &s_file, QString &s_err) const |
save the world (only when the world is stopped) | |
Public Member Functions inherited from april::Component | |
Component (void) | |
constructor; | |
Amorph & | payload (void) |
associated data | |
virtual ID | identificator (void) const |
associated ID, if any | |
virtual Factory * | factory (void) const |
associated factory, if any |
Static Public Member Functions | |
static Q_REQUIRED_RESULT World * | fromStg (QSettings &s) |
constructor method; creates and loads a world from QSettings | |
static Q_REQUIRED_RESULT World * | fromStg (const QString &s_file, QString &s_err) |
constructor method; creates and loads a world from a file |
Protected Member Functions | |
virtual | ~World (void) |
destructor; | |
Protected Member Functions inherited from april::Component | |
virtual | ~Component (void) |
destructor; | |
virtual void | inserted (void) |
the instance is informed that the parent attached it |
Running | |
bool | start (void) |
starts this world | |
void | stop (void) |
stops this world | |
bool | isRunning (void) const |
tell if this world is running | |
void | stepTime (void) |
director uses this method to update the time |
Energy | |
quint64 | energy (void) const |
ammount of energy in this world | |
quint64 | energyFree (void) const |
ammount of free energy in this world | |
quint64 | energyBounded (void) const |
ammount of bounded energy in this world | |
bool | setTotEnergy (quint64 new_val) |
sets the total ammout of energy in this world | |
bool | setEnergy (ActorComp *comp, quint64 energy, quint64 cost) |
set the packed energy and the ammount of energy consumed on each time unit |
Actor related methods | |
Actor * | firstActor (void) const |
first in the list of actors (alive or recently dead) | |
Actor * | actorAt (int i) const |
get nth actor (NULL if out of bounds) | |
bool | killActor (Actor *a) |
an actor is being killed and its energy transferred to world | |
bool | addActor (Actor *act) |
used by the Actor class to insert itself | |
bool | remActor (Actor *act) |
used by the Actor class to remove itself |
EventSource related methods | |
EventSource * | firstEvent (void) const |
first in the list of events (alive or recently dead) | |
bool | addEvent (EventSource *act) |
used by the EventSource class to insert itself | |
bool | remEvent (EventSource *act) |
used by the EventSource class to remove itself |
Eventlines related methods | |
EventLine * | eventLine (ID id) |
used by the EventLine class to insert itself | |
bool | addEventLine (EventLine *el, ID id) |
used by the EventLine class to insert itself | |
bool | remEventLine (EventLine *el, ID id) |
used by the EventLine class to remove itself | |
QMap< ID, EventLine * > ::ConstIterator | firstEventLine (void) |
access to event lines in the world - first | |
QMap< ID, EventLine * > ::ConstIterator | endEventLine (void) |
access to event lines in the world - end |
A world hosts agents, events, environment.
Actor * World::createActor | ( | ID | id_kind | ) |
create an actor
A factory is searched for this ID and, if found, it is requested to create an Actor.
id_kind | the id to search |
|
inline |
get the id associated with a name
s_name | the string to search (case sensitive) |
bool World::killActor | ( | Actor * | a | ) |
an actor is being killed and its energy transferred to world
This is simply a shortcut to Actor::killMe
a | The actor to kill |
|
protected |
set the packed energy and the ammount of energy consumed on each time unit
If the world does not have that much energy the opperation is dropped.
comp | the component where this is to be set |
energy | packed energy (will be substracted from world's free energy) |
cost | energy consumed on each step by this component |