#include <EventFilter/StorageManager/interface/EvtMsgRingBuffer.h>
Public Types | |
typedef std::vector< unsigned char > | Buffer |
Public Member Functions | |
EvtMsgRingBuffer (unsigned int size) | |
bool | isEmpty () |
bool | isFull () |
EventMsgView | pop_front () |
void | push_back (EventMsgView msg) |
virtual | ~EvtMsgRingBuffer () |
Private Attributes | |
int | head_ |
unsigned int | maxsize_ |
int | nextfree_ |
std::vector< Buffer > | ring_buffer_ |
std::vector< int > | ring_totmsgsize_ |
int | tail_ |
Definition at line 26 of file EvtMsgRingBuffer.h.
typedef std::vector<unsigned char> stor::EvtMsgRingBuffer::Buffer |
Definition at line 29 of file EvtMsgRingBuffer.h.
EvtMsgRingBuffer::EvtMsgRingBuffer | ( | unsigned int | size | ) |
Definition at line 22 of file EvtMsgRingBuffer.cc.
References i, int, MAX_EVTBUF_SIZE, maxsize_, and ring_buffer_.
00022 : 00023 maxsize_(size), head_(0), tail_(0), nextfree_(0), 00024 ring_buffer_(maxsize_), ring_totmsgsize_(maxsize_) 00025 { 00026 for (int i=0; i<(int)maxsize_; i++) 00027 ring_buffer_[i].reserve(MAX_EVTBUF_SIZE); 00028 }
virtual stor::EvtMsgRingBuffer::~EvtMsgRingBuffer | ( | ) | [inline, virtual] |
bool EvtMsgRingBuffer::isEmpty | ( | ) |
Definition at line 76 of file EvtMsgRingBuffer.cc.
References head_, nextfree_, and tail_.
Referenced by pop_front().
bool EvtMsgRingBuffer::isFull | ( | ) |
Definition at line 81 of file EvtMsgRingBuffer.cc.
References head_, nextfree_, and tail_.
Referenced by push_back().
EventMsgView EvtMsgRingBuffer::pop_front | ( | ) |
Definition at line 30 of file EvtMsgRingBuffer.cc.
References lat::endl(), EventMsgView::event(), EventMsgView::eventLength(), FDEBUG, head_, isEmpty(), maxsize_, nextfree_, ring_buffer_, and tail_.
00031 { 00032 // check to see if empty - what to return? 00033 // calling code needs to check ifEmpty() and do appropriate thing 00034 // should really return a message an appropriate MsgCode 00035 if(isEmpty()) return EventMsgView(&ring_buffer_[head_][0]); 00036 00037 EventMsgView popthis(&ring_buffer_[head_][0]); 00038 if(head_ == (int)maxsize_-1) head_ = 0; 00039 else head_++; 00040 // see if now empty and need to move the tail 00041 if(head_ == nextfree_) tail_ = head_; 00042 FDEBUG(10) << "after pop_front head = " << head_ << " tail = " << tail_ 00043 << " next free = " << nextfree_ << endl; 00044 FDEBUG(10) << "popping event = " << popthis.event() << endl; 00045 FDEBUG(10) << "pop_front msg event size " << popthis.eventLength() << std::endl; 00046 return popthis; 00047 }
void EvtMsgRingBuffer::push_back | ( | EventMsgView | msg | ) |
Definition at line 49 of file EvtMsgRingBuffer.cc.
References edmNew::copy(), lat::endl(), EventMsgView::eventData(), EventMsgView::eventLength(), FDEBUG, Capri::details::from(), head_, EventMsgView::headerSize(), isFull(), maxsize_, nextfree_, ring_buffer_, ring_totmsgsize_, and tail_.
00050 { 00051 // see if full and need to move the head 00052 if(isFull()) { 00053 if(head_ == (int)maxsize_-1) head_ = 0; 00054 else head_++; 00055 } 00056 00057 // 31-Jul-2006, KAB: I expect that the correct way to copy an 00058 // event message is create an EventMsgBuilder using data fetched from 00059 // the input message. However, there currently doesn't seem to be 00060 // sufficient methods in EventMsgView to support this. So, for now, 00061 // we just copy the data directly (ugly hack). 00062 unsigned char* pos = (unsigned char*) &ring_buffer_[nextfree_][0]; 00063 unsigned char* from = (unsigned char*) 00064 ((unsigned int) inputMsgView.eventData() - inputMsgView.headerSize()); 00065 int dsize = inputMsgView.eventLength() + inputMsgView.headerSize(); 00066 copy(from,from+dsize,pos); 00067 ring_totmsgsize_[nextfree_]=dsize; 00068 00069 tail_ = nextfree_; 00070 if(tail_ == (int)maxsize_-1) nextfree_ = 0; 00071 else nextfree_++; 00072 FDEBUG(10) << "after push_back head = " << head_ << " tail = " << tail_ 00073 << " next free = " << nextfree_ << endl; 00074 }
int stor::EvtMsgRingBuffer::head_ [private] |
Definition at line 41 of file EvtMsgRingBuffer.h.
Referenced by isEmpty(), isFull(), pop_front(), and push_back().
unsigned int stor::EvtMsgRingBuffer::maxsize_ [private] |
Definition at line 40 of file EvtMsgRingBuffer.h.
Referenced by EvtMsgRingBuffer(), pop_front(), and push_back().
int stor::EvtMsgRingBuffer::nextfree_ [private] |
Definition at line 43 of file EvtMsgRingBuffer.h.
Referenced by isEmpty(), isFull(), pop_front(), and push_back().
std::vector<Buffer> stor::EvtMsgRingBuffer::ring_buffer_ [private] |
Definition at line 44 of file EvtMsgRingBuffer.h.
Referenced by EvtMsgRingBuffer(), pop_front(), and push_back().
std::vector<int> stor::EvtMsgRingBuffer::ring_totmsgsize_ [private] |
int stor::EvtMsgRingBuffer::tail_ [private] |
Definition at line 42 of file EvtMsgRingBuffer.h.
Referenced by isEmpty(), isFull(), pop_front(), and push_back().