Jpp 21.0.0-rc.1-88-g0130508c4
the software that should make you happy
Loading...
Searching...
No Matches
JSTDObjectReader.hh
Go to the documentation of this file.
1#ifndef __JLANG__JSTDOBJECTREADER__
2#define __JLANG__JSTDOBJECTREADER__
3
6
7
8/**
9 * \author mdejong
10 */
11
12namespace JLANG {}
13namespace JPP { using namespace JLANG; }
14
15namespace 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>,
27 {
29
30 /**
31 * Default constructor.
32 */
35
36
37 /**
38 * Constructor.
39 *
40 * \param buffer input buffer
41 */
42 template<class JContainer_t>
43 JSTDObjectReader(JContainer_t& buffer)
44 {
45 this->reset(new JSTDObjectIterator<typename JContainer_t::iterator>(buffer.begin(), buffer.end()));
46 }
47
48
49 /**
50 * Set input buffer.
51 *
52 * \param buffer input buffer
53 */
54 template<class JContainer_t>
55 void set(JContainer_t& buffer)
56 {
57 this->reset(new JSTDObjectIterator<typename JContainer_t::iterator>(buffer.begin(), buffer.end()));
58 }
59
60 protected:
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 {
79 using JSTDObjectReader<JHead_t>::reset;
80 using JSTDObjectReader<JTail_t>::reset;
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 protected:
105 using JSTDObjectReader<JHead_t>::set;
106 using JSTDObjectReader<JTail_t>::set;
107 };
108
109
110 /**
111 * Terminator class of recursive JSTDObjectReader class.
112 */
113 template<class JHead_t>
115 public JSTDObjectReader<JHead_t>
116 {};
117
118
119 /**
120 * Specialisation of object iteration from STD container for constant data.
121 */
122 template<class T>
123 struct JSTDObjectReader<const T> :
124 public JRewindableObjectReader<const T>
125 {
127
128 /**
129 * Default constructor.
130 */
133
134
135 /**
136 * Constructor.
137 *
138 * \param buffer input buffer
139 */
140 template<class JContainer_t>
141 JSTDObjectReader(const JContainer_t& buffer)
142 {
143 this->reset(new JSTDObjectIterator<typename JContainer_t::const_iterator>(buffer.begin(), buffer.end()));
144 }
145
146
147 /**
148 * Set input buffer.
149 *
150 * \param buffer buffer buffer
151 */
152 template<class JContainer_t>
153 void set(const JContainer_t& buffer)
154 {
155 this->reset(new JSTDObjectIterator<typename JContainer_t::const_iterator>(buffer.begin(), buffer.end()));
156 }
157
158 private:
159 using JRewindableObjectReader<const T>::set;
160 };
161}
162
163#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.
JSTDObjectReader(const JContainer_t &buffer)
Constructor.
void set(const JContainer_t &buffer)
Set input buffer.
JRewindableObjectReader< constT >::pointer_type pointer_type
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