SerializedKernelObservationIO.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_KERNELOBSERVATIONSERIAL_H
8 #define NUKLEI_KERNELOBSERVATIONSERIAL_H
9 
10 
11 #include <boost/ptr_container/ptr_list.hpp>
12 #include <nuklei/Definitions.h>
13 #include <nuklei/ObservationIO.h>
16 
17 namespace nuklei {
18 
20  {
21  public:
22  KernelReader(const std::string &observationFileName);
23  ~KernelReader();
24 
25  Observation::Type type() const { return Observation::SERIAL; }
26 
27  nullable<unsigned> nObservations() const
28  { NUKLEI_ASSERT(idx_ >= 0); return kc_.size(); }
29 
30  void reset();
31 
32  protected:
33  void init_();
34  NUKLEI_UNIQUE_PTR<Observation> readObservation_();
35  std::string observationFileName_;
36  int idx_;
37  KernelCollection kc_;
38  };
39 
41  {
42  public:
43  KernelWriter(const std::string &observationFileName);
44  ~KernelWriter();
45 
46  Observation::Type type() const { return Observation::SERIAL; }
47 
48  void init();
49  void reset();
50 
51  NUKLEI_UNIQUE_PTR<Observation> templateObservation() const
52  { return NUKLEI_UNIQUE_PTR<Observation>(NUKLEI_MOVE(new SerializedKernelObservation)); }
53 
54  void writeObservation(const Observation &o);
55  void writeBuffer();
56 
57  protected:
58  std::string observationFileName_;
59  KernelCollection kc_;
60  };
61 
62 }
63 
64 #endif
65 
Definition: Observation.h:17
Public namespace.
Definition: Color.cpp:9
This class acts as a vector-like container for kernels. It also provides methods related to kernel de...
#define NUKLEI_ASSERT(expression)
Throws an Error if expression is not true.
Definition: Common.h:113
Base class for kernel reader and point reader classes.
Definition: ObservationIO.h:34
Container::size_type size() const
Returns the number of kernels.
Base class for kernel writer and point writer classes.
Obsolete – use boost::optional and boost::none instead.
Definition: nullable.h:25
© 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.