1 #ifndef _ots_ConfigurationManager_h_
2 #define _ots_ConfigurationManager_h_
8 #include "otsdaq/ConfigurationInterface/ConfigurationInterface.h"
9 #include "otsdaq/ConfigurationInterface/ConfigurationTree.h"
10 #include "otsdaq/TableCore/TableVersion.h"
16 #define __GET_CONFIG__(X) getTable<X>(QUOTE(X))
28 static const std::string READONLY_USER;
29 static const std::string ACTIVE_GROUPS_FILENAME;
30 static const std::string ALIAS_VERSION_PREAMBLE;
31 static const std::string SCRATCH_VERSION_ALIAS;
33 static const std::string XDAQ_CONTEXT_TABLE_NAME;
34 static const std::string XDAQ_APPLICATION_TABLE_NAME;
35 static const std::string XDAQ_APP_PROPERTY_TABLE_NAME;
36 static const std::string GROUP_ALIASES_TABLE_NAME;
37 static const std::string VERSION_ALIASES_TABLE_NAME;
38 static const std::string ARTDAQ_TOP_TABLE_NAME;
39 static const std::string DESKTOP_ICON_TABLE_NAME;
41 static const std::string ACTIVE_GROUP_NAME_CONTEXT;
42 static const std::string ACTIVE_GROUP_NAME_BACKBONE;
43 static const std::string ACTIVE_GROUP_NAME_ITERATE;
44 static const std::string ACTIVE_GROUP_NAME_CONFIGURATION;
45 static const std::string ACTIVE_GROUP_NAME_UNKNOWN;
47 static const std::string LAST_TABLE_GROUP_SAVE_PATH;
48 static const std::string LAST_ACTIVATED_CONFIG_GROUP_FILE;
49 static const std::string LAST_ACTIVATED_CONTEXT_GROUP_FILE;
50 static const std::string LAST_ACTIVATED_BACKBONE_GROUP_FILE;
51 static const std::string LAST_ACTIVATED_ITERATOR_GROUP_FILE;
53 static const uint8_t METADATA_COL_ALIASES;
54 static const uint8_t METADATA_COL_COMMENT;
55 static const uint8_t METADATA_COL_AUTHOR;
56 static const uint8_t METADATA_COL_TIMESTAMP;
58 static const std::set<std::string> contextMemberNames_;
59 static const std::set<std::string> backboneMemberNames_;
60 static const std::set<std::string> iterateMemberNames_;
61 std::set<std::string> configurationMemberNames_;
73 static const std::set<std::string>& getContextMemberNames (
void);
74 static const std::set<std::string>& getBackboneMemberNames (
void);
75 static const std::set<std::string>& getIterateMemberNames (
void);
76 const std::set<std::string>& getConfigurationMemberNames (
void);
78 static const std::string& convertGroupTypeToName (
const ConfigurationManager::GroupType& groupTypeId);
79 static ConfigurationManager::GroupType getTypeOfGroup (
const std::map<std::string /*name*/, TableVersion /*version*/>& memberMap);
80 static const std::string& getTypeNameOfGroup (
const std::map<std::string /*name*/, TableVersion /*version*/>& memberMap);
86 bool initializeFromFhicl =
false);
91 void init (std::string* accumulatedErrors = 0,
bool initForWriteAccess =
false, std::string* accumulatedWarnings = 0);
93 void destroyTableGroup (
const std::string& theGroup =
"",
bool onlyDeactivate =
false);
99 const std::string& configGroupName,
101 bool doActivate =
false,
102 std::map<std::string, TableVersion>* groupMembers = 0,
104 std::string* accumulateWarnings = 0,
105 std::string* groupComment = 0,
106 std::string* groupAuthor = 0,
107 std::string* groupCreateTime = 0,
108 bool doNotLoadMember =
false,
109 std::string* groupTypeString = 0,
110 std::map<std::string /*name*/, std::string /*alias*/>* groupAliases = 0,
111 bool onlyLoadIfBackboneOrContext =
false);
112 void loadMemberMap (
const std::map<std::string /*name*/, TableVersion /*version*/>& memberMap, std::string* accumulateWarnings = 0);
119 const T* getTable (
const std::string& tableName)
const {
const T* retPtr =
dynamic_cast<const T*
>(getTableByName(tableName));
if(retPtr ==
nullptr) { __SS__ <<
"Illegal cast of '" << tableName <<
"' to type " << StringMacros::getTypeName<T>() << __E__; __SS_THROW__ }
return retPtr;}
120 const TableBase* getTableByName (
const std::string& configurationName)
const;
122 void dumpActiveConfiguration (
const std::string& filePath,
const std::string& dumpType);
123 void dumpMacroMakerModeFhicl (
void);
125 std::map<std::string ,
126 std::pair<std::string ,
130 std::map<std::string ,
131 std::map<std::string ,
133 std::pair<std::string ,
135 std::map<std::string ,
136 std::pair<std::string ,
138 const std::map<std::string ,
139 std::pair<std::string ,
140 TableGroupKey>>& getFailedTableGroups (
void)
const {
return lastFailedGroupLoad_;}
141 const std::string& getActiveGroupName (
const ConfigurationManager::GroupType& type = ConfigurationManager::GroupType::CONFIGURATION_TYPE)
const;
142 TableGroupKey getActiveGroupKey (
const ConfigurationManager::GroupType& type = ConfigurationManager::GroupType::CONFIGURATION_TYPE)
const;
144 ConfigurationTree getNode (
const std::string& nodeString,
bool doNotThrowOnBrokenUIDLinks =
false)
const;
145 ConfigurationTree getContextNode (
const std::string& contextUID,
const std::string& applicationUID)
const;
146 ConfigurationTree getSupervisorNode (
const std::string& contextUID,
const std::string& applicationUID)
const;
147 ConfigurationTree getSupervisorTableNode (
const std::string& contextUID,
const std::string& applicationUID)
const;
149 std::vector<std::pair<std::string ,
150 ConfigurationTree>> getChildren (std::map<std::string, TableVersion>* memberMap = 0, std::string* accumulatedTreeErrors = 0)
const;
151 std::string getFirstPathToNode (
const ConfigurationTree& node,
const std::string& startPath =
"/")
const;
153 std::map<std::string, TableVersion> getActiveVersions (
void)
const;
155 const std::string& getOwnerContext (
void) {
return ownerContextUID_; }
156 const std::string& getOwnerApp (
void) {
return ownerAppUID_; }
157 bool isOwnerFirstAppInContext (
void);
161 std::shared_ptr<TableGroupKey> makeTheTableGroupKey (
TableGroupKey key);
162 void restoreActiveTableGroups (
bool throwErrors =
false,
const std::string& pathToActiveGroupsFile =
"",
bool onlyLoadIfBackboneOrContext =
false, std::string* accumulatedWarnings = 0);
164 void setOwnerContext (
const std::string& contextUID) { ownerContextUID_ = contextUID; }
165 void setOwnerApp (
const std::string& appUID) { ownerAppUID_ = appUID; }
166 static void saveGroupNameAndKey (
const std::pair<std::string /*group name*/, TableGroupKey>& theGroup,
const std::string& fileName);
169 TableGroupKey> loadGroupNameAndKey (
const std::string& fileName, std::string& returnedTimeString);
177 void initializeFromFhicl (
const std::string& fhiclPath);
178 void recursiveInitFromFhiclPSet (
const std::string& tableName,
const fhicl::ParameterSet& pset,
const std::string& recordName =
"",
const std::string& groupName =
"",
const std::string& groupLinkIndex =
"");
179 void recursiveTreeToFhicl (
ConfigurationTree node, std::ostream& out, std::string& tabStr, std::string& commentStr,
unsigned int depth = -1);
182 std::string username_;
184 std::shared_ptr<TableGroupKey> theConfigurationTableGroupKey_, theContextTableGroupKey_, theBackboneTableGroupKey_, theIterateTableGroupKey_;
185 std::string theConfigurationTableGroup_, theContextTableGroup_, theBackboneTableGroup_, theIterateTableGroup_;
187 std::map<std::string,
188 std::pair<std::string, TableGroupKey>> lastFailedGroupLoad_;
190 std::map<std::string, TableBase*> nameToTableMap_;
194 std::string ownerContextUID_;
195 std::string ownerAppUID_;