00001 #include "EventFilter/Utilities/interface/MsgBuf.h" 00002 #include <iostream> 00003 00004 namespace evf { 00005 MsgBuf::MsgBuf() : 00006 msize_(MAX_MSG_SIZE) { 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) : 00014 msize_(size) { 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) : 00021 msize_(b.msize_) { 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 msize_ = b.msize_; 00028 buf_ = new unsigned char[msize_ + sizeof(long int)]; 00029 ptr_ = (msgbuf*) buf_; 00030 memcpy(buf_, b.buf_, msize_ + sizeof(long int)); 00031 return *this; 00032 } 00033 size_t MsgBuf::msize() { 00034 return msize_; 00035 } 00036 MsgBuf::~MsgBuf() { 00037 delete[] buf_; 00038 } 00039 msgbuf* MsgBuf::operator->() { 00040 return ptr_; 00041 } 00042 }