Jpp
JSTDObjectReader.hh
Go to the documentation of this file.
1 #ifndef __JLANG__JSTDOBJECTREADER__
2 #define __JLANG__JSTDOBJECTREADER__
3 
4 #include "JLang/JObjectReader.hh"
6 
7 
8 /**
9  * \author mdejong
10  */
11 
12 namespace JLANG {}
13 namespace JPP { using namespace JLANG; }
14 
15 namespace 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>,
26  public JRewindableObjectReader<T>
27  {
29 
30  /**
31  * Default constructor.
32  */
34  {}
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  {
78 
79 
80  /**
81  * Set buffer puffer.
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()
96  {
99  }
100  };
101 
102 
103  /**
104  * Terminator class of recursive JSTDObjectReader class.
105  */
106  template<class JHead_t>
107  struct JSTDObjectReader< JTypeList<JHead_t, JNullType> > :
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  */
125  {}
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 buffer puffer.
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
JLANG::JSTDObjectIterator
Implementation of object iteration from STD container.
Definition: JSTDObjectIterator.hh:25
JLANG::JAbstractRewindableObjectReader::rewind
virtual void rewind()
Rewind.
Definition: JAbstractObjectReader.hh:104
JLANG::JSTDObjectReader< JTypeList< JHead_t, JTail_t > >::set
void set(JContainer_t &buffer)
Set buffer puffer.
Definition: JSTDObjectReader.hh:86
JLANG::JSTDObjectReader::pointer_type
JRewindableObjectReader< T >::pointer_type pointer_type
Definition: JSTDObjectReader.hh:28
JLANG::JNullType
Auxiliary class for no type definition.
Definition: JNullType.hh:19
JLANG::JSTDObjectReader::JSTDObjectReader
JSTDObjectReader(JContainer_t &buffer)
Constructor.
Definition: JSTDObjectReader.hh:43
JLANG::JSTDObjectReader< JTypeList< JHead_t, JTail_t > >::rewind
virtual void rewind()
Rewind.
Definition: JSTDObjectReader.hh:95
JObjectReader.hh
JPP
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JAAnetToolkit.hh:37
JLANG::JSTDObjectReader< const T >::JSTDObjectReader
JSTDObjectReader()
Default constructor.
Definition: JSTDObjectReader.hh:124
JLANG::JPointer< T >
JLANG::JRewindableObjectReader
Auxiliary class for object reading with rewinding.
Definition: JObjectReader.hh:57
JLANG::JTypeList
Type list.
Definition: JTypeList.hh:22
JLANG::JSTDObjectReader::JSTDObjectReader
JSTDObjectReader()
Default constructor.
Definition: JSTDObjectReader.hh:33
JLANG::JSTDObjectReader
Implementation of object iteration from STD container.
Definition: JSTDObjectReader.hh:24
JLANG::JRewindableObjectIterator
Interface for object iteration with rewinding.
Definition: JObjectIterator.hh:362
JLANG::JSTDObjectReader< const T >::pointer_type
JRewindableObjectReader< const T >::pointer_type pointer_type
Definition: JSTDObjectReader.hh:119
JLANG::JSharedPointer< JRewindableObjectIterator< T > >::reset
virtual void reset()
Reset pointer.
Definition: JSharedPointer.hh:171
JLANG::JSTDObjectReader::set
void set(JContainer_t &buffer)
Set input buffer.
Definition: JSTDObjectReader.hh:55
JLANG
Auxiliary classes and methods for language specific functionality.
Definition: JAbstractClass.hh:10
JLANG::JSTDObjectReader< const T >::JSTDObjectReader
JSTDObjectReader(const JContainer_t &buffer)
Constructor.
Definition: JSTDObjectReader.hh:134
JSTDObjectIterator.hh
JLANG::JSTDObjectReader< const T >::set
void set(const JContainer_t &buffer)
Set buffer puffer.
Definition: JSTDObjectReader.hh:146