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
00026 #ifndef GELEMENTH
00027 #define GELEMENTH
00028
00029 #include <QDataStream>
00030 #include <QDateTime>
00031 #include <QObject>
00032
00033 #include <QEvent>
00034 #include <qdom.h>
00035 #include <QCustomEvent>
00036 #include <QStringList>
00037
00038
00039 namespace GCS
00040 {
00041
00042 class GObject;
00043 class GEnergy;
00044 class GForm;
00045 class GMatrix44;
00046 class GElementID;
00047 class GElementInfluence;
00048 class GAgent;
00049
00083 class GElement : public QObject
00084 {
00085
00086
00087
00088 Q_OBJECT
00089
00090 private:
00091
00095 GObject* Object;
00096
00101 QList<GAgent*> Agents;
00102
00111 QDateTime ParkTime;
00112
00113 protected:
00114
00126 virtual ~GElement();
00127
00128 public:
00129
00138 GElement(GObject* object, const QDateTime& park_time = QDateTime::currentDateTime());
00139
00143 const GElementID& getElementID() const;
00144
00150 QDateTime getParkTime() const;
00151
00159 bool isParked();
00160
00164 QList<const GAgent*> getAgents() const;
00165
00169 const GObject* getObject() const;
00170
00174 GObject* getObject();
00175
00181 QStringList getAvailableActions() const;
00182
00188 QString getActionDescription(const QString& action) const;
00189
00196 virtual void customEvent(QEvent* event);
00197
00198 typedef enum {ELEMENTCHANGED=65031, SENDINFLUENCE=65032, RADIATEINFLUENCE=65033,
00199 PARENTCHANGED=65034, INFLUENCERECEIVED=65035, ACTIONPERFORMED=65036,
00200 ENERGYCHANGED=65037, FORMCHANGED=65038, ELEMENTDATACHANGED=65039,
00201 CHILDCREATED=65040, CHILDREMOVED=65041, DELETESELF=65042} ElementSignalType;
00202
00203 protected slots:
00204
00205
00206
00212 void collectElementChanged();
00213
00214 void collectSendInfluence(const GCS::GElementInfluence& influence,
00215 const GCS::GElementID& destination);
00216
00217 void collectRadiateInfluence(const GCS::GElementInfluence& influence,
00218 double radius_factor);
00219
00220 void collectParentChanged(const GCS::GElementID& oldParent, const GCS::GElementID& newParent, const GCS::GMatrix44& transformation);
00221
00222 void collectInfluenceReceived(const GCS::GElementInfluence& influence);
00223
00224 void collectActionPerformed(const QString& action, QStringList params, const QString& agent);
00225
00226 void collectEnergyChanged(const GCS::GEnergy& changedEnergy);
00227
00228 void collectFormChanged(const GCS::GForm& changedForm);
00229
00230 void collectElementDataChanged(const QString& xmlpath);
00231
00232 void collectChildCreated(GCS::GElement* newElement);
00233
00234 void collectChildRemoved(const GCS::GElementID& childID);
00235
00236
00237
00247 void checkReadyDelete();
00248
00249
00250 public slots:
00251
00262 virtual void deleteSelf();
00263
00271 void receiveInfluence(const GCS::GElementInfluence&);
00272
00283 void performAction(const QString& action, QStringList params, const QString& agent = QString());
00284
00293 void addAgent(GCS::GAgent* agent);
00294
00301 void removeAgent(GCS::GAgent* agent, bool del=FALSE);
00302
00303 signals:
00304
00321 void park();
00322
00330 void execute(double seconds_elapsed);
00331
00340 void forwardInfluenceInternal(const GCS::GElementInfluence&);
00341
00349 void notifyReparentingInternal(const GCS::GElementID& old_parent, const GCS::GElementID& new_parent, const GCS::GMatrix44& transformation);
00350
00351
00352 public:
00353
00358 void parkElement();
00359
00369 void executeElement(double seconds_delta_t_offset = 0);
00370
00371 signals:
00372
00376 void sendInfluence(const GCS::GElementInfluence& influence, const GCS::GElementID& destination);
00377
00381 void radiateInfluence(const GCS::GElementInfluence& influence, double radius_factor);
00382
00383 signals:
00384
00393 void elementChanged(const GCS::GElementID& element);
00394
00395
00396
00403 void parentChanged(const GCS::GElementID& newParent, const GCS::GElementID& oldParent, const GCS::GMatrix44& transformation);
00404
00411 void influenceReceived(const GCS::GElementInfluence& influence);
00412
00418 void actionPerformed(const QString& action, QStringList params, const QString& agent);
00419
00420
00421
00422
00423
00427 void energyChanged(const GCS::GEnergy& changedEnergy);
00428
00432 void formChanged(const GCS::GForm& changedForm);
00433
00438 void elementDataChanged(const QString& xmlpath);
00439
00447 void childElementCreated(GCS::GElement* newElement);
00448
00456 void childElementRemoved(const GCS::GElementID& childID);
00457 };
00458
00459 }
00460
00461 #endif