 |
Belle II Software
release-05-02-19
|
1 #include "dqm/analysis/HistMemory.h"
3 #include <daq/slc/base/IOException.h>
4 #include <daq/slc/base/StringUtil.h>
17 int flag = O_RDWR | O_CREAT | O_EXCL;
19 if (mode != NULL && StringUtil::tolower(mode) ==
"recreate") {
20 flag = O_RDWR | O_CREAT;
24 if (errno == EEXIST) {
28 throw (
IOException(
"Failed to open file %s : %s", path, strerror(errno)));
31 m_buf =
new char[size];
32 ::memset(
m_buf, 0, size);
34 int ret = ::write(fd,
m_buf, size);
37 throw (
IOException(
"Failed to clear file %s : %s", path, strerror(errno)));
41 char* buf = (
char*)mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED,
m_fd, 0);
61 for (
size_t i = 0; i <
m_hist.size(); i++) {
65 (msg->
header())->reserved[0] = 0;
67 (msg->
header())->reserved[2] = 0;
78 m_hist = std::vector<TH1*>();
91 for (
size_t i = 0; i <
m_hist.size(); i++) {
96 std::vector<TObject*> objlist;
97 std::vector<std::string> strlist;
99 int nobjs = (msg->
header())->reserved[1];
100 for (
int i = 0; i < nobjs; i++) {
101 add((TH1*)objlist[i]->Clone());
Header * m_header
The header for the message.
Class to manage streamed object.
void init()
Initialize the shared memory.
virtual EvtMessage * encode_msg(ERecordType rectype)
Stream object list into an EvtMessage.
unsigned int m_size
The size of the shared memory.
std::vector< TH1 * > & deserialize(Header *header=NULL)
Deserialize the shared memory.
int size() const
Get size of message including headers.
char * m_buf
The buffer to hold the message.
Abstract base class for different kinds of events.
std::vector< TH1 * > m_hist
The list of the histograms.
std::string m_path
The name of the shared memory.
unsigned int m_updateid
The id of the udpate.
virtual void decode_msg(EvtMessage *msg, std::vector< TObject * > &objlist, std::vector< std::string > &namelist)
Decode an EvtMessage into a vector list of objects with names.
EvtHeader * header()
Get pointer to EvtHeader.
char * m_body
The pointer to the body of the message.
char * buffer()
Get buffer address.
void serialize()
Serialize the shared memory.
void open(const char *path, unsigned int size, const char *mode="")
Open shared memory.
MMutex m_mutex
The mutex lock for the shared memory.
MsgHandler m_handler
The message handler.
TH1 * add(TH1 *h)
Add histogram to the list of histograms.
virtual void add(const TObject *, const std::string &name)
Add an object to be streamed.
int m_fd
The file descriptor.