Jpp test-rotations-old
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
72
73
74 /**
75 * Implementation of object output from STD container for multiple data types.
76 *
77 * This class recursively implements the JLANG::JObjectOutput interface
78 * for all data types by deriving from:
79 * - JSTDObjectWriter<JHead_t>; and
80 * - JSTDObjectWriter<JTail_t>.
81 */
82 template<class JHead_t, class JTail_t>
83 struct JSTDObjectWriter< JTypeList<JHead_t, JTail_t> > :
84 public virtual JObjectOutput< JTypeList<JHead_t, JTail_t> >,
85 public JSTDObjectWriter<JHead_t>,
86 public JSTDObjectWriter<JTail_t>
87 {
88 using JSTDObjectWriter<JHead_t>::put;
89 using JSTDObjectWriter<JTail_t>::put;
90 using JSTDObjectWriter<JHead_t>::reset;
91 using JSTDObjectWriter<JTail_t>::reset;
92
93
94 /**
95 * Set output puffer.
96 *
97 * \param buffer output buffer
98 */
99 template<class JContainer_t>
100 void set(JContainer_t& buffer)
101 {
102 this->reset(getObjectOutput(buffer).clone());
103 }
104 };
105
106
107 /**
108 * Terminator class of recursive JSTDObjectWriter class.
109 */
110 template<class JHead_t>
112 public JSTDObjectWriter<JHead_t>
113 {};
114}
115
116#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