otsdaq  v2_05_02_indev
DataManager.h
1 #ifndef _ots_DataManager_h_
2 #define _ots_DataManager_h_
3 
4 #include "otsdaq/Configurable/Configurable.h"
5 #include "otsdaq/DataManager/CircularBuffer.h"
6 #include "otsdaq/FiniteStateMachine/VStateMachine.h"
7 #include "otsdaq/Macros/CoutMacros.h"
8 #include "otsdaq/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 Configurable, public VStateMachine
26 {
27  public:
28  DataManager(const ConfigurationTree& theXDAQContextConfigTree, const std::string& supervisorConfigurationPath);
29  virtual ~DataManager(void);
30 
31  // State Machine Methods
32  virtual void configure(void);
33  virtual void halt(void);
34  virtual void pause(void);
35  virtual void resume(void);
36  virtual void start(std::string runNumber);
37  virtual void stop(void);
38 
39  template<class D, class H>
40  void configureBuffer(const std::string& bufferUID)
41  {
42  buffers_[bufferUID].buffer_ = new CircularBuffer<D, H>(bufferUID);
43  buffers_[bufferUID].status_ = Initialized;
44  }
45 
46  void registerProducer(const std::string& bufferUID,
47  DataProducerBase* producer); // The data manager becomes the
48  // owner of the producer object!
49  void registerConsumer(const std::string& bufferUID,
50  DataConsumer* consumer); // The data manager becomes the owner
51  // of the consumer object!
52 
53  void unregisterFEProducer(const std::string& bufferID, const std::string& feProducerID);
54 
55  // void unregisterConsumer (const std::string& bufferID, const std::string&
56  // consumerID); void unregisterProducer (const std::string& bufferID, const
57  // std::string& producerID);
58 
59  void dumpStatus(std::ostream* out = (std::ostream*)&(std::cout)) const;
60 
61  protected:
62  void destroyBuffers(void);
63  // void destroyBuffer (const std::string& bufferUID);//!!!!!Delete all the
65  // pointers of the producers and consumers
66 
67  void startAllBuffers(const std::string& runNumber);
68  void stopAllBuffers(void);
69  void resumeAllBuffers(void);
70  void pauseAllBuffers(void);
71 
72  void startBuffer(const std::string& bufferUID, std::string runNumber);
73  void stopBuffer(const std::string& bufferUID);
74  void resumeBuffer(const std::string& bufferUID);
75  void pauseBuffer(const std::string& bufferUID);
76 
77  enum BufferStatus
78  {
79  Initialized,
80  Running
81  };
82 
83  struct Buffer
84  {
85  CircularBufferBase* buffer_;
86  std::vector<DataProducerBase*> producers_;
87  std::vector<DataConsumer*> consumers_;
88  BufferStatus status_;
89  };
90  std::map<std::string /*dataBufferId*/, Buffer /*CircularBuffer:=Map of Producer to Buffer Implementations*/> buffers_;
91 
92  public:
93  bool parentSupervisorHasFrontends_; // if parent supervisor has front-ends, then
94  // allow no producers... that will be checked
95  // later by parent supervisor
96 
97  const std::map<std::string /*dataBufferId*/, Buffer>& getBuffers(void) const { return buffers_; }
98 };
99 
100 } // namespace ots
101 
102 #endif
void unregisterFEProducer(const std::string &bufferID, const std::string &feProducerID)
Definition: DataManager.cc:542
void startAllBuffers(const std::string &runNumber)
Definition: DataManager.cc:654