1 #ifndef _ots_BufferImplementation_h_
2 #define _ots_BufferImplementation_h_
4 #include "otsdaq-core/MessageFacility/MessageFacility.h"
5 #include "otsdaq-core/Macros/CoutMacros.h"
6 #include "otsdaq-core/DataManager/CircularBufferBase.h"
17 template <
class D,
class H>
22 CircularBufferBase::ConsumerPriority priority_;
24 std::atomic_bool* subBuffersStatus_;
35 void resetConsumerList (
void);
36 void registerConsumer (std::string name, CircularBufferBase::ConsumerPriority priority);
37 void unregisterConsumer (std::string name);
38 int attachToEmptySubBuffer (D*& data,H*& header);
39 int setWrittenSubBuffer (
void);
40 int write (
const D& buffer,
const H& header=H());
41 int read (D& buffer,
const std::string& consumer);
42 int read (D& buffer, H& header,
const std::string& consumer);
43 int read (D*& buffer, H*& header,
const std::string& consumer);
44 int setReadSubBuffer (
const std::string& consumer);
47 unsigned int bufferSize (
void){
return numberOfSubBuffers_;}
48 unsigned int numberOfWrittenBuffers(
void);
54 ErrorBufferLocked = -2,
55 ErrorBufferNotAvailable = -3,
56 ErrorReadBufferOutOfSync = -4
58 std::string producerName_;
59 unsigned int numberOfSubBuffers_;
60 std::map<std::string, ConsumerStruct> consumers_;
62 std::atomic_bool* subBuffersStatus_;
63 std::vector<H> headers_ ;
64 std::vector<D> subBuffers_ ;
65 const bool bufferFree_;
67 unsigned int nextWritePointer (
void);
68 unsigned int nextReadPointer (
const std::string& consumer);
69 int getFreeBufferIndex(
void);
70 unsigned int getReadPointer (
const std::string& consumer);
71 void setWritten (
unsigned int subBuffer);
72 void setFree (
unsigned int subBuffer,
const std::string& consumer);
73 std::atomic_bool& isFree (
unsigned int subBuffer);
74 std::atomic_bool& isFree (
unsigned int subBuffer,
const std::string& consumer);
75 void dumpStatus (
void);
76 H& getHeader (
unsigned int subBuffer);
77 D& getSubBuffer (
unsigned int subBuffer);
78 void writeSubBuffer (
unsigned int subBuffer,
const D& buffer,
const H& header);
81 #include "otsdaq-core/DataManager/BufferImplementation.icc"