Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JWriterObjectOutput.hh
Go to the documentation of this file.
1 #ifndef __JIO__JWRITEROBJECTITERATOR__
2 #define __JIO__JWRITEROBJECTITERATOR__
3 
4 #include "JLang/JObjectOutput.hh"
5 #include "JLang/JTypeList.hh"
6 #include "JLang/JNullType.hh"
7 #include "JIO/JSerialisable.hh"
8 
9 
10 /**
11  * \author mdejong
12  */
13 
14 namespace JIO {}
15 namespace JPP { using namespace JIO; }
16 
17 namespace JIO {
18 
20  using JLANG::JTypeList;
21  using JLANG::JNullType;
22 
23 
24  /**
25  * Implementation of object output using JIO::JWriter for single data type.
26  *
27  * This class implements the JLANG::JObjectOutput interface.
28  */
29  template<class T>
31  public virtual JObjectOutput<T>
32  {
33  public:
34  /**
35  * Constructor.
36  *
37  * \param writer writer output
38  */
40  out(writer)
41  {}
42 
43 
44  /**
45  * Object output.
46  *
47  * \param object object
48  * \return true if OK; else false
49  */
50  virtual bool put(const T& object)
51  {
52  out << object;
53 
54  return (bool) out;
55  }
56 
57  private:
59  };
60 
61 
62  /**
63  * Implementation of object output for multiple data types.
64  *
65  * This class recursively implements the JLANG::JObjectOutput interface
66  * for all data types by deriving from:
67  * - JWriterObjectOutput<JHead_t>; and
68  * - JWriterObjectOutput<JTail_t>.
69  */
70  template<class JHead_t, class JTail_t>
71  class JWriterObjectOutput< JTypeList<JHead_t, JTail_t> > :
72  public virtual JObjectOutput< JTypeList<JHead_t, JTail_t> >,
73  public JWriterObjectOutput<JHead_t>,
74  public JWriterObjectOutput<JTail_t>
75 
76  {
77  public:
78  /**
79  * Constructor.
80  *
81  * \param writer writer output
82  */
84  JWriterObjectOutput<JHead_t>(writer),
85  JWriterObjectOutput<JTail_t>(writer)
86  {}
87  };
88 
89 
90  /**
91  * Terminator class of recursive JWriterObjectOutput class.
92  */
93  template<class JHead_t>
95  public JWriterObjectOutput<JHead_t>
96  {
97  public:
98  /**
99  * Constructor.
100  *
101  * \param writer writer output
102  */
104  JWriterObjectOutput<JHead_t>(writer)
105  {}
106  };
107 }
108 
109 #endif
Interface for binary output.
virtual bool put(const T &object)
Object output.
Type list.
Definition: JTypeList.hh:22
do set_variable OUTPUT_DIRECTORY $WORKDIR T
Auxiliary class for no type definition.
Definition: JNullType.hh:19
JWriterObjectOutput(JWriter &writer)
Constructor.
Forward declarations for definitions of I/O redirect and pipe operators.
Implementation of object output using JIO::JWriter for single data type.