Jpp test-rotations-old
the software that should make you happy
Loading...
Searching...
No Matches
JDAQPreamble.hh
Go to the documentation of this file.
1#ifndef __JDAQPREAMBLE__
2#define __JDAQPREAMBLE__
3
4#include <ostream>
5#include <iomanip>
6
10
11
12/**
13 * \author mdejong
14 */
15
16namespace KM3NETDAQ {
17
18 /**
19 * DAQ preamble.
20 *
21 * The data type is determined by the return value of method getDataType().\n
22 * This method should be overloaded so that each data type is uniquely mapped to an integer value.
23 *
24 * The size and type information of this object can be used for RTTI.
25 */
28 public TObject
29 {
30 protected:
31
32 /**
33 * Constructor.
34 *
35 * \param type data type of derived class
36 */
37 template<class T>
41
42 public:
43
44 friend size_t getSizeof<JDAQPreamble>();
46 friend JWriter& operator<<(JWriter&, const JDAQPreamble&);
47
48 /**
49 * Default constructor.
50 */
54
55
56 /**
57 * Virtual destructor.
58 */
59 virtual ~JDAQPreamble()
60 {}
61
62
63 /**
64 * Get DAQ preamble.
65 *
66 * This method should be used for binary I/O to get the actual data for the given object.\n
67 * To this end, the following method should be overloaded for the corresponding data type.
68 * <pre>
69 * size_t getSizeof(const T&);
70 * </pre>
71 *
72 * \param object object
73 * \return preamble
74 */
75 template<class T>
76 static JDAQPreamble getDAQPreamble(const T& object)
77 {
78 static JDAQPreamble preamble;
79
80 preamble.length = getSizeof(object);
82
83 return preamble;
84 }
85
86
87 /**
88 * Print DAQ preamble.
89 *
90 * \param out output stream
91 * \param preamble JDAQPreamble
92 * \return output stream
93 */
94 friend inline std::ostream& operator<<(std::ostream& out, const JDAQPreamble& preamble)
95 {
96 using namespace std;
97
98 out << setw(8) << preamble.length;
99 out << ' ';
100 out << setw(6) << preamble.type;
101
102 return out;
103 }
104
105
107 };
108}
109
110#endif
Interface for binary input.
Interface for binary output.
Simple data structure for the DAQ preamble required for a correct calculation of the object size for ...
JDAQPreamble()
Default constructor.
JDAQPreamble(const JDAQType< T > &type)
Constructor.
friend JWriter & operator<<(JWriter &, const JDAQPreamble &)
Write DAQ preamble to output.
static JDAQPreamble getDAQPreamble(const T &object)
Get DAQ preamble.
ClassDef(JDAQPreamble, 1)
friend size_t getSizeof()
Definition of method to get size of data type.
friend std::ostream & operator<<(std::ostream &out, const JDAQPreamble &preamble)
Print DAQ preamble.
friend JReader & operator>>(JReader &, JDAQPreamble &)
Read DAQ preamble from input.
virtual ~JDAQPreamble()
Virtual destructor.
KM3NeT DAQ data structures and auxiliaries.
Definition DataQueue.cc:39
int getDataType()
Template definition for method returning data type.
size_t getSizeof< JDAQPreamble >()
Get size of type.
Auxiliary class for a DAQ type holder.