$treeview $search $mathjax $extrastylesheet
otsdaq
v2_03_00
$projectbrief
|
$projectbrief
|
$searchbox |
00001 #ifndef _ots_DataManager_h_ 00002 #define _ots_DataManager_h_ 00003 00004 #include "otsdaq-core/Configurable/Configurable.h" 00005 #include "otsdaq-core/DataManager/CircularBuffer.h" 00006 #include "otsdaq-core/FiniteStateMachine/VStateMachine.h" 00007 #include "otsdaq-core/Macros/CoutMacros.h" 00008 #include "otsdaq-core/MessageFacility/MessageFacility.h" 00009 00010 #include <map> 00011 #include <memory> 00012 #include <string> 00013 #include <vector> 00014 00015 namespace ots 00016 { 00017 class DataProcessor; 00018 class DataProducerBase; 00019 class DataConsumer; 00020 class CircularBufferBase; 00021 00022 // DataManager 00023 // This class is the base class that handles a collection of Buffers and associated Data 00024 // Processor plugins. 00025 class DataManager : public VStateMachine, public Configurable 00026 { 00027 public: 00028 DataManager(const ConfigurationTree& theXDAQContextConfigTree, 00029 const std::string& supervisorConfigurationPath); 00030 virtual ~DataManager(void); 00031 00032 // State Machine Methods 00033 virtual void configure(void); 00034 virtual void halt(void); 00035 virtual void pause(void); 00036 virtual void resume(void); 00037 virtual void start(std::string runNumber); 00038 virtual void stop(void); 00039 00040 template<class D, class H> 00041 void configureBuffer(const std::string& bufferUID) 00042 { 00043 buffers_[bufferUID].buffer_ = new CircularBuffer<D, H>(bufferUID); 00044 buffers_[bufferUID].status_ = Initialized; 00045 } 00046 00047 void registerProducer(const std::string& bufferUID, 00048 DataProducerBase* producer); // The data manager becomes the 00049 // owner of the producer object! 00050 void registerConsumer(const std::string& bufferUID, 00051 DataConsumer* consumer); // The data manager becomes the owner 00052 // of the consumer object! 00053 00054 void unregisterFEProducer(const std::string& bufferID, 00055 const std::string& feProducerID); 00056 00057 // void unregisterConsumer (const std::string& bufferID, const std::string& 00058 // consumerID); void unregisterProducer (const std::string& bufferID, const 00059 // std::string& producerID); 00060 00061 void dumpStatus(std::ostream* out = (std::ostream*)&(std::cout)) const; 00062 00063 protected: 00064 void destroyBuffers(void); 00065 00066 // void destroyBuffer (const std::string& bufferUID);//!!!!!Delete all the 00067 // pointers of the producers and consumers 00068 00069 void startAllBuffers(const std::string& runNumber); 00070 void stopAllBuffers(void); 00071 void resumeAllBuffers(void); 00072 void pauseAllBuffers(void); 00073 00074 void startBuffer(const std::string& bufferUID, std::string runNumber); 00075 void stopBuffer(const std::string& bufferUID); 00076 void resumeBuffer(const std::string& bufferUID); 00077 void pauseBuffer(const std::string& bufferUID); 00078 00079 // void startProducer (const std::string& bufferUID, std::string producerID); 00080 // void stopProducer (const std::string& bufferUID, std::string producerID); 00081 // void startConsumer (const std::string& bufferUID, std::string consumerID); 00082 // void stopConsumer (const std::string& bufferUID, std::string consumerID); 00083 00084 //#include "otsdaq-core/DataTypes/DataStructs.h" 00085 // void setConsumerParameters(const std::string& name); 00086 00087 enum BufferStatus 00088 { 00089 Initialized, 00090 Running 00091 }; 00092 00093 struct Buffer 00094 { 00095 CircularBufferBase* buffer_; 00096 std::vector<DataProducerBase*> producers_; 00097 std::vector<DataConsumer*> consumers_; 00098 BufferStatus status_; 00099 }; 00100 std::map<std::string /*dataBufferId*/, 00101 Buffer /*CircularBuffer:=Map of Producer to Buffer Implementations*/> 00102 buffers_; 00103 00104 public: 00105 bool parentSupervisorHasFrontends_; // if parent supervisor has front-ends, then 00106 // allow no producers... that will be checked 00107 // later by parent supervisor 00108 00109 const std::map<std::string /*dataBufferId*/, Buffer>& getBuffers(void) const 00110 { 00111 return buffers_; 00112 } 00113 }; 00114 00115 } // namespace ots 00116 00117 #endif