otsdaq  v2_03_00
DataManager.h
1 #ifndef _ots_DataManager_h_
2 #define _ots_DataManager_h_
3 
4 #include "otsdaq-core/Configurable/Configurable.h"
5 #include "otsdaq-core/DataManager/CircularBuffer.h"
6 #include "otsdaq-core/FiniteStateMachine/VStateMachine.h"
7 #include "otsdaq-core/Macros/CoutMacros.h"
8 #include "otsdaq-core/MessageFacility/MessageFacility.h"
9 
10 #include <map>
11 #include <memory>
12 #include <string>
13 #include <vector>
14 
15 namespace ots
16 {
17 class DataProcessor;
18 class DataProducerBase;
19 class DataConsumer;
20 class CircularBufferBase;
21 
22 // DataManager
23 // This class is the base class that handles a collection of Buffers and associated Data
24 // Processor plugins.
25 class DataManager : public VStateMachine, public Configurable
26 {
27  public:
28  DataManager(const ConfigurationTree& theXDAQContextConfigTree,
29  const std::string& supervisorConfigurationPath);
30  virtual ~DataManager(void);
31 
32  // State Machine Methods
33  virtual void configure(void);
34  virtual void halt(void);
35  virtual void pause(void);
36  virtual void resume(void);
37  virtual void start(std::string runNumber);
38  virtual void stop(void);
39 
40  template<class D, class H>
41  void configureBuffer(const std::string& bufferUID)
42  {
43  buffers_[bufferUID].buffer_ = new CircularBuffer<D, H>(bufferUID);
44  buffers_[bufferUID].status_ = Initialized;
45  }
46 
47  void registerProducer(const std::string& bufferUID,
48  DataProducerBase* producer); // The data manager becomes the
49  // owner of the producer object!
50  void registerConsumer(const std::string& bufferUID,
51  DataConsumer* consumer); // The data manager becomes the owner
52  // of the consumer object!
53 
54  void unregisterFEProducer(const std::string& bufferID,
55  const std::string& feProducerID);
56 
57  // void unregisterConsumer (const std::string& bufferID, const std::string&
58  // consumerID); void unregisterProducer (const std::string& bufferID, const
59  // std::string& producerID);
60 
61  void dumpStatus(std::ostream* out = (std::ostream*)&(std::cout)) const;
62 
63  protected:
64  void destroyBuffers(void);
65  // void destroyBuffer (const std::string& bufferUID);//!!!!!Delete all the
67  // pointers of the producers and consumers
68 
69  void startAllBuffers(const std::string& runNumber);
70  void stopAllBuffers(void);
71  void resumeAllBuffers(void);
72  void pauseAllBuffers(void);
73 
74  void startBuffer(const std::string& bufferUID, std::string runNumber);
75  void stopBuffer(const std::string& bufferUID);
76  void resumeBuffer(const std::string& bufferUID);
77  void pauseBuffer(const std::string& bufferUID);
78 
79  // void startProducer (const std::string& bufferUID, std::string producerID);
80  // void stopProducer (const std::string& bufferUID, std::string producerID);
81  // void startConsumer (const std::string& bufferUID, std::string consumerID);
82  // void stopConsumer (const std::string& bufferUID, std::string consumerID);
83 
84  //#include "otsdaq-core/DataTypes/DataStructs.h"
85  // void setConsumerParameters(const std::string& name);
86 
87  enum BufferStatus
88  {
89  Initialized,
90  Running
91  };
92 
93  struct Buffer
94  {
95  CircularBufferBase* buffer_;
96  std::vector<DataProducerBase*> producers_;
97  std::vector<DataConsumer*> consumers_;
98  BufferStatus status_;
99  };
100  std::map<std::string /*dataBufferId*/,
101  Buffer /*CircularBuffer:=Map of Producer to Buffer Implementations*/>
102  buffers_;
103 
104  public:
105  bool parentSupervisorHasFrontends_; // if parent supervisor has front-ends, then
106  // allow no producers... that will be checked
107  // later by parent supervisor
108 
109  const std::map<std::string /*dataBufferId*/, Buffer>& getBuffers(void) const
110  {
111  return buffers_;
112  }
113 };
114 
115 } // namespace ots
116 
117 #endif
void unregisterFEProducer(const std::string &bufferID, const std::string &feProducerID)
Definition: DataManager.cc:632
void startAllBuffers(const std::string &runNumber)
Definition: DataManager.cc:755