Jpp  master_rocky
the software that should make you happy
JSTDObjectReader.hh
Go to the documentation of this file.
1 #ifndef __JLANG__JSTDOBJECTREADER__
2 #define __JLANG__JSTDOBJECTREADER__
3 
4 #include "JLang/JObjectReader.hh"
6 
7 
8 /**
9  * \author mdejong
10  */
11 
12 namespace JLANG {}
13 namespace JPP { using namespace JLANG; }
14 
15 namespace JLANG {
16 
17 
18  /**
19  * Implementation of object iteration from STD container.
20  *
21  * This class implements the JLANG::JRewindableObjectIterator interface.
22  */
23  template<class T>
25  public virtual JRewindableObjectIterator<T>,
26  public JRewindableObjectReader<T>
27  {
29 
31 
32 
33  /**
34  * Default constructor.
35  */
37  {}
38 
39 
40  /**
41  * Constructor.
42  *
43  * \param buffer input buffer
44  */
45  template<class JContainer_t>
46  JSTDObjectReader(JContainer_t& buffer)
47  {
48  this->reset(new JSTDObjectIterator<typename JContainer_t::iterator>(buffer.begin(), buffer.end()));
49  }
50 
51 
52  /**
53  * Set input buffer.
54  *
55  * \param buffer input buffer
56  */
57  template<class JContainer_t>
58  void set(JContainer_t& buffer)
59  {
60  this->reset(new JSTDObjectIterator<typename JContainer_t::iterator>(buffer.begin(), buffer.end()));
61  }
62  };
63 
64 
65  /**
66  * Implementation of object iteration from STD container for multiple data types.
67  *
68  * This class recursively implements the JLANG::JRewindableObjectIterator interface
69  * for all data types by deriving from:
70  * - JSTDObjectReader<JHead_t>; and
71  * - JSTDObjectReader<JTail_t>.
72  */
73  template<class JHead_t, class JTail_t>
74  struct JSTDObjectReader< JTypeList<JHead_t, JTail_t> > :
75  public virtual JRewindableObjectIterator< JTypeList<JHead_t, JTail_t> >,
76  public JSTDObjectReader<JHead_t>,
77  public JSTDObjectReader<JTail_t>
78  {
81 
82 
83  /**
84  * Set input buffer.
85  *
86  * \param buffer input buffer
87  */
88  template<class JContainer_t>
89  void set(JContainer_t& buffer)
90  {
91  this->reset(new JSTDObjectIterator<typename JContainer_t::iterator>(buffer.begin(), buffer.end()));
92  }
93 
94 
95  /**
96  * Rewind.
97  */
98  virtual void rewind() override
99  {
102  }
103  };
104 
105 
106  /**
107  * Terminator class of recursive JSTDObjectReader class.
108  */
109  template<class JHead_t>
110  struct JSTDObjectReader< JTypeList<JHead_t, JNullType> > :
111  public JSTDObjectReader<JHead_t>
112  {};
113 
114 
115  /**
116  * Specialisation of object iteration from STD container for constant data.
117  */
118  template<class T>
119  struct JSTDObjectReader<const T> :
120  public JRewindableObjectReader<const T>
121  {
123 
125 
126  /**
127  * Default constructor.
128  */
130  {}
131 
132 
133  /**
134  * Constructor.
135  *
136  * \param buffer input buffer
137  */
138  template<class JContainer_t>
139  JSTDObjectReader(const JContainer_t& buffer)
140  {
141  this->reset(new JSTDObjectIterator<typename JContainer_t::const_iterator>(buffer.begin(), buffer.end()));
142  }
143 
144 
145  /**
146  * Set input buffer.
147  *
148  * \param buffer buffer buffer
149  */
150  template<class JContainer_t>
151  void set(const JContainer_t& buffer)
152  {
153  this->reset(new JSTDObjectIterator<typename JContainer_t::const_iterator>(buffer.begin(), buffer.end()));
154  }
155  };
156 }
157 
158 #endif
Interface for object iteration with rewinding.
Auxiliary classes and methods for language specific functionality.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary class for no type definition.
Definition: JNullType.hh:19
Auxiliary class for object reading with rewinding.
Implementation of object iteration from STD container.
void set(JContainer_t &buffer)
Set input buffer.
JRewindableObjectReader< const T >::pointer_type pointer_type
JSTDObjectReader()
Default constructor.
JSTDObjectReader(const JContainer_t &buffer)
Constructor.
void set(const JContainer_t &buffer)
Set input buffer.
Implementation of object iteration from STD container.
void set(JContainer_t &buffer)
Set input buffer.
JSTDObjectReader(JContainer_t &buffer)
Constructor.
JRewindableObjectReader< T >::pointer_type pointer_type
JSTDObjectReader()
Default constructor.
Type list.
Definition: JTypeList.hh:23