CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/EventFilter/Utilities/interface/MsgBuf.h

Go to the documentation of this file.
00001 #ifndef EVENTFILTER_UTILITIES_MSG_BUF_H
00002 #define EVENTFILTER_UTILITIES_MSG_BUF_H
00003 
00004 #include "EventFilter/Utilities/interface/queue_defs.h"
00005 
00006 //@EM ToDo move implementation to .cc file
00007 
00008 namespace evf{
00009   class MsgBuf{
00010   public:
00011     MsgBuf() : msize_(MAX_MSG_SIZE+sizeof(struct msgbuf)+1)
00012       {
00013         buf = new unsigned char[MAX_MSG_SIZE+sizeof(struct msgbuf)+1];
00014         ptr_ = (msgbuf*)buf;
00015         ptr_->mtype = MSQM_MESSAGE_TYPE_NOP;
00016       }
00017 
00018     MsgBuf(unsigned int size, unsigned int type) : msize_(size)
00019       {
00020         buf = new unsigned char[msize_+sizeof(struct msgbuf)+1];
00021         ptr_ = (msgbuf*)buf;
00022         ptr_->mtype = type;
00023       }
00024     size_t msize(){return msize_;}
00025     virtual ~MsgBuf(){delete[] buf;}
00026     msgbuf* operator->(){return ptr_;}
00027   private:
00028     struct msgbuf *ptr_;
00029     unsigned char *buf;
00030     size_t msize_;
00031     friend class MasterQueue;
00032     friend class SlaveQueue;
00033   };
00034 }
00035 #endif