Jpp 21.0.0-rc.3
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
40 */
41 template<class JOutput_t>
42 JSTDObjectWriter(const JOutput_t& out)
43 {
44 this->set(out);
45 }
46
47
48 /**
49 * Constructor.
50 *
51 * \param out output
52 */
53 template<class JOutput_t>
54 JSTDObjectWriter(JOutput_t& out)
55 {
56 this->set(out);
57 }
58
59
60 /**
61 * Set output.
62 *
63 * \param out output
64 */
65 template<class JOutput_t>
66 void set(const JOutput_t& out)
67 {
68 this->reset(getSTDObjectOutput(out));
69 }
70
71
72 /**
73 * Set output.
74 *
75 * \param out output
76 */
77 template<class JOutput_t>
78 void set(JOutput_t& out)
79 {
80 this->reset(getSTDObjectOutput(out));
81 }
82 };
83
84
85 /**
86 * Implementation of object output from STD container for multiple data types.
87 *
88 * This class recursively implements the JLANG::JObjectOutput interface
89 * for all data types by deriving from:
90 * - JSTDObjectWriter<JHead_t>; and
91 * - JSTDObjectWriter<JTail_t>.
92 */
93 template<class JHead_t, class JTail_t>
94 struct JSTDObjectWriter< JTypeList<JHead_t, JTail_t> > :
95 public virtual JObjectOutput< JTypeList<JHead_t, JTail_t> >,
96 public JSTDObjectWriter<JHead_t>,
97 public JSTDObjectWriter<JTail_t>
98 {
99 using JSTDObjectWriter<JHead_t>::put;
100 using JSTDObjectWriter<JTail_t>::put;
101 using JSTDObjectWriter<JHead_t>::reset;
102 using JSTDObjectWriter<JTail_t>::reset;
103
104
105 /**
106 * Set output.
107 *
108 * \param out output
109 */
110 template<class JOutput_t>
111 void set(const JOutput_t& out)
112 {
113 this->reset(getSTDObjectOutput(out));
114 }
115
116
117 /**
118 * Set output.
119 *
120 * \param out output
121 */
122 template<class JOutput_t>
123 void set(JOutput_t& out)
124 {
125 this->reset(getSTDObjectOutput(out));
126 }
127 };
128
129
130 /**
131 * Terminator class of recursive JSTDObjectWriter class.
132 */
133 template<class JHead_t>
135 public JSTDObjectWriter<JHead_t>
136 {};
137}
138
139#endif
Template interface of object output for single data type.
virtual bool put(const T &object)=0
Object output.
Implementation of object output from STD container.
JSTDObjectWriter(const JOutput_t &out)
Constructor.
JSTDObjectWriter()
Default constructor.
void set(const JOutput_t &out)
Set output.
JSTDObjectWriter(JOutput_t &out)
Constructor.
void set(JOutput_t &out)
Set output.
Auxiliary classes and methods for language specific functionality.
JSTDObjectOutput< T > * getSTDObjectOutput(const JSTDObjectOutput< T > &out)
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.
Type list.
Definition JTypeList.hh:23