Jpp 19.3.0-rc.2
the software that should make you happy
Loading...
Searching...
No Matches
JDAQFrameIO.hh
Go to the documentation of this file.
1#ifndef __JDAQFRAME_IO__
2#define __JDAQFRAME_IO__
3
5
7
8#include "JDAQ/JDAQHitIO.hh"
9
10/**
11 * \author mdejong
12 */
13namespace KM3NETDAQ {
14
15 /**
16 * Get size of object.
17 *
18 * \param object DAQ frame
19 * \return number of bytes
20 */
21 inline size_t getSizeof(const JDAQFrame& object)
22 {
23 return sizeof(JDAQFrame::numberOfHits) + object.numberOfHits * sizeof(JDAQHit);
24 }
25
26
27 /**
28 * Read DAQ frame from input.
29 *
30 * \param in reader
31 * \param frame DAQ frame
32 * \return reader
33 */
34 inline JReader& operator>>(JReader& in, JDAQFrame& frame)
35 {
36 frame.clear();
37
38 int number_of_hits;
39
40 in >> number_of_hits;
41
42 frame.resize(number_of_hits);
43
44 in.read((char*) frame.buffer, frame.numberOfHits * sizeof(JDAQHit));
45
46 return in;
47 }
48
49
50 /**
51 * Write DAQ frame to output.
52 *
53 * \param out writer
54 * \param frame DAQ frame
55 * \return writer
56 */
57 inline JWriter& operator<<(JWriter& out, const JDAQFrame& frame)
58 {
59 out << frame.numberOfHits;
60
61 out.write((char*) frame.buffer, frame.numberOfHits * sizeof(JDAQHit));
62
63 return out;
64 }
65}
66
67#endif
Interface for binary input.
Interface for binary output.
virtual int read(char *buffer, const int length)=0
Read byte array.
virtual int write(const char *buffer, const int length)=0
Write byte array.
void resize(const int number_of_hits)
Resize internal buffer.
Definition JDAQFrame.hh:273
void clear()
Clear data.
Definition JDAQFrame.hh:154
Hit data structure.
Definition JDAQHit.hh:35
KM3NeT DAQ data structures and auxiliaries.
Definition DataQueue.cc:39
JWriter & operator<<(JWriter &out, const JDAQChronometer &chronometer)
Write DAQ chronometer to output.
JReader & operator>>(JReader &in, JDAQChronometer &chronometer)
Read DAQ chronometer from input.
size_t getSizeof()
Definition of method to get size of data type.