1 #ifndef _ots_ConfigurationManagerRW_h_
2 #define _ots_ConfigurationManagerRW_h_
4 #include "otsdaq/ConfigurationInterface/ConfigurationManager.h"
18 std::set<TableVersion> versions_;
20 std::string accumulatedWarnings_;
30 latestKeyGroupAuthor_ (ConfigurationManager::UNKNOWN_INFO)
31 , latestKeyGroupComment_ (ConfigurationManager::UNKNOWN_INFO)
32 , latestKeyGroupCreationTime_ (ConfigurationManager::UNKNOWN_TIME)
33 , latestKeyGroupTypeString_ (ConfigurationManager::GROUP_TYPE_NAME_UNKNOWN)
37 const std::set<TableGroupKey>& getKeys()
const {
return keys_; }
38 const TableGroupKey& getLatestKey()
const {
return latestKey_; }
39 const std::string& getLatestKeyGroupAuthor()
const {
return latestKeyGroupAuthor_; }
40 const std::string& getLatestKeyGroupComment()
const {
return latestKeyGroupComment_; }
41 const std::string& getLatestKeyGroupCreationTime()
const {
return latestKeyGroupCreationTime_; }
42 const std::string& getLatestKeyGroupTypeString()
const {
return latestKeyGroupTypeString_; }
43 const std::map<std::string ,
44 TableVersion >& getLatestKeyMemberMap()
const {
return latestKeyMemberMap_; }
48 std::set<TableGroupKey> keys_;
50 std::string latestKeyGroupAuthor_, latestKeyGroupComment_,
51 latestKeyGroupCreationTime_, latestKeyGroupTypeString_;
52 std::map<std::string ,
56 #define __GET_TABLE_PTR__(X) getTablePtr<X>(QUOTE(X))
71 const std::string&
getUsername (
void)
const {
return username_; }
74 const std::map<std::string, TableInfo>&
getAllTableInfo (
bool refresh =
false,
75 std::string* accumulatedWarnings = 0,
76 const std::string& errorFilterName =
"",
77 bool getGroupKeys =
false,
79 bool initializeActiveGroups =
false);
80 std::map<std::string ,
81 std::map<std::string ,
85 T* getTablePtr (
const std::string& tableName) {
return (T*)getTableByName(tableName); }
86 TableBase*
getVersionedTableByName (
const std::string& tableName, TableVersion version,
bool looseColumnMatching =
false, std::string* accumulatedErrors = 0,
bool getRawData =
false);
87 TableBase* getTableByName (
const std::string& tableName);
89 const std::map<std::string, TableVersion>& groupMembers,
90 const std::map<std::string /*name*/, std::string /*alias*/>& groupAliases = std::map<std::string /*name*/, std::string /*alias*/>());
95 const std::string&
setUsername (
const std::string& username) { username_ = username;
return username_; }
101 const std::string& tableName,
106 bool ignoreDuplicates =
false,
107 bool lookForEquivalent =
false,
108 bool* foundEquivalent =
nullptr);
117 void activateTableGroup (
const std::string& tableGroupName,
TableGroupKey tableGroupKey, std::string* accumulatedTreeErrors = 0, std::string* groupTypeString = 0);
125 const std::string& groupComment = TableViewColumnInfo::DATATYPE_COMMENT_DEFAULT,
126 std::map<std::string /*table*/, std::string /*alias*/>* groupAliases = 0);
131 const std::map<std::string, GroupInfo>& getAllGroupInfo (
void) {
return allGroupInfo_; }
133 const std::string& tableGroupName,
134 const TableGroupKey& tableGroupKey,
135 bool doActivate =
false,
136 std::map<std::string, TableVersion>* groupMembers = 0,
137 ProgressBar* progressBar = 0,
138 std::string* accumulateWarnings = 0,
139 std::string* groupComment = 0,
140 std::string* groupAuthor = 0,
141 std::string* groupCreateTime = 0,
142 bool doNotLoadMember =
false,
143 std::string* groupTypeString = 0,
144 std::map<std::string /*name*/, std::string /*alias*/>* groupAliases = 0,
145 ConfigurationManager::LoadGroupType groupTypeToLoad = ConfigurationManager::LoadGroupType::ALL_TYPES,
146 bool ignoreVersionTracking =
false);
152 std::string tableName,
153 TableBase* existingTable,
154 std::shared_ptr<ots::TableInfo> tableInfo,
155 std::shared_ptr<std::atomic<bool>> threadDone);
157 std::string groupName,
159 std::shared_ptr<ots::GroupInfo> theGroupInfo,
160 std::shared_ptr<std::atomic<bool>> theThreadDone);
162 std::string groupName,
164 const std::map<std::string, TableVersion>& groupMemberMap,
165 const std::map<std::string /*name*/, std::string /*alias*/>& memberTableAliases,
166 std::atomic<bool>* theFoundIdentical,
168 std::mutex* theThreadMutex,
169 std::shared_ptr<std::atomic<bool>> theThreadDone);
174 std::map<std::string, TableInfo> allTableInfo_;
175 std::map<std::string, GroupInfo> allGroupInfo_;
177 static std::atomic<bool> firstTimeConstructed_;
191 std::string tableName_;
192 const std::string mfSubject_;
197 __SS__ <<
"impossible!" << std::endl;
203 , mfSubject_(cfgMgr->getUsername())
206 table_ = cfgMgr->getTableByName(tableName_);
210 !(originalVersion_ =
table_->getView().getVersion()).isTemporaryVersion())
221 __COUT__ <<
"Created '" << tableName_ <<
"' temporary version " << temporaryVersion_ << std::endl;
227 tableView_ =
table_->getViewP();
238 std::map<std::string, TableVersion> groupMembers_;
239 std::map<std::string, TableEditStruct> groupTables_;
241 const ConfigurationManager::GroupType groupType_;
242 const std::string originalGroupName_;
246 const std::string mfSubject_;
251 : groupType_(ConfigurationManager::GroupType::CONFIGURATION_TYPE) {__SS__ <<
"impossible!" << __E__; __SS_THROW__;}
256 void dropChanges (
void);
258 const std::string& groupNameToSave,
260 bool* foundEquivalentGroupKey =
nullptr,
261 bool activateNewGroup =
false,
262 bool updateGroupAliases =
false,
263 bool updateTableAliases =
false,
265 bool* foundEquivalentBackboneKey =
nullptr,
266 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
defines used also by OtsConfigurationWizardSupervisor
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