00001 #include "EventFilter/Utilities/interface/MsgBuf.h" 00002 #include <iostream> 00003 00004 namespace evf{ 00005 MsgBuf::MsgBuf() : msize_(MAX_MSG_SIZE) 00006 { 00007 00008 buf_ = new unsigned char[msize_+sizeof(long int)]; 00009 ptr_ = (msgbuf*)buf_; 00010 ptr_->mtype = MSQM_MESSAGE_TYPE_NOP; 00011 } 00012 00013 MsgBuf::MsgBuf(unsigned int size, unsigned int type) : msize_(size) 00014 { 00015 buf_ = new unsigned char[msize_+sizeof(long int)]; 00016 ptr_ = (msgbuf*)buf_; 00017 ptr_->mtype = type; 00018 } 00019 00020 MsgBuf::MsgBuf(const MsgBuf &b) : msize_(b.msize_) 00021 { 00022 buf_ = new unsigned char[msize_+sizeof(long int)]; 00023 ptr_ = (msgbuf*)buf_; 00024 memcpy(buf_,b.buf_,msize_); 00025 } 00026 MsgBuf & MsgBuf::operator=(const MsgBuf &b) 00027 { 00028 msize_ = b.msize_; 00029 buf_ = new unsigned char[msize_+sizeof(long int)]; 00030 ptr_ = (msgbuf*)buf_; 00031 memcpy(buf_,b.buf_,msize_+sizeof(long int)); 00032 return *this; 00033 } 00034 size_t MsgBuf::msize(){return msize_;} 00035 MsgBuf::~MsgBuf() 00036 { 00037 delete[] buf_; 00038 } 00039 msgbuf* MsgBuf::operator->(){return ptr_;} 00040 }