CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Private Attributes
trklet::CircularBuffer< T > Class Template Reference

#include <CircularBuffer.h>

Public Member Functions

bool almostfull () const
 
 CircularBuffer (unsigned int nbits)
 
bool empty () const
 
bool full () const
 
bool nearfull () const
 
const Tpeek () const
 
const Tread ()
 
void reset ()
 
unsigned int rptr () const
 
void store (T element)
 
unsigned int wptr () const
 
 ~CircularBuffer ()=default
 

Private Attributes

std::vector< Tbuffer_
 
unsigned int rptr_
 
unsigned int size_
 
unsigned int wptr_
 

Detailed Description

template<class T>
class trklet::CircularBuffer< T >

Definition at line 10 of file CircularBuffer.h.

Constructor & Destructor Documentation

template<class T>
trklet::CircularBuffer< T >::CircularBuffer ( unsigned int  nbits)
inline

Definition at line 12 of file CircularBuffer.h.

12  {
13  size_ = 1 << nbits;
14  buffer_.resize(size_);
15  reset();
16  }
std::vector< T > buffer_
template<class T>
trklet::CircularBuffer< T >::~CircularBuffer ( )
default

Member Function Documentation

template<class T>
bool trklet::CircularBuffer< T >::almostfull ( ) const
inline

Definition at line 29 of file CircularBuffer.h.

29 { return (((wptr_ + 1) % size_) == rptr_) || (((wptr_ + 2) % size_) == rptr_); }
template<class T>
bool trklet::CircularBuffer< T >::empty ( void  ) const
inline
template<class T>
bool trklet::CircularBuffer< T >::full ( ) const
inline

Definition at line 26 of file CircularBuffer.h.

Referenced by trklet::CircularBuffer< trklet::ProjectionTemp >::store().

26 { return ((wptr_ + 1) % size_) == rptr_; }
template<class T>
bool trklet::CircularBuffer< T >::nearfull ( ) const
inline

Definition at line 32 of file CircularBuffer.h.

Referenced by trklet::TrackletProcessor::execute().

32  {
33  return (((wptr_ + 1) % size_) == rptr_) || (((wptr_ + 2) % size_) == rptr_) || (((wptr_ + 3) % size_) == rptr_);
34  }
template<class T>
const T& trklet::CircularBuffer< T >::peek ( ) const
inline

Definition at line 46 of file CircularBuffer.h.

46  {
47  assert(!empty());
48  return buffer_[rptr_];
49  }
std::vector< T > buffer_
assert(be >=bs)
template<class T>
const T& trklet::CircularBuffer< T >::read ( )
inline

Definition at line 39 of file CircularBuffer.h.

Referenced by edmIntegrityCheck.PublishToFileSystem::get().

39  {
40  assert(!empty());
41  unsigned int oldrptr = rptr_;
42  rptr_ = (rptr_ + 1) % size_;
43  return buffer_[oldrptr];
44  }
std::vector< T > buffer_
assert(be >=bs)
template<class T>
void trklet::CircularBuffer< T >::reset ( void  )
inline

Definition at line 20 of file CircularBuffer.h.

Referenced by trklet::CircularBuffer< trklet::ProjectionTemp >::CircularBuffer().

20  {
21  rptr_ = 0;
22  wptr_ = 0;
23  }
template<class T>
unsigned int trklet::CircularBuffer< T >::rptr ( ) const
inline

Definition at line 59 of file CircularBuffer.h.

Referenced by trklet::TrackletProcessor::execute().

59 { return rptr_; }
template<class T>
void trklet::CircularBuffer< T >::store ( T  element)
inline

Definition at line 51 of file CircularBuffer.h.

Referenced by trklet::TrackletProcessor::execute().

51  {
52  assert(!full());
53  buffer_[wptr_++] = element;
54  wptr_ = wptr_ % size_;
55  assert(wptr_ != rptr_);
56  }
std::vector< T > buffer_
assert(be >=bs)
template<class T>
unsigned int trklet::CircularBuffer< T >::wptr ( ) const
inline

Definition at line 60 of file CircularBuffer.h.

Referenced by trklet::TrackletProcessor::execute().

60 { return wptr_; }

Member Data Documentation

template<class T>
std::vector<T> trklet::CircularBuffer< T >::buffer_
private
template<class T>
unsigned int trklet::CircularBuffer< T >::rptr_
private
template<class T>
unsigned int trklet::CircularBuffer< T >::size_
private
template<class T>
unsigned int trklet::CircularBuffer< T >::wptr_
private