NukleiObservationIO.h
Go to the documentation of this file.
1 // (C) Copyright Renaud Detry 2007-2015.
2 // Distributed under the GNU General Public License and under the
3 // BSD 3-Clause License (See accompanying file LICENSE.txt).
4 
5 /** @file */
6 
7 #ifndef NUKLEI_NUKLEI_OBSERVATIONSERIAL_H
8 #define NUKLEI_NUKLEI_OBSERVATIONSERIAL_H
9 
10 
11 #include <boost/ptr_container/ptr_list.hpp>
12 #include <nuklei/Definitions.h>
13 #include <nuklei/ObservationIO.h>
15 
16 #ifdef NUKLEI_USE_TICPP
17 namespace ticpp {
18  class Document;
19  class Node;
20  class Element;
21  template < class T > class Iterator;
22 }
23 #else
24 namespace tinyxml2 {
25  class XMLDocument;
26  class XMLElement;
27 }
28 #endif
29 
30 namespace nuklei {
31 
33  {
34  public:
35  NukleiReader(const std::string &observationFileName);
36  ~NukleiReader();
37 
38  Observation::Type type() const { return Observation::NUKLEI; }
39 
40  void reset();
41 
42  protected:
43  void init_();
44  NUKLEI_UNIQUE_PTR<Observation> readObservation_();
45  std::string observationFileName_;
46  private:
47 #ifdef NUKLEI_USE_TICPP
48  boost::shared_ptr<ticpp::Document> in_;
49  typedef ticpp::Iterator< ticpp::Element > ElementIterator;
50  boost::shared_ptr<ElementIterator> e_;
51 #else
52  boost::shared_ptr<tinyxml2::XMLDocument> in_;
53  tinyxml2::XMLElement* e_;
54 #endif
55  };
56 
58  {
59  public:
60  NukleiWriter(const std::string &observationFileName);
61  ~NukleiWriter();
62 
63  Observation::Type type() const { return Observation::NUKLEI; }
64 
65  void init();
66  void reset();
67 
68  NUKLEI_UNIQUE_PTR<Observation> templateObservation() const
69  { return NUKLEI_UNIQUE_PTR<Observation>(NUKLEI_MOVE(new NukleiObservation)); }
70 
71  void writeObservation(const Observation &o);
72  void writeBuffer();
73 
74  private:
75  std::string observationFileName_;
76 #ifdef NUKLEI_USE_TICPP
77  boost::shared_ptr<ticpp::Document> out_;
78  ticpp::Element* kc_;
79 #else
80  boost::shared_ptr<tinyxml2::XMLDocument> out_;
81  tinyxml2::XMLElement* kc_;
82 #endif
83  coord_t totalWeight_;
84  };
85 
86 }
87 
88 #endif
89 
Definition: Observation.h:17
Public namespace.
Definition: Color.cpp:9
Base class for kernel reader and point reader classes.
Definition: ObservationIO.h:34
double coord_t
Type for point coordinates.
Definition: Definitions.h:25
Base class for kernel writer and point writer classes.
© Copyright 2007-2013 Renaud Detry.
Distributed under the terms of the GNU General Public License (GPL).
(See accompanying file LICENSE.txt or copy at http://www.gnu.org/copyleft/gpl.html.)
Revised Sun Sep 13 2020 19:10:06.