tdaq-develop-2025-02-12
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 {
16 {
17  public:
18  DataProducerBase(const std::string& supervisorApplicationUID,
19  const std::string& bufferUID,
20  const std::string& processorUID,
21  unsigned int bufferSize = 100);
22  virtual ~DataProducerBase(void);
23 
24  virtual void registerToBuffer(void);
25  // virtual void unregisterFromBuffer (void);
26 
27  template<class D, class H>
28  int attachToEmptySubBuffer(D*& data, H*& header)
29  {
30  return static_cast<CircularBuffer<D, H>*>(theCircularBuffer_)
31  ->getBuffer(DataProcessor::processorUID_)
32  .attachToEmptySubBuffer(data, header);
33  }
34 
35  template<class D, class H>
36  int setWrittenSubBuffer(void)
37  {
38  // __COUT__ << __E__;
39  return static_cast<CircularBuffer<D, H>*>(theCircularBuffer_)
40  ->getBuffer(DataProcessor::processorUID_)
41  .setWrittenSubBuffer();
42  }
43 
44  template<class D, class H>
45  int write(const D& buffer)
46  {
47  return static_cast<CircularBuffer<D, H>*>(theCircularBuffer_)
48  ->getBuffer(DataProcessor::processorUID_)
49  .write(buffer);
50  }
51 
52  template<class D, class H>
53  int write(const D& buffer, const H& header)
54  {
55  return static_cast<CircularBuffer<D, H>*>(theCircularBuffer_)
56  ->getBuffer(DataProcessor::processorUID_)
57  .write(buffer, header);
58  }
59 
60  unsigned int getBufferSize(void) const { return bufferSize_; }
61 
62  private:
63  const unsigned int bufferSize_;
64 };
65 
66 } // namespace ots
67 
68 #endif
virtual void registerToBuffer(void)
mirror DataConsumer::registerToBuffer