Jpp
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:
29 
30  /**
31  * Default constructor.
32  */
34  {}
35 
36 
37  /**
38  * Constructor.
39  *
40  * \param out output iterator
41  */
42  template<class JOutputIterator_t>
44  {
45  this->reset(out.clone());
46  }
47 
48 
49  /**
50  * Constructor.
51  *
52  * \param buffer output buffer
53  */
54  template<class JContainer_t>
55  JSTDObjectWriter(JContainer_t& buffer)
56  {
57  this->reset(getObjectOutput(buffer).clone());
58  }
59 
60 
61  /**
62  * Set output buffer.
63  *
64  * \param buffer output buffer
65  */
66  template<class JContainer_t>
67  void set(JContainer_t& buffer)
68  {
69  this->reset(getObjectOutput(buffer).clone());
70  }
71  };
72 
73 
74 
75  /**
76  * Implementation of object output from STD container for multiple data types.
77  *
78  * This class recursively implements the JLANG::JObjectOutput interface
79  * for all data types by deriving from:
80  * - JSTDObjectWriter<JHead_t>; and
81  * - JSTDObjectWriter<JTail_t>.
82  */
83  template<class JHead_t, class JTail_t>
84  struct JSTDObjectWriter< JTypeList<JHead_t, JTail_t> > :
85  public virtual JObjectOutput< JTypeList<JHead_t, JTail_t> >,
86  public JSTDObjectWriter<JHead_t>,
87  public JSTDObjectWriter<JTail_t>
88  {
93 
94 
95  /**
96  * Set output puffer.
97  *
98  * \param buffer output buffer
99  */
100  template<class JContainer_t>
101  void set(JContainer_t& buffer)
102  {
103  this->reset(getObjectOutput(buffer).clone());
104  }
105  };
106 
107 
108  /**
109  * Terminator class of recursive JSTDObjectWriter class.
110  */
111  template<class JHead_t>
112  struct JSTDObjectWriter< JTypeList<JHead_t, JNullType> > :
113  public JSTDObjectWriter<JHead_t>
114  {};
115 }
116 
117 #endif
JObjectWriter.hh
JLANG::JSTDObjectWriter::JSTDObjectWriter
JSTDObjectWriter()
Default constructor.
Definition: JSTDObjectWriter.hh:33
JLANG::JNullType
Auxiliary class for no type definition.
Definition: JNullType.hh:19
JLANG::JObjectWriter
Auxiliary class for object writing to a named device.
Definition: JObjectWriter.hh:25
JLANG::JObjectOutput
Forward declarations for definitions of I/O redirect and pipe operators.
Definition: JObjectIterator.hh:31
JLANG::JObject< JSTDObjectOutput< JOutputIterator_t > >::clone
data_type * clone() const
Get clone from temporary object.
Definition: JObject.hh:42
JPP
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JAAnetToolkit.hh:37
JLANG::JSTDObjectOutput
Implementation of object output for STD compatible output iterator.
Definition: JSTDObjectOutput.hh:26
JLANG::JSTDObjectWriter::set
void set(JContainer_t &buffer)
Set output buffer.
Definition: JSTDObjectWriter.hh:67
JLANG::JTypeList
Type list.
Definition: JTypeList.hh:22
JLANG::JSTDObjectWriter::JSTDObjectWriter
JSTDObjectWriter(JContainer_t &buffer)
Constructor.
Definition: JSTDObjectWriter.hh:55
JLANG::JSTDObjectWriter< JTypeList< JHead_t, JTail_t > >::set
void set(JContainer_t &buffer)
Set output puffer.
Definition: JSTDObjectWriter.hh:101
JLANG::getObjectOutput
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.
Definition: JSTDObjectOutput.hh:73
JLANG::JSharedPointer< JObjectOutput< T > >::reset
virtual void reset()
Reset pointer.
Definition: JSharedPointer.hh:171
JLANG
Auxiliary classes and methods for language specific functionality.
Definition: JAbstractClass.hh:10
JLANG::JSTDObjectWriter
Implementation of object output from STD container.
Definition: JSTDObjectWriter.hh:24
JLANG::JSTDObjectWriter::JSTDObjectWriter
JSTDObjectWriter(const JSTDObjectOutput< JOutputIterator_t > &out)
Constructor.
Definition: JSTDObjectWriter.hh:43
JSTDObjectOutput.hh