Jpp 19.3.0-rc.3
the software that should make you happy
Loading...
Searching...
No Matches
JRootStreamObjectOutput.hh
Go to the documentation of this file.
1#ifndef __JROOT__JSTREAMOBJECTOUTPUT__
2#define __JROOT__JSTREAMOBJECTOUTPUT__
3
4#include <string>
5
7#include "JLang/JTypeList.hh"
8#include "JLang/JNullType.hh"
9
11
12
13/**
14 * \author mdejong
15 */
16
17namespace JROOT {}
18namespace JPP { using namespace JROOT; }
19
20namespace JROOT {
21
23 using JLANG::JTypeList;
24 using JLANG::JNullType;
25
26
27 /**
28 * Template implementation of stream output for single data type based on ROOT dictionary.
29 *
30 * This class implements the JLANG::JObjectOutput interface.
31 */
32 template<class T>
34 public virtual JObjectOutput<T>
35 {
36 public:
37 /**
38 * Constructor.
39 *
40 * \param out output stream
41 * \param sep token separator
42 */
44 const std::string& sep = "") :
45 __out(out),
46 __sep(sep)
47 {}
48
49
50 /**
51 * Object output.
52 *
53 * \param object object
54 * \return true if OK; else false
55 */
56 virtual bool put(const T& object) override
57 {
58 __out.putObject(object) << __sep;
59
60 return (bool) __out;
61 }
62
63
64 /**
65 * Get token separator.
66 *
67 * \return separator
68 */
69 const std::string& getSeparator() const
70 {
71 return this->__sep;
72 }
73
74
75 /**
76 * Set token separator.
77 *
78 * \param sep separator
79 */
80 void setSeparator(const std::string& sep)
81 {
82 this->__sep = sep;
83 }
84
85 private:
87 std::string __sep;
88 };
89
90
91 /**
92 * Template specialisationimplementation of stream object output for multiple data types.
93 *
94 * This class recursively implements the JLANG::JObjectOutput interface
95 * for all data types by deriving from:
96 * - JRootStreamObjectOutput<JHead_t>; and
97 * - JRootStreamObjectOutput<JTail_t>.
98 */
99 template<class JHead_t, class JTail_t>
100 class JRootStreamObjectOutput< JTypeList<JHead_t, JTail_t> > :
101 public virtual JObjectOutput< JTypeList<JHead_t, JTail_t> >,
102 public JRootStreamObjectOutput<JHead_t>,
103 public JRootStreamObjectOutput<JTail_t>
104
105 {
106 public:
107
108 using JRootStreamObjectOutput<JHead_t>::put;
109 using JRootStreamObjectOutput<JTail_t>::put;
110
111
112 /**
113 * Constructor.
114 *
115 * \param out output stream
116 * \param sep token separator
117 */
119 const std::string& sep = "") :
120 JRootStreamObjectOutput<JHead_t>(out, sep),
121 JRootStreamObjectOutput<JTail_t>(out, sep)
122 {}
123
124
125 /**
126 * Set token separator.
127 *
128 * \param sep separator
129 */
135 };
136
137
138 /**
139 * Terminator class of recursive JRootStreamObjectOutput class.
140 */
141 template<class JHead_t>
143 public JRootStreamObjectOutput<JHead_t>
144 {
145 public:
146
147 using JRootStreamObjectOutput<JHead_t>::put;
148
149
150 /**
151 * Constructor.
152 *
153 * \param out output stream
154 * \param sep token separator
155 */
157 const std::string& sep = "") :
158 JRootStreamObjectOutput<JHead_t>(out, sep)
159 {}
160 };
161}
162
163#endif
ASCII I/O of objects with ROOT dictionary.
Template interface of object output for single data type.
JRootStreamObjectOutput(JRootWriter &out, const std::string &sep="")
Constructor.
void setSeparator(const std::string &sep)
Set token separator.
JRootStreamObjectOutput(JRootWriter &out, const std::string &sep="")
Constructor.
Template implementation of stream output for single data type based on ROOT dictionary.
JRootStreamObjectOutput(JRootWriter &out, const std::string &sep="")
Constructor.
virtual bool put(const T &object) override
Object output.
const std::string & getSeparator() const
Get token separator.
void setSeparator(const std::string &sep)
Set token separator.
Implementation for ASCII output of objects with ROOT dictionary.
JRootWriter & putObject(const T &object)
Write object.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary classes and methods for ROOT I/O.
Auxiliary class for no type definition.
Definition JNullType.hh:19
Type list.
Definition JTypeList.hh:23