FACT++  1.0
DataProcessorImp.h
Go to the documentation of this file.
1 #ifndef FACT_DataProcessorImp
2 #define FACT_DataProcessorImp
3 
4 #include "MessageImp.h"
5 
6 struct RUN_HEAD;
7 struct EVT_CTRL2;
8 struct RUN_CTRL2;
9 
10 namespace FAD
11 {
12  struct RunDescription;
13 };
14 
16 {
17  std::string fPath;
18  uint32_t fNight;
19  uint32_t fRunId;
20 
21  int Write(const Time &time, const std::string &txt, int qos=kMessage)
22  {
23  return fMsg.Write(time, txt, qos);
24  }
25 
26 protected:
28  std::string fFileName;
29 
30 public:
31  DataProcessorImp(const std::string &path, uint64_t night, uint32_t id, MessageImp &imp) : fPath(path), fNight(night), fRunId(id), fMsg(imp) { }
32  virtual ~DataProcessorImp() { }
33 
34  virtual bool Open(const RUN_HEAD &h, const FAD::RunDescription &desc) = 0;
35  virtual bool WriteEvt(const EVT_CTRL2 &) = 0;
36  virtual bool Close(const EVT_CTRL2 &) = 0;
37 
38  const std::string &GetFileName() const { return fFileName; }
39 
40  std::string GetPath() const { return fPath; }
41  uint32_t GetNight() const { return fNight; }
42  uint32_t GetRunId() const { return fRunId; }
43 
44  static std::string FormFileName(const std::string &path, uint64_t night, uint32_t runid, const std::string &extension);
45  std::string FormFileName(const std::string &extension)
46  {
47  return FormFileName(fPath, fNight, fRunId, extension);
48  }
49 };
50 
51 #include "Time.h"
52 
53 class DataDump : public DataProcessorImp
54 {
56 
57 public:
58  DataDump(const std::string &path, uint64_t night, uint32_t id, MessageImp &imp) : DataProcessorImp(path, night, id, imp) { }
59 
60  bool Open(const RUN_HEAD &h, const FAD::RunDescription &d);
61  bool WriteEvt(const EVT_CTRL2 &);
62  bool Close(const EVT_CTRL2 &);
63 };
64 
65 class DataDebug : public DataDump
66 {
67 public:
68  DataDebug(const std::string &path, uint64_t night, uint32_t id, MessageImp &imp) : DataDump(path, night, id, imp) { }
69 
70  bool WriteEvt(const EVT_CTRL2 &);
71 };
72 
73 #endif
std::string FormFileName(const std::string &extension)
MessageImp & fMsg
The base implementation of a distributed messaging system.
Definition: MessageImp.h:10
Adds some functionality to boost::posix_time::ptime for our needs.
Definition: Time.h:30
uint32_t GetRunId() const
std::string fFileName
std::string GetPath() const
DataDebug(const std::string &path, uint64_t night, uint32_t id, MessageImp &imp)
Definition: FAD.h:92
uint16_t qos
Definition: HeadersGPS.h:29
DataDump(const std::string &path, uint64_t night, uint32_t id, MessageImp &imp)
Warning because the service this data corrsponds to might have been last updated longer ago than Local time
Definition: smartfact.txt:92
uint32_t GetNight() const
virtual ~DataProcessorImp()
DataProcessorImp(const std::string &path, uint64_t night, uint32_t id, MessageImp &imp)
int Write(const Time &time, const std::string &txt, int qos=kMessage)
const std::string & GetFileName() const