GXmlDataController.h

00001 /***************************************************************************
00002  *   Copyright (C) 2004 - 2006 by Raphael Langerhorst                      *
00003  *   raphael-langerhorst@gmx.at                                            *
00004  *                                                                         *
00005  *   Permission is hereby granted, free of charge, to any person obtaining *
00006  *   a copy of this software and associated documentation files (the       *
00007  *   "Software"), to deal in the Software without restriction, including   *
00008  *   without limitation the rights to use, copy, modify, merge, publish,   *
00009  *   distribute, sublicense, and/or sell copies of the Software, and to    *
00010  *   permit persons to whom the Software is furnished to do so, subject to *
00011  *   the following conditions:                                             *
00012  *                                                                         *
00013  *   The above copyright notice and this permission notice shall be        *
00014  *   included in all copies or substantial portions of the Software.       *
00015  *                                                                         *
00016  *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,       *
00017  *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF    *
00018  *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*
00019  *   IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR     *
00020  *   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
00021  *   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR *
00022  *   OTHER DEALINGS IN THE SOFTWARE.                                       *
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 //     QStringList ChildServers;
00105     
00116 //     QMap<GCS::GElementID,QString> ElementServerMapping;
00117     
00123 //     QValueList<GCS::GElementID> PrimaryElements;
00124     
00130 //     QValueList<GCS::GElementID> SecondaryElements;
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     // GDataController implementation //
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     //BEGIN ELEMENT OBSERVATION
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     //BEGIN ELEMENT OBSERVATION
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     //BEGIN SLOTS / SIGNALS FOR USER INTERACTION
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     //END SLOTS / SIGNALS FOR USER INTERACTION
00458 };
00459 
00460 }
00461 
00462 #endif //GXMLDATACONTROLLER_H

Generated on Thu Nov 16 07:49:12 2006 for G System by  doxygen 1.4.7