Jpp  19.1.0
the software that should make you happy
JDAQFileWriter.hh
Go to the documentation of this file.
1 #ifndef __JSUPPORT__JDAQFILEWRITER__
2 #define __JSUPPORT__JDAQFILEWRITER__
3 
4 #include <ostream>
5 
7 #include "JIO/JStreamIO.hh"
8 #include "JDAQ/JDAQPreambleIO.hh"
10 #include "JLang/JObjectOutput.hh"
11 #include "JLang/JTypeList.hh"
12 #include "JLang/JNullType.hh"
13 #include "JLang/JObjectOutput.hh"
14 #include "JLang/JConversion.hh"
15 
16 
17 /**
18  * \author mdejong
19  */
20 
21 namespace JSUPPORT {}
22 namespace JPP { using namespace JSUPPORT; }
23 
24 namespace JSUPPORT {
25 
26  using JIO::JWriter;
28  using JIO::JStreamWriter;
33  using JLANG::JNullOutput;
34  using JLANG::JTypeList;
35  using JLANG::JNullType;
36 
37 
38  /**
39  * Auxiliary class for DAQ object writing to binary stream.
40  */
41  template<class T, bool = JLANG::JConversion<T,JDAQPreamble>::is_derived>
43 
44 
45  /**
46  * Implementation of object output for DAQ compatible data types.
47  *
48  * This class implements the JLANG::JObjectOutput interface.
49  */
50  template<class T>
51  class JDAQWriterObjectOutput<T,true> :
52  public JWriterObjectOutput<T>
53  {
54  protected:
55  /**
56  * Constructor.
57  *
58  * \param writer JWriter output
59  */
61  JWriterObjectOutput<T>(writer)
62  {}
63  };
64 
65 
66  /**
67  * Implementation of object output for DAQ incompatible data types.
68  *
69  * This class implements the JLANG::JObjectOutput interface by doing nothing.
70  */
71  template<class T>
72  class JDAQWriterObjectOutput<T,false> :
73  public JNullOutput<T>
74  {
75  protected:
76  /**
77  * Constructor.
78  *
79  * \param writer JWriter output
80  */
82  {}
83  };
84 
85 
86  /**
87  * Implementation of object output to binary file for single data type.
88  *
89  * This class implements the JLANG::JObjectOutput interface.
90  */
91  template<class T>
92  class JDAQWriter :
93  public JDAQWriterObjectOutput<T>
94  {
95  protected:
96  /**
97  * Constructor.
98  *
99  * \param writer JWriter output
100  */
101  JDAQWriter(JWriter& writer) :
102  JDAQWriterObjectOutput<T>(writer)
103  {}
104  };
105 
106 
107  /**
108  * Implementation of object output to binary file for multiple data types.
109  *
110  * This class recursively implements the JLANG::JObjectOutput interface
111  * for all data types by deriving from:
112  * - JDAQWriter<JHead_t>; and
113  * - JDAQWriter<JTail_t>.
114  */
115  template<class JHead_t, class JTail_t>
116  class JDAQWriter< JTypeList<JHead_t, JTail_t> > :
117  public virtual JObjectOutput< JTypeList<JHead_t, JTail_t> >,
118  public JDAQWriter<JHead_t>,
119  public JDAQWriter<JTail_t>
120 
121  {
122  protected:
123  /**
124  * Constructor.
125  *
126  * \param writer JWriter output
127  */
128  JDAQWriter(JWriter& writer) :
129  JDAQWriter<JHead_t>(writer),
130  JDAQWriter<JTail_t>(writer)
131  {}
132  };
133 
134 
135  /**
136  * Terminator class of recursive JDAQWriter class.
137  */
138  template<class JHead_t>
139  class JDAQWriter< JTypeList<JHead_t, JNullType> > :
140  public JDAQWriter<JHead_t>
141  {
142  protected:
143  /**
144  * Constructor.
145  *
146  * \param writer JWriter output
147  */
148  JDAQWriter(JWriter& writer) :
149  JDAQWriter<JHead_t>(writer)
150  {}
151  };
152 
153 
154  /**
155  * Object(s) writing to binary file (i.e.\ .dat).
156  *
157  * This class implements the JLANG::JAccessibleObjectOutput interface.
158  */
159  template<class T>
162  public JStreamWriter,
163  public JDAQWriter<T>,
164  public JAccessibleObjectOutput<T>
165  {
166  public:
167  /**
168  * Default constructor.
169  */
172  JStreamWriter(static_cast<std::ostream&>(*this)),
173  JDAQWriter<T>(static_cast<JWriter&> (*this))
174  {}
175  };
176 }
177 
178 #endif
Binary output based on std::ostream.
Definition: JStreamIO.hh:83
Implementation of object output using JIO::JWriter for single data type.
Interface for binary output.
Interface for object output with named access.
Template interface of object output for single data type.
Object(s) writing to binary file (i.e. .dat).
JDAQFileWriter()
Default constructor.
JDAQWriterObjectOutput(JWriter &writer)
Constructor.
JDAQWriterObjectOutput(JWriter &writer)
Constructor.
Auxiliary class for DAQ object writing to binary stream.
Implementation of object output to binary file for single data type.
JDAQWriter(JWriter &writer)
Constructor.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Support classes and methods for experiment specific I/O.
Definition: JDataWriter.cc:38
Definition: JSTDTypes.hh:14
Implementation of null output for single data type.
Auxiliary class for no type definition.
Definition: JNullType.hh:19
Type list.
Definition: JTypeList.hh:23