Jpp - the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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() override
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
JRewindableObjectReader< T >::pointer_type pointer_type
Interface for object iteration with rewinding.
virtual void rewind() override
Rewind.
Type list.
Definition: JTypeList.hh:22
void set(JContainer_t &buffer)
Set buffer puffer.
void set(JContainer_t &buffer)
Set input buffer.
Auxiliary class for object reading with rewinding.
Implementation of object iteration from STD container.
do set_variable OUTPUT_DIRECTORY $WORKDIR T
JSTDObjectReader(const JContainer_t &buffer)
Constructor.
Auxiliary class for no type definition.
Definition: JNullType.hh:19
Implementation of object iteration from STD container.
JSTDObjectReader(JContainer_t &buffer)
Constructor.
JSTDObjectReader()
Default constructor.
void set(const JContainer_t &buffer)
Set buffer puffer.
virtual void reset() override
Reset pointer.
JSTDObjectReader()
Default constructor.
JRewindableObjectReader< const T >::pointer_type pointer_type