53 class ActuatorFactory;
117 quint64 energy_free_;
129 QMap<ID,ActorFactory*> actor_factories_;
132 QMap<ID,ActuatorFactory*> actuator_factories_;
135 QMap<ID,BrainFactory*> brain_factories_;
138 QMap<ID,SensorFactory*> sensor_factories_;
141 QMap<ID,EventFactory*> event_factories_;
144 QMap<ID,ReflexFactory*> reflex_factories_;
147 QMap<ID,EventLine*> event_lines_;
162 World (
const QString & name, quint64 tot_energ );
166 static World * fromStg ( QSettings & s );
170 static World * fromStg (
171 const QString & s_file,
180 virtual ~
World (
void );
186 const QString & name (
void )
const
190 quint64 currentTime (
void )
const
194 void advance (
void );
197 virtual QString factoryName (
void )
const;
200 const QString & associatedFile (
void )
const
204 bool hasAssociatedFile (
void )
const
205 {
return s_file_.isEmpty() ==
false; }
208 void setAssociatedFile (
const QString & s_val )
221 {
return director_; }
224 bool setDirector (
Director * new_val );
251 bool isRunning (
void )
const
252 {
return b_running_; }
257 void stepTime (
void )
274 quint64 energy (
void )
const
275 {
return energy_all_; }
278 quint64 energyFree (
void )
const
279 {
return energy_free_; }
282 quint64 energyBounded (
void )
const
283 {
return energy_all_ - energy_free_; }
286 bool setTotEnergy ( quint64 new_val );
317 const QMap<ID,ActorFactory*> & actorFactories (
void )
const
318 {
return actor_factories_; }
321 const QMap<ID,ActuatorFactory*> & actuatorFactories (
void )
const
322 {
return actuator_factories_; }
325 const QMap<ID,BrainFactory*> & brainFactories (
void )
const
326 {
return brain_factories_; }
329 const QMap<ID,SensorFactory*> & sensorFactories (
void )
const
330 {
return sensor_factories_; }
333 const QMap<ID,EventFactory*> & eventFactories (
void )
const
334 {
return event_factories_; }
337 const QMap<ID,ReflexFactory*> & reflexFactories (
void )
const
338 {
return reflex_factories_; }
343 {
return actor_factories_.value(
id, NULL ); }
347 {
return actuator_factories_.value(
id, NULL ); }
351 {
return brain_factories_.value(
id, NULL ); }
355 {
return sensor_factories_.value(
id, NULL ); }
359 {
return event_factories_.value(
id, NULL ); }
363 {
return reflex_factories_.value(
id, NULL ); }
382 ID idValue (
const QString & s_name )
383 {
return uid_.
value( s_name ); }
386 void insertId ( ID
id,
const QString & s_name )
387 { uid_.
insert(
id, s_name ); }
390 ID addNewId (
const QString & s_name = QString() )
391 {
return uid_.
addNew( s_name ); }
394 ID checkAddId (
const QString & s_name )
398 void checkAddId ( ID
id,
const QString & s_name )
402 QString nameForId ( ID
id )
403 {
return uid_.
name(
id ); }
406 bool sameUId (
World * other )
const
407 {
return uid_ == other->uid_; }
410 QString createIdName (
const QString & s_pattern )
414 QList<ID> allocatedIds (
void )
const
415 {
return uid_.
ids(); }
418 bool isIDAssigned ( ID
id )
const
433 Actor * firstActor (
void )
const;
436 Actor * actorAt (
int i )
const;
444 bool killActor (
Actor * a );
449 bool addActor (
Actor * act );
452 bool remActor (
Actor * act );
488 {
return event_lines_.value(
id, NULL ); }
493 bool addEventLine (
EventLine * el, ID
id );
496 bool remEventLine (
EventLine * el, ID
id );
499 QMap<ID,EventLine*>::ConstIterator firstEventLine (
void )
500 {
return event_lines_.constBegin(); }
503 QMap<ID,EventLine*>::ConstIterator endEventLine (
void )
504 {
return event_lines_.constEnd(); }
557 ActorFactory* findActorFactory (
const QString & s_name );
566 BrainFactory* findBrainFactory (
const QString & s_name );
569 EventFactory* findEventFactory (
const QString & s_name );
593 Actor * createActor ( ID id_kind );
622 virtual bool save ( QSettings & stg )
const;
625 virtual bool load ( QSettings & stg );
629 virtual bool saveAsStg (
630 const QString & s_file,
640 void actorDies (
Actor * actor );
661 #endif // __WORLD_INC__