Jpp  17.1.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 
30  CLBDataGram(const CLBDataGram&);
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  {
130  return isOptical() && ::isTrailer(*getCLBCommonHeader());
131  }
132 };
133 #endif
uint32_t getRunNumber() const
Definition: clb_datagram.hh:85
size_t capacity() const
Definition: clb_datagram.hh:75
CLBDataGram & operator=(const CLBDataGram &)
static const size_t DGRAM_CAPACITY
Definition: clb_datagram.hh:20
bool is_acoustic(unsigned int dt)
Definition: datatypespec.hh:17
const char * getPayload() const
Definition: clb_datagram.hh:96
bool hasValidTimeStamp() const
const CLBCommonHeader * getCLBCommonHeader() const
Definition: clb_datagram.hh:90
size_t getPayloadSize() const
void resize(size_t s)
Definition: clb_datagram.hh:54
bool is_infoword(const void *const data)
Definition: infoword.hh:93
uint32_t runNumber() const
size_t size() const
Definition: clb_datagram.hh:49
size_t m_size
Definition: clb_datagram.hh:28
const char * raw() const
Definition: clb_datagram.hh:70
uint32_t getUDPSequenceNumber() const
Definition: clb_datagram.hh:80
bool hasInfoWord() const
bool isAcoustic() const
bool isTrailer() const
static boost::atomic< unsigned int > n_obj
Definition: clb_datagram.hh:35
bool is_optical(unsigned int dt)
Definition: datatypespec.hh:12
char * raw()
Definition: clb_datagram.hh:65
bool validTimeStamp(CLBCommonHeader const &header)
char m_block[DGRAM_CAPACITY]
Definition: clb_datagram.hh:27
uint32_t udpSequenceNumber() const
void clear()
Definition: clb_datagram.hh:60
bool isOptical() const