Jpp  master_rocky-40-g5f0272dcd
the software that should make you happy
JDAQEventIO.hh
Go to the documentation of this file.
1 #ifndef __JDAQEVENT_IO__
2 #define __JDAQEVENT_IO__
3 
5 
6 #include "JIO/JSerialisable.hh"
7 #include "JIO/JSTDIO.hh"
8 
9 #include "JDAQ/JDAQSizeof.hh"
10 #include "JDAQ/JDAQPreambleIO.hh"
12 #include "JDAQ/JDAQKeyHitIO.hh"
14 
15 /**
16  * \author mdejong
17  */
18 namespace KM3NETDAQ {
19 
20  /**
21  * Get size of object.
22  *
23  * \param object DAQ event
24  * \return number of bytes
25  */
26  inline size_t getSizeof(const JDAQEvent& object)
27  {
28  return (getSizeof<JDAQPreamble>() +
29  sizeof(Version_t) +
31  getSizeof(static_cast<const JDAQEvent&>(object).triggeredHits) +
32  getSizeof(static_cast<const JDAQEvent&>(object).snapshotHits));
33  }
34 
35 
36  /**
37  * Read DAQ event from input.
38  *
39  * \param in reader
40  * \param object DAQ event
41  * \return reader
42  */
43  inline JReader& operator>>(JReader& in, JDAQEvent& object)
44  {
45  Version_t version;
46 
47  in >> static_cast<JDAQPreamble&> (object);
48  in >> version;
49  in >> static_cast<JDAQEventHeader&>(object);
50  in >> object.triggeredHits;
51  in >> object.snapshotHits;
52 
53  return in;
54  }
55 
56 
57  /**
58  * Write DAQ event to output.
59  *
60  * \param out writer
61  * \param object DAQ event
62  * \return writer
63  */
64  inline JWriter& operator<<(JWriter& out, const JDAQEvent& object)
65  {
66  out << JDAQPreamble::getDAQPreamble(object);
67  out << JDAQEvent::Class_Version();
68  out << static_cast<const JDAQEventHeader&>(object);
69  out << object.triggeredHits;
70  out << object.snapshotHits;
71 
72  return out;
73  }
74 }
75 
76 #endif
STD extensions for binary I/O.
Interface for binary input.
Interface for binary output.
static JDAQPreamble getDAQPreamble(const T &object)
Get DAQ preamble.
Definition: JDAQPreamble.hh:76
KM3NeT DAQ data structures and auxiliaries.
Definition: DataQueue.cc:39
JReader & operator>>(JReader &in, JDAQChronometer &chronometer)
Read DAQ chronometer from input.
size_t getSizeof(const JDAQEvent &object)
Get size of object.
Definition: JDAQEventIO.hh:26
size_t getSizeof< JDAQPreamble >()
Get size of type.
size_t getSizeof< JDAQEventHeader >()
Get size of type.
JWriter & operator<<(JWriter &out, const JDAQChronometer &chronometer)
Write DAQ chronometer to output.