otsdaq  v2_05_02_indev
CircularBufferBase.h
1 #ifndef _ots_CircularBufferBase_h_
2 #define _ots_CircularBufferBase_h_
3 
4 #include <string>
5 
6 namespace ots
7 {
8 class DataProcessor;
9 
10 // CircularBufferBase
11 // This class is the base class for the otsdaq Buffer
13 {
14  public:
15  enum ConsumerPriority
16  {
17  LowConsumerPriority, // If the buffers are full because a low priority consumer
18  // didn't emptied them then overwrite
19  HighConsumerPriority // Can't overwrite but need to wait for sometime before
20  // writing a buffer
21  };
22 
23  CircularBufferBase(const std::string& bufferID);
24  virtual ~CircularBufferBase(void);
25 
26  virtual void reset(void) = 0;
27  void registerProducer(DataProcessor* producer, unsigned int numberOfSubBuffers = 100);
28  void registerConsumer(DataProcessor* consumer);
29  // void unregisterProducer(DataProcessor* producer);
30  // void unregisterConsumer(DataProcessor* consumer);
31 
32  virtual bool isEmpty(void) const = 0;
33  virtual unsigned int getTotalNumberOfSubBuffers(void) const = 0;
34  virtual unsigned int getProducerBufferSize(const std::string& producerID) const = 0;
35 
36  protected:
37  virtual void registerProducer(const std::string& producerID, unsigned int numberOfSubBuffers = 100) = 0;
38  virtual void registerConsumer(const std::string& consumerID, ConsumerPriority priority) = 0;
39  // virtual void unregisterProducer (const std::string& producerID) = 0;
40  // virtual void unregisterConsume r(const std::string& consumerID) = 0;
41 
42  std::string dataBufferId_;
43  std::string mfSubject_;
44 };
45 } // namespace ots
46 #endif