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 GXMLDATACONTROLLER_H
00026 #define GXMLDATACONTROLLER_H
00027
00028 #include "GDataController.h"
00029
00030 #include <qdom.h>
00031 #include <QMap>
00032 #include <QStringList>
00033 #include <GElementID.h>
00034 #include <GElement.h>
00035
00036 namespace GWE
00037 {
00038
00039 class GCoreXmlSerializer;
00040 class GStorage;
00041 class GXmlNetwork;
00042
00043
00072 class GXmlDataController : public GDataController
00073 {
00074 Q_OBJECT
00075
00076 protected:
00077
00082 GCoreXmlSerializer* Serializer;
00083
00088 GStorage* Storage;
00089
00097 GXmlNetwork* Network;
00098
00104
00105
00116
00117
00123
00124
00130
00131
00135 QMap<GCS::GElementID,GCS::GElement*> OpenElements;
00136
00144 QMap<GCS::GElementID,QDateTime> LastSyndicationTime;
00145
00152 QList<GCS::GElementID> PendingSyndication;
00153
00154 public:
00155
00162 GXmlDataController(GStorage* storage, GXmlNetwork* network, QObject *parent = 0);
00163
00167 virtual ~GXmlDataController();
00168
00169
00170
00171 virtual const GCS::GElement* read(const GCS::GElementID& ) const;
00172
00173 virtual QList<GCS::GElementID> getChildren(const GCS::GElementID& parent) const;
00174
00175 virtual GCS::GElement* open(const GCS::GElementID& );
00176
00177 virtual GCS::GElement* getOpenElement(const GCS::GElementID& );
00178
00179 virtual QList<GCS::GElementID> getListOfOpenElements();
00180
00181 virtual QList<GCS::GElementID> getListOfAllElements();
00182
00187 virtual bool isPrimaryElement(const GCS::GElementID&) const;
00188
00189 public slots:
00190
00196 virtual bool add(GCS::GElement* );
00197
00198 virtual bool writeOpenElementToStorage(const GCS::GElementID& );
00199
00200 virtual bool close(const GCS::GElementID& );
00201
00202 virtual bool postDelete(const GCS::GElementID& );
00203
00204 public:
00205
00209 bool isMasterServer();
00210
00214 QString getMasterServer() const;
00215
00222 bool isRegisteredWithMaster() const;
00223
00228 QString getManagingServerOfElement(const GCS::GElementID&) const;
00229
00234 QStringList getAllKnownElementOwners() const;
00235
00240 QStringList getAllKnownServers() const;
00241
00242
00243
00244 protected slots:
00245
00251 virtual void shutdown();
00252
00258 virtual void syndicateGenericMessage(QDomElement data, bool to_master = false, QString exclude = QString());
00259
00264 virtual void registerWithMaster();
00265
00271 virtual void unregisterFromMaster();
00272
00277 virtual void unregisterFromAllKnownServers();
00278
00283 virtual void checkFreeIDs();
00284
00289 virtual void requestFreeIDs(unsigned long amount);
00290
00294 virtual void sendFreeIDs(QString server, unsigned long amount);
00295
00300 virtual void postSyndication(const GCS::GElementID& id);
00301
00308 virtual void checkElementsForSyndication();
00309
00313 virtual void syndicateElementDataToServer(const GCS::GElementID& id,const QString& server);
00314
00324 virtual void syndicateElementData(const GCS::GElementID& id);
00325
00330 virtual void syndicateAllElementDataToServer(const QString& server);
00331
00336 virtual void updateServerPresence(QString server, bool available);
00337
00338
00339
00340
00345 virtual void prepareOpenedElement(GCS::GElement* element);
00346
00353 virtual void processChildCreation(GCS::GElement* element);
00354
00363 virtual void processInfluencing(const GCS::GElementInfluence& influence);
00364
00379 virtual void processActionPerformed(const QString& action, QStringList params, const QString& agent);
00380
00381
00382
00387 virtual void processUnregister(const QString& server);
00388
00389 public slots:
00390
00395 virtual void receiveData(QDomElement data, const QString& sender);
00396
00409 virtual void addSecondary(GCS::GElement* element, QString managing_server);
00410
00417 virtual void moveElement(const GCS::GElementID& id, QString new_owner);
00418
00425 virtual bool checkConsistency(bool& ok);
00426
00427
00428
00429 public slots:
00430
00435 void sendUserMessage(QString message, QString destination);
00436
00437 signals:
00438
00445 void userMessageReceived(QString message, QString sender, bool internal);
00446
00455 void serverPresenceChanged(QString server, bool available, bool internal);
00456
00457
00458 };
00459
00460 }
00461
00462 #endif //GXMLDATACONTROLLER_H