Jpp 20.0.0-rc.2
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 /**
32 * Default constructor.
33 */
36
37
38 /**
39 * Constructor.
40 *
41 * \param buffer input buffer
42 */
43 template<class JContainer_t>
44 JSTDObjectReader(JContainer_t& buffer)
45 {
46 this->reset(new JSTDObjectIterator<typename JContainer_t::iterator>(buffer.begin(), buffer.end()));
47 }
48
49
50 /**
51 * Set input buffer.
52 *
53 * \param buffer input buffer
54 */
55 template<class JContainer_t>
56 void set(JContainer_t& buffer)
57 {
58 this->reset(new JSTDObjectIterator<typename JContainer_t::iterator>(buffer.begin(), buffer.end()));
59 }
60
61 private:
63 };
64
65
66 /**
67 * Implementation of object iteration from STD container for multiple data types.
68 *
69 * This class recursively implements the JLANG::JRewindableObjectIterator interface
70 * for all data types by deriving from:
71 * - JSTDObjectReader<JHead_t>; and
72 * - JSTDObjectReader<JTail_t>.
73 */
74 template<class JHead_t, class JTail_t>
75 struct JSTDObjectReader< JTypeList<JHead_t, JTail_t> > :
76 public virtual JRewindableObjectIterator< JTypeList<JHead_t, JTail_t> >,
77 public JSTDObjectReader<JHead_t>,
78 public JSTDObjectReader<JTail_t>
79 {
80 using JSTDObjectReader<JHead_t>::reset;
81 using JSTDObjectReader<JTail_t>::reset;
82
83
84 /**
85 * Set input buffer.
86 *
87 * \param buffer input buffer
88 */
89 template<class JContainer_t>
90 void set(JContainer_t& buffer)
91 {
92 this->reset(new JSTDObjectIterator<typename JContainer_t::iterator>(buffer.begin(), buffer.end()));
93 }
94
95
96 /**
97 * Rewind.
98 */
99 virtual void rewind() override
100 {
103 }
104 };
105
106
107 /**
108 * Terminator class of recursive JSTDObjectReader class.
109 */
110 template<class JHead_t>
112 public JSTDObjectReader<JHead_t>
113 {};
114
115
116 /**
117 * Specialisation of object iteration from STD container for constant data.
118 */
119 template<class T>
120 struct JSTDObjectReader<const T> :
121 public JRewindableObjectReader<const T>
122 {
124
125 /**
126 * Default constructor.
127 */
130
131
132 /**
133 * Constructor.
134 *
135 * \param buffer input buffer
136 */
137 template<class JContainer_t>
138 JSTDObjectReader(const JContainer_t& buffer)
139 {
140 this->reset(new JSTDObjectIterator<typename JContainer_t::const_iterator>(buffer.begin(), buffer.end()));
141 }
142
143
144 /**
145 * Set input buffer.
146 *
147 * \param buffer buffer buffer
148 */
149 template<class JContainer_t>
150 void set(const JContainer_t& buffer)
151 {
152 this->reset(new JSTDObjectIterator<typename JContainer_t::const_iterator>(buffer.begin(), buffer.end()));
153 }
154
155 private:
156 using JRewindableObjectReader<const T>::set;
157 };
158}
159
160#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