otsdaq  v2_05_02_indev
RawDataSaverConsumerBase.h
1 #ifndef _ots_RawDataSaverConsumerBase_h_
2 #define _ots_RawDataSaverConsumerBase_h_
3 
4 #include "otsdaq/Configurable/Configurable.h"
5 #include "otsdaq/DataManager/DataConsumer.h"
6 
7 #include <fstream>
8 #include <string>
9 
10 namespace ots
11 {
13  {
14  public:
15  RawDataSaverConsumerBase(std::string supervisorApplicationUID,
16  std::string bufferUID,
17  std::string processorUID,
18  const ConfigurationTree& theXDAQContextConfigTree,
19  const std::string& configurationPath);
20  virtual ~RawDataSaverConsumerBase(void);
21 
22  protected:
23  virtual void openFile(std::string runNumber);
24  virtual void closeFile(void);
25  virtual void save(const std::string& data);
26  virtual void writeHeader(void) { ; }
27  virtual void writeFooter(void) { ; }
28  virtual void writePacketHeader(const std::string& /*data*/)
29  {// unsigned char quadWordsCount = (data.length()-2)/8; outFile_.write(
30  // (char*)&quadWordsCount, 1);
31  ;
32  }
33  virtual void writePacketFooter(const std::string& /*data*/) { ; }
34  virtual void startProcessingData(std::string runNumber) override;
35  virtual void stopProcessingData(void) override;
36  virtual bool workLoopThread(toolbox::task::WorkLoop* workLoop) override;
37  virtual void fastRead(void);
38  virtual void slowRead(void);
39 
40  std::ofstream outFile_;
41  // For fast read
42  std::string* dataP_;
43  std::map<std::string, std::string>* headerP_;
44  // For slow read
45  std::string data_;
46  std::map<std::string, std::string> header_;
47 
48  std::string filePath_;
49  std::string fileRadix_;
50  long maxFileSize_;
51  std::string currentRunNumber_;
52  unsigned int currentSubRunNumber_;
53  };
54 
55 } // namespace ots
56 
57 #endif