Jpp  debug
the software that should make you happy
JSTDObjectWriter.hh
Go to the documentation of this file.
1 #ifndef __JLANG__JSTDOBJECTWRITER__
2 #define __JLANG__JSTDOBJECTWRITER__
3 
4 #include "JLang/JObjectWriter.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 output from STD container.
20  *
21  * This class implements the JObjectOutput interface.
22  */
23  template<class T>
25  public virtual JObjectOutput<T>,
26  public JObjectWriter<T>
27  {
28  public:
30 
31  /**
32  * Default constructor.
33  */
35  {}
36 
37 
38  /**
39  * Constructor.
40  *
41  * \param out output iterator
42  */
43  template<class JOutputIterator_t>
45  {
46  this->reset(out.clone());
47  }
48 
49 
50  /**
51  * Constructor.
52  *
53  * \param buffer output buffer
54  */
55  template<class JContainer_t>
56  JSTDObjectWriter(JContainer_t& buffer)
57  {
58  this->reset(getObjectOutput(buffer).clone());
59  }
60 
61 
62  /**
63  * Set output buffer.
64  *
65  * \param buffer output buffer
66  */
67  template<class JContainer_t>
68  void set(JContainer_t& buffer)
69  {
70  this->reset(getObjectOutput(buffer).clone());
71  }
72  };
73 
74 
75 
76  /**
77  * Implementation of object output from STD container for multiple data types.
78  *
79  * This class recursively implements the JLANG::JObjectOutput interface
80  * for all data types by deriving from:
81  * - JSTDObjectWriter<JHead_t>; and
82  * - JSTDObjectWriter<JTail_t>.
83  */
84  template<class JHead_t, class JTail_t>
85  struct JSTDObjectWriter< JTypeList<JHead_t, JTail_t> > :
86  public virtual JObjectOutput< JTypeList<JHead_t, JTail_t> >,
87  public JSTDObjectWriter<JHead_t>,
88  public JSTDObjectWriter<JTail_t>
89  {
94 
95 
96  /**
97  * Set output puffer.
98  *
99  * \param buffer output buffer
100  */
101  template<class JContainer_t>
102  void set(JContainer_t& buffer)
103  {
104  this->reset(getObjectOutput(buffer).clone());
105  }
106  };
107 
108 
109  /**
110  * Terminator class of recursive JSTDObjectWriter class.
111  */
112  template<class JHead_t>
113  struct JSTDObjectWriter< JTypeList<JHead_t, JNullType> > :
114  public JSTDObjectWriter<JHead_t>
115  {};
116 }
117 
118 #endif
Template interface of object output for single data type.
Implementation of object output for STD compatible output iterator.
Implementation of object output from STD container.
JSTDObjectWriter(JContainer_t &buffer)
Constructor.
JSTDObjectWriter()
Default constructor.
JSTDObjectWriter(const JSTDObjectOutput< JOutputIterator_t > &out)
Constructor.
void set(JContainer_t &buffer)
Set output buffer.
virtual void reset() override
Reset pointer.
Auxiliary classes and methods for language specific functionality.
JSTDObjectOutput< std::back_insert_iterator< std::vector< JElement_t, JAllocator_t > > > getObjectOutput(std::vector< JElement_t, JAllocator_t > &buffer)
Helper method to create STD compatible object output.
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 writing to a named device.
data_type * clone() const
Get clone from temporary object.
Definition: JObject.hh:44
void set(JContainer_t &buffer)
Set output puffer.
Type list.
Definition: JTypeList.hh:23