Jpp master_rocky-44-g75b7c4f75
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
31
32
33 /**
34 * Default constructor.
35 */
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 {
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
105
106 /**
107 * Terminator class of recursive JSTDObjectReader class.
108 */
109 template<class JHead_t>
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 {
122 using JRewindableObjectReader<const T>::set;
123
125
126 /**
127 * Default constructor.
128 */
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.
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