Jpp 21.0.0-rc.3
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
61
62 /**
63 * Implementation of object iteration from STD container for multiple data types.
64 *
65 * This class recursively implements the JLANG::JRewindableObjectIterator interface
66 * for all data types by deriving from:
67 * - JSTDObjectReader<JHead_t>; and
68 * - JSTDObjectReader<JTail_t>.
69 */
70 template<class JHead_t, class JTail_t>
71 struct JSTDObjectReader< JTypeList<JHead_t, JTail_t> > :
72 public virtual JRewindableObjectIterator< JTypeList<JHead_t, JTail_t> >,
73 public JSTDObjectReader<JHead_t>,
74 public JSTDObjectReader<JTail_t>
75 {
76 using JSTDObjectReader<JHead_t>::reset;
77 using JSTDObjectReader<JTail_t>::reset;
78
79
80 /**
81 * Set input buffer.
82 *
83 * \param buffer input buffer
84 */
85 template<class JContainer_t>
86 void set(JContainer_t& buffer)
87 {
88 this->reset(new JSTDObjectIterator<typename JContainer_t::iterator>(buffer.begin(), buffer.end()));
89 }
90
91
92 /**
93 * Rewind.
94 */
95 virtual void rewind() override
96 {
99 }
100 };
101
102
103 /**
104 * Terminator class of recursive JSTDObjectReader class.
105 */
106 template<class JHead_t>
108 public JSTDObjectReader<JHead_t>
109 {};
110
111
112 /**
113 * Specialisation of object iteration from STD container for constant data.
114 */
115 template<class T>
116 struct JSTDObjectReader<const T> :
117 public JRewindableObjectReader<const T>
118 {
120
121 /**
122 * Default constructor.
123 */
126
127
128 /**
129 * Constructor.
130 *
131 * \param buffer input buffer
132 */
133 template<class JContainer_t>
134 JSTDObjectReader(const JContainer_t& buffer)
135 {
136 this->reset(new JSTDObjectIterator<typename JContainer_t::const_iterator>(buffer.begin(), buffer.end()));
137 }
138
139
140 /**
141 * Set input buffer.
142 *
143 * \param buffer buffer buffer
144 */
145 template<class JContainer_t>
146 void set(const JContainer_t& buffer)
147 {
148 this->reset(new JSTDObjectIterator<typename JContainer_t::const_iterator>(buffer.begin(), buffer.end()));
149 }
150 };
151}
152
153#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