xmldatastore.h

00001 /*
00002  * Silence
00003  *
00004  * Copyright (C) 2009 Manuel Unglaub
00005  *
00006  * This file is part of Silence.
00007  *
00008  * Silence is free software: you can redistribute it and/or modify
00009  * it under the terms of the GNU General Public License as published by
00010  * the Free Software Foundation, version GPLv2 only of the License.
00011  *
00012  * Silence is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016 
00017  * You should have received a copy of the GNU General Public License
00018  * along with Silence.  If not, see <http://www.gnu.org/licenses/>.
00019  */
00020 
00021 #ifndef XMLDATASTORE_H
00022 #define XMLDATASTORE_H
00023 
00024 #include "src/data/label.h"
00025 #include "src/data/node/node.h"
00026 #include "src/persistence/abstractdatastore.h"
00027 #include <QDomDocument>
00028 #include <QObject>
00029 
00030 
00038 class XmlDataStore : public AbstractDataStore
00039 {
00040     Q_OBJECT
00041 
00042     public:
00047         XmlDataStore();
00048 
00053         ~XmlDataStore();
00054 
00055         Node* getRootNode();
00056         Node *getNode(NodeId id);
00057         Label* getRootLabel();
00058 
00059         void removeNode(Node *node);
00060         void addNode(Node *node);
00061 
00062         void addLabel(Label *label);
00063         void removeLabel(Label *label);
00064 
00065     public slots:
00066         void saveNode(Node *node);
00067     
00068     private:
00069         Node *rootNode;
00070         Label *rootLabel;
00071         static const QString DATA_FILE;
00072 
00073         void saveAll();
00074         Node* findNode(Node* parent, NodeId id);
00075 
00076         void xmlToLabels(QDomElement &xmlLabels, Label* label);
00077 
00078         void addXmlNode(Node* node, QDomElement &parent, QDomDocument &doc);
00079         void xmlToNode(Node* parentNode, QDomNode &xmlNode, QDomDocument &doc);
00080 
00081         void writeLabels(QDomDocument &doc, QDomElement &parent, Label* parentLabel);
00082 };
00083 
00084 #endif // XMLDATASTORE_H
00085 
Generated on Fri May 14 19:12:50 2010 for Silence by  doxygen 1.6.3