Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
berryXMLMemento.h
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 
14 #ifndef BERRYXMLMEMENTO_H_
15 #define BERRYXMLMEMENTO_H_
16 
17 #include <berryMacros.h>
18 #include "berryIMemento.h"
19 #include "berryUIException.h"
20 
21 #include "Poco/DOM/Document.h"
22 #include "Poco/DOM/Element.h"
23 #include "Poco/SAX/XMLReader.h"
24 
25 
26 namespace berry {
27 
38 {
39 
40  public:
42 
46  typedef std::ostream XMLByteOutputStream;
47 
51  typedef std::istream XMLByteInputStream;
52 
64  XMLMemento(Poco::XML::Document* document, Poco::XML::Element* elem);
65 
66  ~XMLMemento() override;
67 
77  static XMLMemento::Pointer CreateReadRoot(berry::XMLMemento::XMLByteInputStream& reader);
78 
93  static XMLMemento::Pointer CreateReadRoot(berry::XMLMemento::XMLByteInputStream& reader, const QString& baseDir);
94 
101  static XMLMemento::Pointer CreateWriteRoot(const QString& type);
102 
109  IMemento::Pointer CopyChild(IMemento::Pointer child);
110 
117  IMemento::Pointer CreateChild(const QString& type) override;
118 
133  IMemento::Pointer CreateChild(const QString& type, const QString& id) override;
134 
141  IMemento::Pointer GetChild(const QString& type) const override;
142 
149  QList< IMemento::Pointer > GetChildren(const QString& type) const override;
150 
154  QString GetType() const override;
155 
159  QString GetID() const override;
160 
164  bool GetInteger(const QString& key, int& value) const override;
165 
169  bool GetFloat(const QString& key, double& value) const override;
170 
174  bool GetString(const QString& key, QString& value) const override;
175 
179  bool GetBoolean(const QString& key, bool& value) const override;
180 
188  QString GetTextData() const override;
189 
196  QList< QString > GetAttributeKeys() const override;
197 
204  void PutFloat(const QString& key, double value) override;
205 
212  void PutInteger(const QString& key, int value) override;
213 
220  void PutMemento(IMemento::Pointer memento) override;
221 
228  void PutString(const QString& key, const QString& value) override;
229 
236  void PutBoolean(const QString& key, bool value) override;
237 
243  void PutTextData(const QString& data) override;
244 
252  void Save(XMLByteOutputStream& writer); //TODO: throw(IOException)
253 
259  virtual Poco::XML::Element* GetElement() const;
260 
261 private:
262 
270  Poco::XML::Text* GetTextNode() const;
271 
276  void PutElement(Poco::XML::Element* element, bool copyText);
277 
278  Poco::XML::Document* factory;
279  Poco::XML::Element* element;
280 
281 };
282 }//namespace berry
283 #endif /* BERRYXMLMEMENTO_H_ */
std::istream XMLByteInputStream
std::ostream XMLByteOutputStream
#define berryObjectMacro(...)
Definition: berryMacros.h:33
#define BERRY_UI_QT