Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
berryXMLMemento.h
Go to the documentation of this file.
1 /*===================================================================
2 
3 BlueBerry Platform
4 
5 Copyright (c) German Cancer Research Center,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 
18 #ifndef BERRYXMLMEMENTO_H_
19 #define BERRYXMLMEMENTO_H_
20 
21 #include <berryMacros.h>
22 #include "berryIMemento.h"
23 #include "berryUIException.h"
24 
25 #include "Poco/DOM/Document.h"
26 #include "Poco/DOM/Element.h"
27 #include "Poco/SAX/XMLReader.h"
28 
29 
30 namespace berry {
31 
42 {
43 
44  public:
46 
47 
50  typedef std::ostream XMLByteOutputStream;
51 
55  typedef std::istream XMLByteInputStream;
56 
68  XMLMemento(Poco::XML::Document* document, Poco::XML::Element* elem);
69 
70  ~XMLMemento();
71 
81  static XMLMemento::Pointer CreateReadRoot(berry::XMLMemento::XMLByteInputStream& reader);
82 
97  static XMLMemento::Pointer CreateReadRoot(berry::XMLMemento::XMLByteInputStream& reader, const QString& baseDir);
98 
105  static XMLMemento::Pointer CreateWriteRoot(const QString& type);
106 
113  IMemento::Pointer CopyChild(IMemento::Pointer child);
114 
121  virtual IMemento::Pointer CreateChild(const QString& type) override;
122 
137  virtual IMemento::Pointer CreateChild(const QString& type, const QString& id) override;
138 
145  virtual IMemento::Pointer GetChild(const QString& type) const override;
146 
153  virtual QList< IMemento::Pointer > GetChildren(const QString& type) const override;
154 
158  virtual QString GetType() const override;
159 
163  virtual QString GetID() const override;
164 
168  virtual bool GetInteger(const QString& key, int& value) const override;
169 
173  virtual bool GetFloat(const QString& key, double& value) const override;
174 
178  virtual bool GetString(const QString& key, QString& value) const override;
179 
183  virtual bool GetBoolean(const QString& key, bool& value) const override;
184 
192  virtual QString GetTextData() const override;
193 
200  virtual QList< QString > GetAttributeKeys() const override;
201 
208  virtual void PutFloat(const QString& key, double value) override;
209 
216  virtual void PutInteger(const QString& key, int value) override;
217 
224  virtual void PutMemento(IMemento::Pointer memento) override;
225 
232  virtual void PutString(const QString& key, const QString& value) override;
233 
240  virtual void PutBoolean(const QString& key, bool value) override;
241 
247  virtual void PutTextData(const QString& data) override;
248 
256  void Save(XMLByteOutputStream& writer); //TODO: throw(IOException)
257 
263  virtual Poco::XML::Element* GetElement() const;
264 
265 private:
266 
274  Poco::XML::Text* GetTextNode() const;
275 
280  void PutElement(Poco::XML::Element* element, bool copyText);
281 
282  Poco::XML::Document* factory;
283  Poco::XML::Element* element;
284 
285 };
286 }//namespace berry
287 #endif /* BERRYXMLMEMENTO_H_ */
STL namespace.
#define berryObjectMacro(...)
Definition: berryMacros.h:37
#define BERRY_UI_QT