otsdaq  3.04.02
Database_configInterface.h
1 #ifndef _ots_DatabaseConfigurationInterface_h_
2 #define _ots_DatabaseConfigurationInterface_h_
3 
4 #include "otsdaq/ConfigurationInterface/ConfigurationInterface.h"
5 
6 // #include "ConfigurationInterface.h"
7 
8 #include <list>
9 #include <map>
10 #include <set>
11 #include <stdexcept>
12 
13 // clang-format off
14 namespace ots
15 {
16 class TableBase;
17 
19 {
20  public:
21  using table_version_map_t = std::map<std::string /*name*/, TableVersion /*version*/>;
22 
25 
26  bool IS_FILESYSTEM_DB = true;
27 
29  void fill (TableBase* table, TableVersion version) const override;
30 
32  void saveActiveVersion (const TableBase* table, bool overwrite = false) const override;
33 
35  TableVersion findLatestVersion (const TableBase* table) const noexcept override;
36 
38  std::set<std::string /*name*/> getAllTableNames (void) const override;
40  std::set<TableVersion> getVersions (const TableBase* table) const noexcept override;
41 
43  std::set<std::string /*name+version*/> getAllTableGroupNames (std::string const& filterString = "") const override;
44  std::set<TableGroupKey> getKeys (const std::string& groupName) const override;
45  std::set<std::string /*group*/> findGroupsWithTable (std::string const& tableName, TableVersion version) const override;
46 
47  TableGroupKey findLatestGroupKey (const std::string& groupName) const noexcept override;
48 
50  table_version_map_t getTableGroupMembers (std::string const& tableGroup, bool includeMetaDataTable = false) const override;
51 
53  void saveTableGroup (table_version_map_t const& memberMap, std::string const& tableGroup) const override;
54 
55  std::pair<std::string, TableVersion> saveCustomJSON (const std::string& JSON, const std::string& documentNameToSave) const override;
56  std::string loadCustomJSON (const std::string& documentNameToLoad, TableVersion documentVersionToLoad) const override;
57 
58  private:
59  table_version_map_t getCachedTableGroupMembers(std::string const& tableGroup) const;
60  void saveTableGroupMemberCache(table_version_map_t const& memberMap, std::string const& tableGroup) const;
61 };
62 } // namespace ots
63 
64 // clang-format on
65 #endif
void saveTableGroup(table_version_map_t const &memberMap, std::string const &tableGroup) const override
create a new table group from the contents map
TableVersion findLatestVersion(const TableBase *table) const noexcept override
find the latest table version by table type
table_version_map_t getTableGroupMembers(std::string const &tableGroup, bool includeMetaDataTable=false) const override
return the contents of a table group
std::set< std::string > getAllTableGroupNames(std::string const &filterString="") const override
find all table groups in database
std::set< TableGroupKey > getKeys(const std::string &groupName) const override
find all configuration groups in database
std::set< std::string > findGroupsWithTable(std::string const &tableName, TableVersion version) const override
std::string loadCustomJSON(const std::string &documentNameToLoad, TableVersion documentVersionToLoad) const override
Load a document in the document database and return content as a json string.
std::pair< std::string, TableVersion > saveCustomJSON(const std::string &JSON, const std::string &documentNameToSave) const override
Save a json string as a document in the document database.
std::set< TableVersion > getVersions(const TableBase *table) const noexcept override
find all table versions by table type
std::set< std::string > getAllTableNames(void) const override
returns a list of all table names
void fill(TableBase *table, TableVersion version) const override
read table from database
TableGroupKey findLatestGroupKey(const std::string &groupName) const noexcept override
void saveActiveVersion(const TableBase *table, bool overwrite=false) const override
write table to database
defines used also by OtsConfigurationWizardSupervisor