| 1 | #ifndef FACT_DataProcessorImp
|
|---|
| 2 | #define FACT_DataProcessorImp
|
|---|
| 3 |
|
|---|
| 4 | #include "MessageImp.h"
|
|---|
| 5 |
|
|---|
| 6 | struct RUN_HEAD;
|
|---|
| 7 | struct _EVENT;
|
|---|
| 8 | struct _RUN_TAIL;
|
|---|
| 9 |
|
|---|
| 10 | namespace FAD
|
|---|
| 11 | {
|
|---|
| 12 | struct RunDescription;
|
|---|
| 13 | };
|
|---|
| 14 |
|
|---|
| 15 | typedef struct _EVENT EVENT;
|
|---|
| 16 | typedef struct _RUN_TAIL RUN_TAIL;
|
|---|
| 17 |
|
|---|
| 18 | class DataProcessorImp : public MessageImp
|
|---|
| 19 | {
|
|---|
| 20 | std::string fPath;
|
|---|
| 21 | uint32_t fNight;
|
|---|
| 22 | uint32_t fRunId;
|
|---|
| 23 |
|
|---|
| 24 | int Write(const Time &time, const std::string &txt, int qos=kMessage)
|
|---|
| 25 | {
|
|---|
| 26 | return fMsg.Write(time, txt, qos);
|
|---|
| 27 | }
|
|---|
| 28 |
|
|---|
| 29 | protected:
|
|---|
| 30 | MessageImp &fMsg;
|
|---|
| 31 | std::string fFileName;
|
|---|
| 32 |
|
|---|
| 33 | public:
|
|---|
| 34 | DataProcessorImp(const std::string &path, uint64_t night, uint32_t id, MessageImp &imp) : fPath(path), fNight(night), fRunId(id), fMsg(imp) { }
|
|---|
| 35 | virtual ~DataProcessorImp() { }
|
|---|
| 36 |
|
|---|
| 37 | virtual bool Open(const RUN_HEAD &h, const FAD::RunDescription &desc) = 0;
|
|---|
| 38 | virtual bool WriteEvt(const EVENT &) = 0;
|
|---|
| 39 | virtual bool Close(const RUN_TAIL * = 0) = 0;
|
|---|
| 40 |
|
|---|
| 41 | const std::string &GetFileName() const { return fFileName; }
|
|---|
| 42 |
|
|---|
| 43 | std::string GetPath() const { return fPath; }
|
|---|
| 44 | uint32_t GetNight() const { return fNight; }
|
|---|
| 45 | uint32_t GetRunId() const { return fRunId; }
|
|---|
| 46 |
|
|---|
| 47 | static std::string FormFileName(const std::string &path, uint64_t night, uint32_t runid, const std::string &extension);
|
|---|
| 48 | std::string FormFileName(const std::string &extension)
|
|---|
| 49 | {
|
|---|
| 50 | return FormFileName(fPath, fNight, fRunId, extension);
|
|---|
| 51 | }
|
|---|
| 52 | };
|
|---|
| 53 |
|
|---|
| 54 | #include "Time.h"
|
|---|
| 55 |
|
|---|
| 56 | class DataDump : public DataProcessorImp
|
|---|
| 57 | {
|
|---|
| 58 | Time fTime;
|
|---|
| 59 |
|
|---|
| 60 | public:
|
|---|
| 61 | DataDump(const std::string &path, uint64_t night, uint32_t id, MessageImp &imp) : DataProcessorImp(path, night, id, imp) { }
|
|---|
| 62 |
|
|---|
| 63 | bool Open(const RUN_HEAD &h, const FAD::RunDescription &d);
|
|---|
| 64 | bool WriteEvt(const EVENT &e);
|
|---|
| 65 | bool Close(const RUN_TAIL * = 0);
|
|---|
| 66 | };
|
|---|
| 67 |
|
|---|
| 68 | class DataDebug : public DataDump
|
|---|
| 69 | {
|
|---|
| 70 | public:
|
|---|
| 71 | DataDebug(const std::string &path, uint64_t night, uint32_t id, MessageImp &imp) : DataDump(path, night, id, imp) { }
|
|---|
| 72 |
|
|---|
| 73 | bool WriteEvt(const EVENT &e);
|
|---|
| 74 | };
|
|---|
| 75 |
|
|---|
| 76 | #endif
|
|---|