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_;
28 latestKeyGroupAuthor_(ConfigurationManager::UNKNOWN_INFO)
29 , latestKeyGroupComment_(ConfigurationManager::UNKNOWN_INFO)
30 , latestKeyGroupCreationTime_(ConfigurationManager::UNKNOWN_TIME)
31 , latestKeyGroupTypeString_(ConfigurationManager::GROUP_TYPE_NAME_UNKNOWN)
35 const std::set<TableGroupKey>& getKeys()
const {
return keys_; }
36 const TableGroupKey& getLatestKey()
const {
return latestKey_; }
37 const std::string& getLatestKeyGroupAuthor()
const {
return latestKeyGroupAuthor_; }
38 const std::string& getLatestKeyGroupComment()
const {
return latestKeyGroupComment_; }
39 const std::string& getLatestKeyGroupCreationTime()
const
41 return latestKeyGroupCreationTime_;
43 const std::string& getLatestKeyGroupTypeString()
const
45 return latestKeyGroupTypeString_;
48 getLatestKeyMemberMap()
const
50 return latestKeyMemberMap_;
55 return *(keys_.rbegin());
61 std::set<TableGroupKey> keys_;
63 std::string latestKeyGroupAuthor_, latestKeyGroupComment_,
64 latestKeyGroupCreationTime_, latestKeyGroupTypeString_;
65 std::map<std::string ,
TableVersion > latestKeyMemberMap_;
68 #define __GET_TABLE_PTR__(X) getTablePtr<X>(QUOTE(X))
84 const std::string&
getUsername (
void)
const {
return username_; }
87 const std::map<std::string, TableInfo>&
getAllTableInfo (
bool refresh =
false,
88 std::string* accumulatedWarnings = 0,
89 const std::string& errorFilterName =
"",
90 bool getGroupKeys =
false,
92 bool initializeActiveGroups =
false);
93 std::map<std::string ,
94 std::map<std::string ,
98 T* getTablePtr (
const std::string& tableName) {
return (T*)getTableByName(tableName); }
99 TableBase*
getVersionedTableByName (
const std::string& tableName, TableVersion version,
bool looseColumnMatching =
false, std::string* accumulatedErrors = 0,
bool getRawData =
false);
100 TableBase* getTableByName (
const std::string& tableName);
101 TableGroupKey
findTableGroup (
const std::string& groupName,
const std::map<std::string, TableVersion>& groupMembers,
102 const std::map<std::string /*name*/, std::string /*alias*/>& groupAliases = std::map<std::string /*name*/, std::string /*alias*/>());
107 const std::string&
setUsername (
const std::string& username) { username_ = username;
return username_; }
113 const std::string& tableName,
118 bool ignoreDuplicates =
false,
119 bool lookForEquivalent =
false,
120 bool* foundEquivalent =
nullptr);
129 void activateTableGroup (
const std::string& tableGroupName,
TableGroupKey tableGroupKey, std::string* accumulatedTreeErrors = 0, std::string* groupTypeString = 0);
137 const std::string& groupComment = TableViewColumnInfo::DATATYPE_COMMENT_DEFAULT,
138 std::map<std::string /*table*/, std::string /*alias*/>* groupAliases = 0);
143 const std::map<std::string, GroupInfo>& getAllGroupInfo (
void) {
return allGroupInfo_; }
145 const std::string& tableGroupName,
146 const TableGroupKey& tableGroupKey,
147 bool doActivate =
false,
148 std::map<std::string, TableVersion>* groupMembers = 0,
149 ProgressBar* progressBar = 0,
150 std::string* accumulateWarnings = 0,
151 std::string* groupComment = 0,
152 std::string* groupAuthor = 0,
153 std::string* groupCreateTime = 0,
154 bool doNotLoadMember =
false,
155 std::string* groupTypeString = 0,
156 std::map<std::string /*name*/, std::string /*alias*/>* groupAliases = 0,
157 ConfigurationManager::LoadGroupType groupTypeToLoad = ConfigurationManager::LoadGroupType::ALL_TYPES,
158 bool ignoreVersionTracking =
false);
164 std::string tableName,
165 TableBase* existingTable,
166 std::shared_ptr<ots::TableInfo> tableInfo,
167 std::shared_ptr<std::atomic<bool>> threadDone);
169 std::string groupName,
171 std::shared_ptr<ots::GroupInfo> theGroupInfo,
172 std::shared_ptr<std::atomic<bool>> theThreadDone);
174 std::string groupName,
176 const std::map<std::string, TableVersion>& groupMemberMap,
177 const std::map<std::string /*name*/, std::string /*alias*/>& memberTableAliases,
178 std::atomic<bool>* theFoundIdentical,
180 std::mutex* theThreadMutex,
181 std::shared_ptr<std::atomic<bool>> theThreadDone);
186 std::map<std::string, TableInfo> allTableInfo_;
187 std::map<std::string, GroupInfo> allGroupInfo_;
189 static std::atomic<bool> firstTimeConstructed_;
203 std::string tableName_;
204 const std::string mfSubject_;
209 __SS__ <<
"impossible!" << std::endl;
215 , mfSubject_(cfgMgr->getUsername())
218 table_ = cfgMgr->getTableByName(tableName_);
222 !(originalVersion_ =
table_->getView().getVersion()).isTemporaryVersion())
233 __COUT__ <<
"Created '" << tableName_ <<
"' temporary version " << temporaryVersion_ << std::endl;
239 tableView_ =
table_->getViewP();
250 std::map<std::string, TableVersion> groupMembers_;
251 std::map<std::string, TableEditStruct> groupTables_;
253 const ConfigurationManager::GroupType groupType_;
254 const std::string originalGroupName_;
258 const std::string mfSubject_;
263 : groupType_(ConfigurationManager::GroupType::CONFIGURATION_TYPE) {__SS__ <<
"impossible!" << __E__; __SS_THROW__;}
268 void dropChanges (
void);
270 const std::string& groupNameToSave,
272 bool* foundEquivalentGroupKey =
nullptr,
273 bool activateNewGroup =
false,
274 bool updateGroupAliases =
false,
275 bool updateTableAliases =
false,
277 bool* foundEquivalentBackboneKey =
nullptr,
278 std::string* accumulatedWarnings =
nullptr);
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())
const std::string & setUsername(const std::string &username)
Setters.
const GroupInfo & getGroupInfo(const std::string &groupName, bool attemptToReloadKeys=false)
public group cache handling
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)
void loadTableGroup(const std::string &tableGroupName, const TableGroupKey &tableGroupKey, bool doActivate=false, std::map< std::string, TableVersion > *groupMembers=0, ProgressBar *progressBar=0, std::string *accumulateWarnings=0, std::string *groupComment=0, std::string *groupAuthor=0, std::string *groupCreateTime=0, bool doNotLoadMember=false, std::string *groupTypeString=0, std::map< std::string, std::string > *groupAliases=0, ConfigurationManager::LoadGroupType groupTypeToLoad=ConfigurationManager::LoadGroupType::ALL_TYPES, bool ignoreVersionTracking=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
TableBase * getMetadataTable(TableVersion fillVersion=TableVersion())
created for use in otsdaq_flatten_system_aliases and otsdaq_export_system_aliases,...
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
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)
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()
friend class ConfigurationManagerRW
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