9#include <framework/pcore/EvtMessage.h>
21 int roundToNearestInt(
int bytes)
23 return sizeof(int) * ((bytes +
sizeof(
int) - 1) /
sizeof(int));
40 int bufsize = roundToNearestInt(fullsize);
41 m_data =
new char[bufsize];
43 memset(
m_data + fullsize, 0, bufsize - fullsize);
83 UInt_t
size = *(UInt_t*)bufadr;
84 int bufsize = roundToNearestInt(
size);
85 m_data =
new char[bufsize];
87 for (
int i = bufsize -
size; i > 0; i--)
88 m_data[bufsize - i] =
'\0';
101 const int sizeBytes =
size();
103 return roundToNearestInt(sizeBytes) /
sizeof(int);
149 tv.tv_sec = (
reinterpret_cast<EvtHeader*
>(m_data))->time_sec;
150 tv.tv_usec = (
reinterpret_cast<EvtHeader*
>(m_data))->time_usec;
184 gettimeofday(&tv,
nullptr);
Class to manage streamed object.
int dest() const
Get destination IP of message.
int msg_size() const
Get size of message body.
int paddedSize() const
Same as size(), but as size of an integer array.
EvtMessage(char *buf=nullptr)
build EvtMessage from existing buffer (no copy, but does not take ownership).
ERecordType type() const
Get record type.
int src() const
Get source IP of message.
char * m_data
Pointer to the internal EvtMessage buffer.
EvtHeader * header()
Get pointer to EvtHeader.
char * buffer()
Get buffer address.
void setMsg(const char *msg, int size, ERecordType type)
Copy message into newly allocated buffer.
char * msg()
Get pointer to message body.
bool m_ownsBuffer
Wether to clean up m_data in destructor.
void setTime(const struct timeval &time)
Set time stamp.
const EvtHeader * getHeader() const
Get pointer to EvtHeader.
EvtMessage & operator=(const EvtMessage &obj)
Assignment (m_data is copied).
int size() const
Get size of message including headers.
ERecordType
What type of message is this?
Abstract base class for different kinds of events.