LSSTApplications  1.1.2+25,10.0+13,10.0+132,10.0+133,10.0+224,10.0+41,10.0+8,10.0-1-g0f53050+14,10.0-1-g4b7b172+19,10.0-1-g61a5bae+98,10.0-1-g7408a83+3,10.0-1-gc1e0f5a+19,10.0-1-gdb4482e+14,10.0-11-g3947115+2,10.0-12-g8719d8b+2,10.0-15-ga3f480f+1,10.0-2-g4f67435,10.0-2-gcb4bc6c+26,10.0-28-gf7f57a9+1,10.0-3-g1bbe32c+14,10.0-3-g5b46d21,10.0-4-g027f45f+5,10.0-4-g86f66b5+2,10.0-4-gc4fccf3+24,10.0-40-g4349866+2,10.0-5-g766159b,10.0-5-gca2295e+25,10.0-6-g462a451+1
LSSTDataManagementBasePackage
Public Member Functions | Private Member Functions | Private Attributes | List of all members
lsst::ap::Fifo< NumEntries > Class Template Reference

A First In, First Out (FIFO) queue of fixed capacity. More...

#include <Fifo.h>

Inheritance diagram for lsst::ap::Fifo< NumEntries >:

Public Member Functions

 Fifo ()
 Creates an empty Fifo. More...
 
void clear ()
 Empties the Fifo. More...
 
bool empty () const
 Returns true if the Fifo is empty. More...
 
bool full () const
 Returns true if the Fifo is full. More...
 
void enqueue (boost::int64_t const elt)
 
boost::int64_t dequeue ()
 

Private Member Functions

 BOOST_STATIC_ASSERT (NumEntries > 0 &&(NumEntries &(NumEntries-1))==0)
 

Private Attributes

boost::int64_t _buffer [NumEntries]
 
int _size
 
int _back
 
int _front
 

Detailed Description

template<int NumEntries>
class lsst::ap::Fifo< NumEntries >

A First In, First Out (FIFO) queue of fixed capacity.

Definition at line 48 of file Fifo.h.

Constructor & Destructor Documentation

template<int NumEntries>
lsst::ap::Fifo< NumEntries >::Fifo ( )
inline

Creates an empty Fifo.

Definition at line 56 of file Fifo.h.

56 { clear(); }
void clear()
Empties the Fifo.
Definition: Fifo.h:59

Member Function Documentation

template<int NumEntries>
lsst::ap::Fifo< NumEntries >::BOOST_STATIC_ASSERT ( NumEntries  ,
0 &&  NumEntries &(NumEntries-1) = =0 
)
private
template<int NumEntries>
void lsst::ap::Fifo< NumEntries >::clear ( )
inline

Empties the Fifo.

Definition at line 59 of file Fifo.h.

59  {
60  _size = 0;
61  _back = 0;
62  _front = 0;
63  }
int _size
Definition: Fifo.h:113
int _front
Definition: Fifo.h:115
int _back
Definition: Fifo.h:114
template<int NumEntries>
boost::int64_t lsst::ap::Fifo< NumEntries >::dequeue ( )
inline

Removes the least recently inserted integer from the Fifo.

Exceptions
lsst::pex::exceptions::LengthErrorThrown if the Fifo is empty.

Definition at line 97 of file Fifo.h.

97  {
98  int sz = _size;
99  if (sz == 0) {
100  throw LSST_EXCEPT(lsst::pex::exceptions::LengthError,
101  "unable to remove element from empty FIFO");
102  }
103  int i = _front;
104  boost::int64_t elt = _buffer[i];
105  _front = (i + 1) & (NumEntries - 1);
106  _size = sz - 1;
107  return elt;
108  }
int _size
Definition: Fifo.h:113
int _front
Definition: Fifo.h:115
boost::int64_t _buffer[NumEntries]
Definition: Fifo.h:112
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
template<int NumEntries>
bool lsst::ap::Fifo< NumEntries >::empty ( ) const
inline

Returns true if the Fifo is empty.

Definition at line 66 of file Fifo.h.

66  {
67  return _size == 0;
68  }
int _size
Definition: Fifo.h:113
template<int NumEntries>
void lsst::ap::Fifo< NumEntries >::enqueue ( boost::int64_t const  elt)
inline

Inserts the given integer into the Fifo.

Exceptions
lsst::pex::exceptions::LengthErrorThrown if the Fifo is full.

Definition at line 80 of file Fifo.h.

80  {
81  int sz = _size;
82  if (sz == NumEntries) {
83  throw LSST_EXCEPT(lsst::pex::exceptions::LengthError,
84  "unable to insert element into full FIFO");
85  }
86  int i = _back;
87  _buffer[i] = elt;
88  _back = (i + 1) & (NumEntries - 1);
89  _size = sz + 1;
90  }
int _size
Definition: Fifo.h:113
boost::int64_t _buffer[NumEntries]
Definition: Fifo.h:112
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
int _back
Definition: Fifo.h:114
template<int NumEntries>
bool lsst::ap::Fifo< NumEntries >::full ( ) const
inline

Returns true if the Fifo is full.

Definition at line 71 of file Fifo.h.

71  {
72  return _size == NumEntries;
73  }
int _size
Definition: Fifo.h:113

Member Data Documentation

template<int NumEntries>
int lsst::ap::Fifo< NumEntries >::_back
private

Definition at line 114 of file Fifo.h.

template<int NumEntries>
boost::int64_t lsst::ap::Fifo< NumEntries >::_buffer[NumEntries]
private

Definition at line 112 of file Fifo.h.

template<int NumEntries>
int lsst::ap::Fifo< NumEntries >::_front
private

Definition at line 115 of file Fifo.h.

template<int NumEntries>
int lsst::ap::Fifo< NumEntries >::_size
private

Definition at line 113 of file Fifo.h.


The documentation for this class was generated from the following file: