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