$treeview $search $mathjax $extrastylesheet
otsdaq
v2_03_00
$projectbrief
|
$projectbrief
|
$searchbox |
00001 #ifndef _ots_DataConsumer_h_ 00002 #define _ots_DataConsumer_h_ 00003 00004 #include <map> 00005 #include <string> 00006 #include "otsdaq-core/DataManager/DataProcessor.h" 00007 00008 namespace ots 00009 { 00010 // DataConsumer 00011 // This class provides base class functionality for Data Consumer plugin classes to 00012 // extracts and process streaming data from a Buffer. 00013 class DataConsumer : public DataProcessor, public virtual WorkLoop 00014 { 00015 public: 00016 enum ConsumerPriority 00017 { 00018 LowConsumerPriority, // If the buffers are full because a low priority consumer 00019 // didn't emptied them then overwrite 00020 HighConsumerPriority // Can't overwrite but need to wait for sometime before 00021 // writing a buffer 00022 }; 00023 DataConsumer(std::string supervisorApplicationUID, 00024 std::string bufferUID, 00025 std::string processorUID, 00026 ConsumerPriority priority); 00027 virtual ~DataConsumer(void); 00028 00029 virtual void registerToBuffer(void); 00030 // virtual void unregisterFromBuffer (void); 00031 00032 virtual void startProcessingData(std::string runNumber); 00033 virtual void stopProcessingData(void); 00034 00035 // Copies the buffer into the passed parameters 00036 template<class D, class H> 00037 int read(D& buffer, H& header) 00038 { 00039 return static_cast<CircularBuffer<D, H>*>(theCircularBuffer_) 00040 ->read(buffer, header, processorUID_); 00041 } 00042 00043 // Fast version where you point to the buffer without copying 00044 template<class D, class H> 00045 int read(D*& buffer, H*& header) 00046 { 00047 return static_cast<CircularBuffer<D, H>*>(theCircularBuffer_) 00048 ->read(buffer, header, processorUID_); 00049 } 00050 00051 template<class D, class H> 00052 int setReadSubBuffer(void) 00053 { 00054 return static_cast<CircularBuffer<D, H>*>(theCircularBuffer_) 00055 ->getLastReadBuffer(DataProcessor::processorUID_) 00056 .setReadSubBuffer(DataProcessor::processorUID_); 00057 } 00058 00059 template<class D, class H> 00060 int read(D& buffer) 00061 { 00062 return static_cast<CircularBuffer<D, H>*>(theCircularBuffer_) 00063 ->read(buffer, processorUID_); 00064 } 00065 00066 ConsumerPriority getPriority(void); 00067 00068 private: 00069 ConsumerPriority priority_; 00070 }; 00071 00072 } // namespace ots 00073 00074 #endif