Jpp 19.3.0-rc.2
the software that should make you happy
Loading...
Searching...
No Matches
JWriterObjectOutput.hh
Go to the documentation of this file.
1#ifndef __JIO__JWRITEROBJECTITERATOR__
2#define __JIO__JWRITEROBJECTITERATOR__
3
5#include "JLang/JTypeList.hh"
6#include "JLang/JNullType.hh"
8#include "JLang/JBool.hh"
10
11
12/**
13 * \author mdejong
14 */
15
16namespace JIO {}
17namespace JPP { using namespace JIO; }
18
19namespace JIO {
20
22 using JLANG::JTypeList;
23 using JLANG::JNullType;
24
25
26 /**
27 * Implementation of object output using JIO::JWriter for single data type.
28 *
29 * This class implements the JLANG::JObjectOutput interface.
30 */
31 template<class T>
33 public virtual JObjectOutput<T>
34 {
35 public:
36 /**
37 * Constructor.
38 *
39 * \param writer writer output
40 */
42 out(writer)
43 {}
44
45
46 /**
47 * Object output.
48 *
49 * \param object object
50 * \return true if OK; else false
51 */
52 virtual bool put(const T& object) override
53 {
55 }
56
57 private:
58 bool put(const T& object, JLANG::JBool<true>) { return (bool) object.write(out); }
59 bool put(const T& object, JLANG::JBool<false>) { return (bool) (out << object); }
60
62 };
63
64
65 /**
66 * Implementation of object output for multiple data types.
67 *
68 * This class recursively implements the JLANG::JObjectOutput interface
69 * for all data types by deriving from:
70 * - JWriterObjectOutput<JHead_t>; and
71 * - JWriterObjectOutput<JTail_t>.
72 */
73 template<class JHead_t, class JTail_t>
74 class JWriterObjectOutput< JTypeList<JHead_t, JTail_t> > :
75 public virtual JObjectOutput< JTypeList<JHead_t, JTail_t> >,
76 public JWriterObjectOutput<JHead_t>,
77 public JWriterObjectOutput<JTail_t>
78
79 {
80 public:
81 /**
82 * Constructor.
83 *
84 * \param writer writer output
85 */
87 JWriterObjectOutput<JHead_t>(writer),
88 JWriterObjectOutput<JTail_t>(writer)
89 {}
90 };
91
92
93 /**
94 * Terminator class of recursive JWriterObjectOutput class.
95 */
96 template<class JHead_t>
98 public JWriterObjectOutput<JHead_t>
99 {
100 public:
101 /**
102 * Constructor.
103 *
104 * \param writer writer output
105 */
107 JWriterObjectOutput<JHead_t>(writer)
108 {}
109 };
110}
111
112#endif
Implementation of object output using JIO::JWriter for single data type.
JWriterObjectOutput(JWriter &writer)
Constructor.
bool put(const T &object, JLANG::JBool< true >)
virtual bool put(const T &object) override
Object output.
bool put(const T &object, JLANG::JBool< false >)
Interface for binary output.
Template interface of object output for single data type.
Auxiliary classes and methods for binary I/O.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary template class for type bool.
Definition JBool.hh:21
Template class test for polymorphism.
Auxiliary class for no type definition.
Definition JNullType.hh:19
Type list.
Definition JTypeList.hh:23