00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef GAGENTH
00026 #define GAGENTH
00027
00028 #include <QThread>
00029 #include <QStringList>
00030 #include <qdom.h>
00031
00032
00033 namespace GCS
00034 {
00035
00036 class GElement;
00037 class GObject;
00038 class GEnergy;
00039 class GForm;
00040 class GVector3;
00041 class GMatrix44;
00042 class GElementID;
00043 class GElementInfluence;
00044 class GElementData;
00045
00087 class GAgent : protected QThread
00088 {
00089
00090
00091 Q_OBJECT
00092
00093 private:
00104 GObject* Object;
00105
00116 QList<GAgent*>* Agents;
00117
00118 protected:
00119
00137 bool shutdown;
00138
00139 public:
00140
00145 GAgent();
00146
00154 virtual ~GAgent() {}
00155
00161 const GElementID& getElementID() const;
00162
00183 virtual QString getAgentName() const;
00184
00192 virtual QStringList getAvailableActions() const;
00193
00199 virtual QString getActionDescription(const QString& action) const;
00200
00201 protected:
00202
00209 virtual void run();
00210
00257 bool msleepCheckShutdown(unsigned long msecs, unsigned long checkinterval = 5000);
00258
00262 GObject* requestObject();
00263
00267 const GObject* requestObject() const;
00268
00272 GEnergy* requestEnergy();
00273
00277 const GEnergy* requestEnergy() const;
00278
00282 GForm* requestForm();
00283
00287 const GForm* requestForm() const;
00288
00292 GElementData* requestElementData();
00293
00297 const GElementData* requestElementData() const;
00298
00302 QList<const GAgent*> requestAgents() const;
00303
00307 const GElementID& getConnectionID() const;
00308
00309 protected slots:
00310
00319 virtual void beginPark();
00320
00326 virtual void threadStart(double seconds_elapsed);
00327
00328 public slots:
00329
00341 virtual void receiveInfluence(const GCS::GElementInfluence&);
00342
00352 virtual void performAction(const QString& action, QStringList params);
00353
00358 virtual void reparented(const GCS::GElementID& old_parent, const GCS::GElementID& new_parent, const GCS::GMatrix44& transformation);
00359
00360 signals:
00361
00366 void sendInfluence(const GCS::GElementInfluence& influence, const GCS::GElementID& destination);
00367
00383 void radiateInfluence(const GCS::GElementInfluence& influence, double radius_factor);
00384
00391 void parentChanged(const GCS::GElementID& newParent, const GCS::GElementID& oldParent, const GCS::GMatrix44& transformation);
00392
00397 void energyChanged(const GCS::GEnergy& changedEnergy);
00398
00403 void formChanged(const GCS::GForm& changedForm);
00404
00414 void elementDataChanged(const QString& xmlpath);
00415
00422 void childElementCreated(GCS::GElement* newElement);
00423
00430 void childElementRemoved(const GCS::GElementID& childID);
00431
00432
00433 public:
00434
00459 virtual bool isParked() const;
00460
00464 friend class GElement;
00465
00466 };
00467
00468 }
00469
00470 #endif