otsdaq  v2_05_02_indev
DataProducerBase.h
1 #ifndef _ots_DataProducerBase_h_
2 #define _ots_DataProducerBase_h_
3 
4 #include "otsdaq/DataManager/CircularBuffer.h"
5 #include "otsdaq/DataManager/DataProcessor.h"
6 #include "otsdaq/Macros/BinaryStringMacros.h"
7 
8 #include <string>
9 
10 namespace ots
11 {
12 // DataProducerBase
13 // This class provides base class functionality for Data Producer plugin classes to
14 // receive incoming streaming data and places it in a Buffer.
16 {
17  public:
18  DataProducerBase(const std::string& supervisorApplicationUID, const std::string& bufferUID, const std::string& processorUID, unsigned int bufferSize = 100);
19  virtual ~DataProducerBase(void);
20 
21  virtual void registerToBuffer(void);
22  // virtual void unregisterFromBuffer (void);
23 
24  template<class D, class H>
25  int attachToEmptySubBuffer(D*& data, H*& header)
26  {
27  return static_cast<CircularBuffer<D, H>*>(theCircularBuffer_)->getBuffer(DataProcessor::processorUID_).attachToEmptySubBuffer(data, header);
28  }
29 
30  template<class D, class H>
31  int setWrittenSubBuffer(void)
32  {
33  // __COUT__ << __E__;
34  return static_cast<CircularBuffer<D, H>*>(theCircularBuffer_)->getBuffer(DataProcessor::processorUID_).setWrittenSubBuffer();
35  }
36 
37  template<class D, class H>
38  int write(const D& buffer)
39  {
40  return static_cast<CircularBuffer<D, H>*>(theCircularBuffer_)->getBuffer(DataProcessor::processorUID_).write(buffer);
41  }
42 
43  template<class D, class H>
44  int write(const D& buffer, const H& header)
45  {
46  return static_cast<CircularBuffer<D, H>*>(theCircularBuffer_)->getBuffer(DataProcessor::processorUID_).write(buffer, header);
47  }
48 
49  unsigned int getBufferSize(void) const { return bufferSize_; }
50 
51  private:
52  const unsigned int bufferSize_;
53 };
54 
55 } // namespace ots
56 
57 #endif