8 #include "dqm/analysis/HistMemory.h"
10 #include <daq/slc/base/IOException.h>
11 #include <daq/slc/base/StringUtil.h>
24 int flag = O_RDWR | O_CREAT | O_EXCL;
26 if (mode != NULL && StringUtil::tolower(mode) ==
"recreate") {
27 flag = O_RDWR | O_CREAT;
31 if (errno == EEXIST) {
35 throw (
IOException(
"Failed to open file %s : %s", path, strerror(errno)));
38 m_buf =
new char[size];
39 ::memset(
m_buf, 0, size);
41 int ret = ::write(fd,
m_buf, size);
44 throw (
IOException(
"Failed to clear file %s : %s", path, strerror(errno)));
48 char* buf = (
char*)mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED,
m_fd, 0);
68 for (
size_t i = 0; i <
m_hist.size(); i++) {
72 (msg->
header())->reserved[0] = 0;
74 (msg->
header())->reserved[2] = 0;
85 m_hist = std::vector<TH1*>();
98 for (
size_t i = 0; i <
m_hist.size(); i++) {
103 std::vector<TObject*> objlist;
104 std::vector<std::string> strlist;
106 int nobjs = (msg->
header())->reserved[1];
107 for (
int i = 0; i < nobjs; i++) {
108 add((TH1*)objlist[i]->Clone());
Class to manage streamed object.
EvtHeader * header()
Get pointer to EvtHeader.
char * buffer()
Get buffer address.
int size() const
Get size of message including headers.
void init()
Initialize the shared memory.
TH1 * add(TH1 *h)
Add histogram to the list of histograms.
char * m_body
The pointer to the body of the message.
Header * m_header
The header for the message.
char * m_buf
The buffer to hold the message.
MsgHandler m_handler
The message handler.
std::string m_path
The name of the shared memory.
unsigned int m_updateid
The id of the udpate.
std::vector< TH1 * > m_hist
The list of the histograms.
std::vector< TH1 * > & deserialize(Header *header=NULL)
Deserialize the shared memory.
void open(const char *path, unsigned int size, const char *mode="")
Open shared memory.
int m_fd
The file descriptor.
MMutex m_mutex
The mutex lock for the shared memory.
unsigned int m_size
The size of the shared memory.
void serialize()
Serialize the shared memory.
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.
virtual void add(const TObject *, const std::string &name)
Add an object to be streamed.
virtual EvtMessage * encode_msg(ERecordType rectype)
Stream object list into an EvtMessage.
Abstract base class for different kinds of events.