EPICS ARCHIVER V4
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups
CircularBuffer.h
1 // -*- c++ -*-
2 #ifndef __CIRCULARBUFFER_H__
3 #define __CIRCULARBUFFER_H__
4 
5 // storage
6 #include "storage/RawValue.h"
7 
15 {
16 public:
17 
19 
21  void allocate(DbrType type, DbrCount count, size_t num);
22 
25  { return type; }
26 
29  { return count; }
30 
35  size_t getCapacity() const
36  { return max_index-1; }
37 
39  size_t getCount() const;
40 
42  void reset();
43 
45  size_t getOverwrites() const
46  { return overwrites; }
47 
54 
56  void addRawValue(const RawValue::Data *raw_value);
57 
62  const RawValue::Data *getRawValue(size_t i) const;
63 
69 
71  void dump() const;
72 
73 private:
74 
75  CircularBuffer(const CircularBuffer &); // not impl.
76  CircularBuffer & operator = (const CircularBuffer &); // not impl.
77 
78  RawValue::Data *getElement(size_t i) const;
79 
80  DbrType type; // dbr_time_xx
81  DbrCount count; // array size of type
82  MemoryBuffer<char> buffer; // the buffer
83  size_t element_size;// == RawValue::getSize (_type, _count)
84  size_t max_index; // max. number of elements in buffer
85  size_t head; // index of current element
86  size_t tail; // before(!) last element, _tail==_head: empty
87  size_t overwrites; // # of elements we had to drop
88 };
89 
90 #endif //__CIRCULARBUFFER_H__
91 
void reset()
Keep memory as is, but reset to have 0 entries.
unsigned short DbrType
DbrType is used to hold dbr_time_xxx types.
Definition: RawValue.h:24
void allocate(DbrType type, DbrCount count, size_t num)
Allocate buffer for num*(type,count) values.
RawValue::Data * getNextElement()
Advance pointer to the next element and return it.
DbrCount getDbrCount() const
Definition: CircularBuffer.h:28
void dump() const
dump
unsigned short DbrCount
DbrCount is used to hold the array size of CA channels.
Definition: RawValue.h:27
In-Memory buffer for values.
Definition: CircularBuffer.h:14
DbrType getDbrType() const
Definition: CircularBuffer.h:24
size_t getOverwrites() const
Number of samples that had to be dropped.
Definition: CircularBuffer.h:45
size_t getCapacity() const
Definition: CircularBuffer.h:35
const RawValue::Data * removeRawValue()
Return pointer to the oldest value in the buffer and remove it.
size_t getCount() const
Number of values in the buffer, 0...(capacity-1)
void addRawValue(const RawValue::Data *raw_value)
Copy a raw value into the buffer.
dbr_time_double Data
Type for accessing the raw data and its common fields.
Definition: RawValue.h:55
const RawValue::Data * getRawValue(size_t i) const
Get a pointer to value number i without removing it.