Jpp 19.3.0-rc.1
the software that should make you happy
Loading...
Searching...
No Matches
JTreeWriterObjectOutput.hh
Go to the documentation of this file.
1#ifndef __JROOT__JTREEWRITEROBJECTOUTPUT__
2#define __JROOT__JTREEWRITEROBJECTOUTPUT__
3
4#include "JLang/JTypeList.hh"
5#include "JLang/JNullType.hh"
8
9
10/**
11 * \author mdejong
12 */
13
14namespace JROOT {}
15namespace JPP { using namespace JROOT; }
16
17namespace JROOT {
18
20 using JLANG::JTypeList;
21 using JLANG::JNullType;
22
23
24 template<class T> class JRootCreateFlatTree : public std::false_type {};
25
26 /**
27 * JTreeWriter object output.
28 *
29 * This class implements the JLANG::JObjectOutput interface.
30 */
31 template<class T>
33 public virtual JObjectOutput<T>
34 {
35 protected:
36 /**
37 * Default constructor.
38 */
41 del(true)
42 {}
43
44
45 /**
46 * Destructor.
47 */
49 {
50 if (del) {
51 delete out;
52 }
53 }
54
55
56 /**
57 * Set directory.
58 *
59 * \param dir pointer to directory
60 */
61 void SetDirectory(TDirectory* dir)
62 {
63 out->SetDirectory(dir);
64
65 del = (dir == NULL);
66 }
67
68
70 bool del; // delete TTree on destruction
71
72 public:
73 /**
74 * Get TreeWriter.
75 *
76 * \return TreeWriter
77 */
79 {
80 return *out;
81 }
82
83
84 /**
85 * Object output.
86 *
87 * \param object object
88 * \return true if OK; else false
89 */
90 virtual bool put(const T& object) override
91 {
92 return (out->Write(object) > 0);
93 }
94
95
96 /**
97 * Set circular buffer size.
98 *
99 * \param size number of entries
100 */
101 void SetCircular(Long64_t size)
102 {
103 out->SetCircular(size);
104 }
105
106
107 /**
108 * Reset TTree.
109 */
110 void Reset()
111 {
112 out->Reset();
113 }
114
115 private:
120 };
121
122
123 /**
124 * Implementation of JTreeWriterObjectOutput for multiple data types.
125 *
126 * This class recursively implements the JLANG::JObjectOutput interface
127 * for all data types by deriving from:
128 * - JTreeWriterObjectOutput<JHead_t>; and
129 * - JTreeWriterObjectOutput<JTail_t>.
130 */
131 template<class JHead_t, class JTail_t>
132 class JTreeWriterObjectOutput< JTypeList<JHead_t, JTail_t> > :
133 public virtual JObjectOutput< JTypeList<JHead_t, JTail_t> >,
134 public JTreeWriterObjectOutput<JHead_t>,
135 public JTreeWriterObjectOutput<JTail_t>
136
137 {
138 protected:
139 /**
140 * Set directory.
141 *
142 * \param dir pointer to directory
143 */
149
150 public:
151 using JTreeWriterObjectOutput<JHead_t>::put;
152 using JTreeWriterObjectOutput<JTail_t>::put;
153
154 /**
155 * Set circular buffer size.
156 *
157 * \param size number of entries
158 */
164
165
166 /**
167 * Reset TTree.
168 */
174 };
175
176
177 /**
178 * Terminator class of recursive JTreeWriterObjectOutput class.
179 */
180 template<class JHead_t>
182 public JTreeWriterObjectOutput<JHead_t>
183 {};
184}
185
186#endif
TTree writing for template data type.
Template interface of object output for single data type.
JTreeWriter< T, JRootCreateFlatTree< T >::value > * out
JTreeWriterObjectOutput()
Default constructor.
JTreeWriterObjectOutput & operator=(JTreeWriterObjectOutput &&)
void SetDirectory(TDirectory *dir)
Set directory.
JTreeWriterObjectOutput(const JTreeWriterObjectOutput &)
virtual bool put(const T &object) override
Object output.
void SetCircular(Long64_t size)
Set circular buffer size.
JTreeWriterObjectOutput & operator=(const JTreeWriterObjectOutput &)
JTreeWriterObjectOutput(JTreeWriterObjectOutput &&)
JTreeWriter< T > & getTreeWriter()
Get TreeWriter.
Auxiliary class for default template TTree writing.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary classes and methods for ROOT I/O.
JTreeParameters & getTreeParameters()
Template definition for method returning TTree parameters.
Auxiliary class for no type definition.
Definition JNullType.hh:19
Type list.
Definition JTypeList.hh:23