Jpp test-rotations-old
the software that should make you happy
Loading...
Searching...
No Matches
clb_datagram.hh
Go to the documentation of this file.
1#ifndef __CLBDATAGRAM_HH
2#define __CLBDATAGRAM_HH
3
6#include <datatypespec.hh>
8#include <boost/atomic.hpp>
9#include <cassert>
10
11/**
12 * \author cpellegrino
13 */
14
16{
17
18 public:
19
20 static const size_t DGRAM_CAPACITY = 10000; // It should be at
21 // least the size of a
22 // jumbo frame payload
23 // (9000)
24
25 private:
26
28 size_t m_size;
29
32
33 public:
34
35 static boost::atomic<unsigned int> n_obj;
36
38 :
39 m_size(0)
40 {
41 ++n_obj;
42 }
43
45 {
46 --n_obj;
47 }
48
49 size_t size() const
50 {
51 return m_size;
52 }
53
54 void resize(size_t s)
55 {
56 assert(s <= DGRAM_CAPACITY);
57 m_size = s;
58 }
59
60 void clear()
61 {
62 m_size = 0;
63 }
64
65 char* raw()
66 {
67 return m_block;
68 }
69
70 const char* raw() const
71 {
72 return m_block;
73 }
74
75 size_t capacity() const
76 {
77 return DGRAM_CAPACITY;
78 }
79
80 uint32_t getUDPSequenceNumber() const
81 {
83 }
84
85 uint32_t getRunNumber() const
86 {
87 return getCLBCommonHeader()->runNumber();
88 }
89
91 {
92 return static_cast<const CLBCommonHeader*>(
93 static_cast<const void*>(m_block));
94 }
95
96 const char* getPayload() const
97 {
98 return m_block + sizeof(CLBCommonHeader);
99 }
100
101 bool isOptical() const
102 {
103 return is_optical(getCLBCommonHeader()->dataType());
104 }
105
106 bool isAcoustic() const
107 {
108 return is_acoustic(getCLBCommonHeader()->dataType());
109 }
110
111 bool hasInfoWord() const
112 {
113 return isAcoustic() && is_infoword(getPayload());
114 }
115
116 size_t getPayloadSize() const
117 {
118 return m_size <= sizeof(CLBCommonHeader) ?
119 0 :
120 (m_size - sizeof(CLBCommonHeader));
121 }
122
123 bool hasValidTimeStamp() const
124 {
126 }
127
128 bool isTrailer() const
129 {
131 }
132};
133#endif
uint32_t getRunNumber() const
void resize(size_t s)
char * raw()
bool isTrailer() const
static boost::atomic< unsigned int > n_obj
bool isAcoustic() const
const CLBCommonHeader * getCLBCommonHeader() const
bool hasInfoWord() const
const char * getPayload() const
size_t getPayloadSize() const
CLBDataGram & operator=(const CLBDataGram &)
const char * raw() const
static const size_t DGRAM_CAPACITY
CLBDataGram(const CLBDataGram &)
bool hasValidTimeStamp() const
size_t size() const
bool isOptical() const
size_t capacity() const
char m_block[DGRAM_CAPACITY]
uint32_t getUDPSequenceNumber() const
bool validTimeStamp(CLBCommonHeader const &header)
bool is_acoustic(unsigned int dt)
bool is_optical(unsigned int dt)
bool is_infoword(const void *const data)
Definition infoword.hh:93
uint32_t udpSequenceNumber() const
uint32_t runNumber() const