Jpp 20.0.0-rc.2
the software that should make you happy
Loading...
Searching...
No Matches
JSTDObjectWriter.hh
Go to the documentation of this file.
1#ifndef __JLANG__JSTDOBJECTWRITER__
2#define __JLANG__JSTDOBJECTWRITER__
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 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:
29 /**
30 * Default constructor.
31 */
34
35
36 /**
37 * Constructor.
38 *
39 * \param out output iterator
40 */
41 template<class JOutputIterator_t>
43 {
44 this->reset(out.clone());
45 }
46
47
48 /**
49 * Constructor.
50 *
51 * \param buffer output buffer
52 */
53 template<class JContainer_t>
54 JSTDObjectWriter(JContainer_t& buffer)
55 {
56 this->reset(getObjectOutput(buffer).clone());
57 }
58
59
60 /**
61 * Set output buffer.
62 *
63 * \param buffer output buffer
64 */
65 template<class JContainer_t>
66 void set(JContainer_t& buffer)
67 {
68 this->reset(getObjectOutput(buffer).clone());
69 }
70
71 private:
72 using JObjectWriter<T>::set;
73 };
74
75
76
77 /**
78 * Implementation of object output from STD container for multiple data types.
79 *
80 * This class recursively implements the JLANG::JObjectOutput interface
81 * for all data types by deriving from:
82 * - JSTDObjectWriter<JHead_t>; and
83 * - JSTDObjectWriter<JTail_t>.
84 */
85 template<class JHead_t, class JTail_t>
86 struct JSTDObjectWriter< JTypeList<JHead_t, JTail_t> > :
87 public virtual JObjectOutput< JTypeList<JHead_t, JTail_t> >,
88 public JSTDObjectWriter<JHead_t>,
89 public JSTDObjectWriter<JTail_t>
90 {
91 using JSTDObjectWriter<JHead_t>::put;
92 using JSTDObjectWriter<JTail_t>::put;
93 using JSTDObjectWriter<JHead_t>::reset;
94 using JSTDObjectWriter<JTail_t>::reset;
95
96
97 /**
98 * Set output puffer.
99 *
100 * \param buffer output buffer
101 */
102 template<class JContainer_t>
103 void set(JContainer_t& buffer)
104 {
105 this->reset(getObjectOutput(buffer).clone());
106 }
107 };
108
109
110 /**
111 * Terminator class of recursive JSTDObjectWriter class.
112 */
113 template<class JHead_t>
115 public JSTDObjectWriter<JHead_t>
116 {};
117}
118
119#endif
Template interface of object output for single data type.
virtual bool put(const T &object)=0
Object output.
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.
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