DABC (Data Acquisition Backbone Core)  2.9.9
HierarchyStore.h
Go to the documentation of this file.
1 // $Id$
2 
3 /************************************************************
4  * The Data Acquisition Backbone Core (DABC) *
5  ************************************************************
6  * Copyright (C) 2009 - *
7  * GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
8  * Planckstr. 1, 64291 Darmstadt, Germany *
9  * Contact: http://dabc.gsi.de *
10  ************************************************************
11  * This software can be used under the GPL license *
12  * agreements as stated in LICENSE.txt file *
13  * which is part of the distribution. *
14  ************************************************************/
15 
16 #ifndef DABC_HierarchyStore
17 #define DABC_HierarchyStore
18 
19 #ifndef DABC_Hierarchy
20 #include "dabc/Hierarchy.h"
21 #endif
22 
23 #ifndef DABC_BinaryFile
24 #include "dabc/BinaryFile.h"
25 #endif
26 
27 #ifndef DABC_timing
28 #include "dabc/timing.h"
29 #endif
30 
31 namespace dabc {
32 
34  protected:
35  std::string fBasePath;
36 
41 
42  bool fDoStore;
43  bool fDoFlush;
44  uint64_t fLastVersion;
47 
48  public:
50  virtual ~HierarchyStore();
51 
53  bool SetBasePath(const std::string &path);
54 
55 
56  bool StartFile(dabc::Buffer buf);
57 
58  bool WriteDiff(dabc::Buffer buf);
59 
60  bool CloseFile();
61 
63  bool CheckForNextStore(DateTime& now, double store_period, double flush_period);
64 
67 
69  bool WriteExtractedData();
70  };
71 
72 
73  // =====================================================================
74 
75 
77  protected:
78  std::string fBasePath;
79 
81 
83 
84  bool ScanTreeDir(dabc::Hierarchy& h, const std::string &dirname);
85 
86  bool ScanFiles(const std::string &dirname, const DateTime& onlydate, std::vector<uint64_t>& vect);
87 
88  std::string MakeFileName(const std::string &fpath, const DateTime& dt);
89 
90  bool ProduceStructure(Hierarchy& tree, const DateTime& from, const DateTime& till, const std::string &entry, Hierarchy& tgt);
91 
93 
94  public:
95 
97  virtual ~HierarchyReading();
98 
100  void SetBasePath(const std::string &path);
101 
103  bool ScanTree();
104 
106  bool GetStrucutre(Hierarchy& h, const DateTime& dt = 0);
107 
109  Hierarchy GetSerie(const std::string &entry, const DateTime& from, const DateTime& till);
110 
111  };
112 
113 }
114 
115 #endif
Generic file storage for DABC buffers.
Definition: BinaryFile.h:181
Reference on memory from memory pool.
Definition: Buffer.h:135
Class for holding GMT time with precision of nanoseconds.
Definition: timing.h:190
Defines and implements basic POSIX file interface.
Definition: BinaryFile.h:33
std::string MakeFileName(const std::string &fpath, const DateTime &dt)
FileInterface * fIO
! base directory
bool ScanTreeDir(dabc::Hierarchy &h, const std::string &dirname)
! scanned files tree
void SetBasePath(const std::string &path)
Set top directory for all recorded data.
dabc::Hierarchy fTree
! file interface
Hierarchy GetSerie(const std::string &entry, const DateTime &from, const DateTime &till)
Get entry with history for specified time interval.
bool ScanFiles(const std::string &dirname, const DateTime &onlydate, std::vector< uint64_t > &vect)
bool GetStrucutre(Hierarchy &h, const DateTime &dt=0)
Get full structure at given point of time.
bool ProduceStructure(Hierarchy &tree, const DateTime &from, const DateTime &till, const std::string &entry, Hierarchy &tgt)
bool ScanTree()
Scan only directories, do not open any files.
dabc::Buffer ReadBuffer(dabc::BinaryFile &f)
bool fDoStore
! time when last store flush was done
uint64_t fLastVersion
! indicate if store flush should be done
FileInterface * fIO
! base directory for data store
bool WriteDiff(dabc::Buffer buf)
bool fDoFlush
! indicate if store diff should be done
bool CheckForNextStore(DateTime &now, double store_period, double flush_period)
Returns true if any new store action should be performed.
bool WriteExtractedData()
Write extracted data to files, performed outside hierarchy mutex.
dabc::DateTime fLastFlushTm
! time when last store was done
bool SetBasePath(const std::string &path)
Set base path for data storage, can only be changed when all files are closed.
bool StartFile(dabc::Buffer buf)
dabc::BinaryFile fFile
! file interface
bool ExtractData(dabc::Hierarchy &h)
Extract data which is can be stored, must be called under hierarchy mutex.
dabc::DateTime fLastStoreTm
! file used to write data
Buffer fStoreBuf
! last stored version
Represents objects hierarchy of remote (or local) DABC process.
Definition: Hierarchy.h:285
Event manipulation API.
Definition: api.h:23