1 #ifndef _ots_ConfigurationManagerRW_h_
2 #define _ots_ConfigurationManagerRW_h_
4 #include "otsdaq/ConfigurationInterface/ConfigurationManager.h"
16 std::set<TableVersion> versions_;
18 std::string accumulatedWarnings_;
25 latestKeyGroupAuthor_(ConfigurationManager::UNKNOWN_INFO)
26 , latestKeyGroupComment_(ConfigurationManager::UNKNOWN_INFO)
27 , latestKeyGroupCreationTime_(ConfigurationManager::UNKNOWN_TIME)
28 , latestKeyGroupTypeString_(ConfigurationManager::GROUP_TYPE_NAME_UNKNOWN)
32 std::set<TableGroupKey> keys_;
33 std::string latestKeyGroupAuthor_, latestKeyGroupComment_,
34 latestKeyGroupCreationTime_, latestKeyGroupTypeString_;
35 std::map<std::string ,
TableVersion > latestKeyMemberMap_;
40 return *(keys_.rbegin());
46 #define __GETCFG_RW__(X) getConfigurationRW<X>(QUOTE(X))
62 const std::string&
getUsername (
void)
const {
return username_; }
65 const std::map<std::string, TableInfo>&
getAllTableInfo (
bool refresh =
false,
66 std::string* accumulatedWarnings = 0,
67 const std::string& errorFilterName =
"",
68 bool getGroupKeys =
false,
70 bool initializeActiveGroups =
false);
71 std::map<std::string ,
72 std::map<std::string ,
76 T* getConfigurationRW (std::string name) {
return (T*)getTableByName(name); }
77 TableBase*
getVersionedTableByName (
const std::string& tableName, TableVersion version,
bool looseColumnMatching =
false, std::string* accumulatedErrors = 0,
bool getRawData =
false);
78 TableBase* getTableByName (
const std::string& tableName);
79 TableGroupKey
findTableGroup (
const std::string& groupName,
const std::map<std::string, TableVersion>& groupMembers,
80 const std::map<std::string /*name*/, std::string /*alias*/>& groupAliases = std::map<std::string /*name*/, std::string /*alias*/>());
81 TableBase* getMetadataTable (
void) {
return &groupMetadataTable_; }
85 TableVersion
saveNewTable (
const std::string& tableName, TableVersion temporaryVersion = TableVersion(),
bool makeTemporary =
false);
87 const std::string& tableName,
88 TableVersion originalVersion,
91 TableVersion temporaryModifiedVersion,
92 bool ignoreDuplicates =
false,
93 bool lookForEquivalent =
false,
94 bool* foundEquivalent =
nullptr);
97 void eraseTemporaryVersion (
const std::string& tableName, TableVersion targetVersion = TableVersion());
103 void activateTableGroup (
const std::string& tableGroupName, TableGroupKey tableGroupKey, std::string* accumulatedTreeErrors = 0, std::string* groupTypeString = 0);
106 TableVersion
saveNewBackbone (TableVersion temporaryVersion = TableVersion());
110 TableGroupKey
saveNewTableGroup (
const std::string& groupName, std::map<std::string, TableVersion>& groupMembers,
111 const std::string& groupComment = TableViewColumnInfo::DATATYPE_COMMENT_DEFAULT,
112 std::map<std::string /*table*/, std::string /*alias*/>* groupAliases = 0);
116 const GroupInfo&
getGroupInfo (
const std::string& groupName);
117 const std::map<std::string, GroupInfo>& getAllGroupInfo (
void) {
return allGroupInfo_; }
123 std::string tableName,
124 TableBase* existingTable,
125 std::shared_ptr<ots::TableInfo> tableInfo,
126 std::shared_ptr<std::atomic<bool>> threadDone);
128 std::string groupName,
130 std::shared_ptr<ots::GroupInfo> theGroupInfo,
131 std::shared_ptr<std::atomic<bool>> theThreadDone);
133 std::string groupName,
135 const std::map<std::string, TableVersion>& groupMemberMap,
136 const std::map<std::string /*name*/, std::string /*alias*/>& memberTableAliases,
137 std::atomic<bool>* theFoundIdentical,
139 std::mutex* theThreadMutex,
140 std::shared_ptr<std::atomic<bool>> theThreadDone);
145 void cacheGroupKey (
const std::string& groupName, TableGroupKey key);
149 std::map<std::string, TableInfo> allTableInfo_;
150 std::map<std::string, GroupInfo> allGroupInfo_;
152 static std::atomic<bool> firstTimeConstructed_;
166 std::string tableName_;
167 const std::string mfSubject_;
172 __SS__ <<
"impossible!" << std::endl;
178 , mfSubject_(cfgMgr->getUsername())
181 table_ = cfgMgr->getTableByName(tableName_);
185 !(originalVersion_ =
table_->getView().getVersion()).isTemporaryVersion())
196 __COUT__ <<
"Created '" << tableName_ <<
"' temporary version " << temporaryVersion_ << std::endl;
202 tableView_ =
table_->getViewP();
214 std::map<std::string, TableVersion> groupMembers_;
215 std::map<std::string, TableEditStruct> groupTables_;
217 const ConfigurationManager::GroupType groupType_;
218 const std::string originalGroupName_;
222 const std::string mfSubject_;
227 : groupType_(ConfigurationManager::GroupType::CONFIGURATION_TYPE) {__SS__ <<
"impossible!" << __E__; __SS_THROW__;}
232 void dropChanges (
void);
234 const std::string& groupNameToSave,
236 bool* foundEquivalentGroupKey =
nullptr,
237 bool activateNewGroup =
false,
238 bool updateGroupAliases =
false,
239 bool updateTableAliases =
false,
241 bool* foundEquivalentBackboneKey =
nullptr,
242 std::string* accumulatedWarnings =
nullptr);
friend class ConfigurationManagerRW
TableVersion saveNewTable(const std::string &tableName, TableVersion temporaryVersion=TableVersion(), bool makeTemporary=false)
modifiers of generic TableBase
TableGroupKey findTableGroup(const std::string &groupName, const std::map< std::string, TableVersion > &groupMembers, const std::map< std::string, std::string > &groupAliases=std::map< std::string, std::string >())
void testXDAQContext(void)
for debugging
TableVersion saveNewBackbone(TableVersion temporaryVersion=TableVersion())
void clearAllCachedVersions(void)
const std::map< std::string, TableInfo > & getAllTableInfo(bool refresh=false, std::string *accumulatedWarnings=0, const std::string &errorFilterName="", bool getGroupKeys=false, bool getGroupInfo=false, bool initializeActiveGroups=false)
TableVersion copyViewToCurrentColumns(const std::string &tableName, TableVersion sourceVersion)
copyViewToCurrentColumns
TableGroupKey saveNewTableGroup(const std::string &groupName, std::map< std::string, TableVersion > &groupMembers, const std::string &groupComment=TableViewColumnInfo::DATATYPE_COMMENT_DEFAULT, std::map< std::string, std::string > *groupAliases=0)
modifiers of a table group based on alias, e.g. "Physics"
void activateTableGroup(const std::string &tableGroupName, TableGroupKey tableGroupKey, std::string *accumulatedTreeErrors=0, std::string *groupTypeString=0)
modifiers of table groups
TableVersion saveModifiedVersion(const std::string &tableName, TableVersion originalVersion, bool makeTemporary, TableBase *config, TableVersion temporaryModifiedVersion, bool ignoreDuplicates=false, bool lookForEquivalent=false, bool *foundEquivalent=nullptr)
TableVersion createTemporaryBackboneView(TableVersion sourceViewVersion=TableVersion())
-1, from MockUp, else from valid backbone view version
const GroupInfo & getGroupInfo(const std::string &groupName)
public group cache handling
void clearCachedVersions(const std::string &tableName)
const std::string & getUsername(void) const
Getters.
std::map< std::string, std::map< std::string, TableVersion > > getVersionAliases(void) const
void eraseTemporaryVersion(const std::string &tableName, TableVersion targetVersion=TableVersion())
TableBase * getVersionedTableByName(const std::string &tableName, TableVersion version, bool looseColumnMatching=false, std::string *accumulatedErrors=0, bool getRawData=false)
static void compareTableGroupThread(ConfigurationManagerRW *cfgMgr, std::string groupName, ots::TableGroupKey groupKeyToCompare, const std::map< std::string, TableVersion > &groupMemberMap, const std::map< std::string, std::string > &memberTableAliases, std::atomic< bool > *theFoundIdentical, ots::TableGroupKey *theIdenticalKey, std::mutex *theThreadMutex, std::shared_ptr< std::atomic< bool >> theThreadDone)
compareTableGroupThread()
static void loadTableGroupThread(ConfigurationManagerRW *cfgMgr, std::string groupName, ots::TableGroupKey groupKey, std::shared_ptr< ots::GroupInfo > theGroupInfo, std::shared_ptr< std::atomic< bool >> theThreadDone)
loadTableGroupThread()
static void loadTableInfoThread(ConfigurationManagerRW *cfgMgr, std::string tableName, TableBase *existingTable, std::shared_ptr< ots::TableInfo > tableInfo, std::shared_ptr< std::atomic< bool >> threadDone)
loadTableInfoThread()
TableVersion createTemporaryView(TableVersion sourceViewVersion=TableVersion(), TableVersion destTemporaryViewVersion=TableVersion::getNextTemporaryVersion())
source of -1, from MockUp, else from valid view version
bool isActive(void)
isActive
TableEditStruct & getTableEditStruct(const std::string &tableName, bool markModified=false)
Note: if markModified, and table not found in group, this function will try to add it to group.
static std::string stackTrace(void)
TableEditStruct(const std::string &tableName, ConfigurationManagerRW *cfgMgr, bool markModified=false)
TableBase * table_
everything needed for editing a table
bool createdTemporaryVersion_
indicates if temp version was created here
bool modified_
indicates if temp version was modified