1 #ifndef _ots_ConfigurationTree_h_
2 #define _ots_ConfigurationTree_h_
4 #include "otsdaq-core/ConfigurationDataFormats/ConfigurationView.h"
15 class ConfigurationManager;
16 class ConfigurationBase;
17 class ConfigurationView;
40 friend class ConfigurationGUISupervisor;
70 __COUT__ <<
"OPERATOR= COPY CONSTRUCTOR ConfigManager: " << configMgr_ <<
" configuration: " << configuration_ << std::endl;
74 __COUT__ <<
"OPERATOR= COPY CONSTRUCTOR CANNOT BE USED - SO YOUR CODE IS WRONG! Crashing now." << std::endl;
75 __COUT__ <<
"OPERATOR= COPY CONSTRUCTOR CANNOT BE USED - SO YOUR CODE IS WRONG! Crashing now." << std::endl;
76 __COUT__ <<
"OPERATOR= COPY CONSTRUCTOR CANNOT BE USED - SO YOUR CODE IS WRONG! Crashing now." << std::endl;
77 __COUT__ <<
"OPERATOR= COPY CONSTRUCTOR CANNOT BE USED - SO YOUR CODE IS WRONG! Crashing now." << std::endl;
78 __COUT__ <<
"OPERATOR= COPY CONSTRUCTOR CANNOT BE USED - SO YOUR CODE IS WRONG! Crashing now." << std::endl;
79 __COUT__ <<
"OPERATOR= COPY CONSTRUCTOR CANNOT BE USED - SO YOUR CODE IS WRONG! Crashing now." << std::endl;
80 __COUT__ <<
"OPERATOR= COPY CONSTRUCTOR CANNOT BE USED - SO YOUR CODE IS WRONG! Crashing now." << std::endl;
85 configMgr_ = a.configMgr_;
86 configuration_ = a.configuration_;
92 configView_ = a.configView_;
93 __COUT__ <<
"OPERATOR COPY CONSTRUCTOR" << std::endl;
98 static const std::string DISCONNECTED_VALUE;
99 static const std::string VALUE_TYPE_DISCONNECTED;
100 static const std::string VALUE_TYPE_NODE;
102 static const std::string NODE_TYPE_GROUP_TABLE;
103 static const std::string NODE_TYPE_TABLE;
104 static const std::string NODE_TYPE_GROUP_LINK;
105 static const std::string NODE_TYPE_UID_LINK;
106 static const std::string NODE_TYPE_VALUE;
107 static const std::string NODE_TYPE_UID;
108 static const std::string NODE_TYPE_ROOT;
118 void getValue(T& value)
const
120 if(row_ != ConfigurationView::INVALID && col_ != ConfigurationView::INVALID)
127 __COUT__ <<
"Success following path to tree node!" << std::endl;
137 value = handleValidateValueForColumn(configView_,
138 valueAsTreeNode.getValueAsString(),col_,
identity<T>());
140 __COUT__ <<
"Successful value!" << std::endl;
149 configView_->getValue(value,row_,col_);
151 else if(row_ == ConfigurationView::INVALID && col_ == ConfigurationView::INVALID)
153 __SS__ <<
"Requesting getValue on config node level. Must be a value node." << std::endl;
154 __COUT_ERR__ << ss.str();
155 throw std::runtime_error(ss.str());
157 else if(row_ == ConfigurationView::INVALID)
159 __SS__ <<
"Malformed ConfigurationTree" << std::endl;
160 __COUT_ERR__ << ss.str();
161 throw std::runtime_error(ss.str());
163 else if(col_ == ConfigurationView::INVALID)
165 __SS__ <<
"Requesting getValue on uid node level. Must be a value node." << std::endl;
166 __COUT_ERR__ << ss.str();
167 throw std::runtime_error(ss.str());
171 __SS__ <<
"Impossible" << std::endl;
172 __COUT_ERR__ << ss.str();
173 throw std::runtime_error(ss.str());
178 void getValue (std::string& value)
const;
185 T getValue(
void)
const
188 ConfigurationTree::getValue<T>(value);
193 std::string getValue (
void)
const;
201 __SS__ <<
"Null configView" << std::endl;
202 __COUT_ERR__ << ss.str();
203 throw std::runtime_error(ss.str());
205 std::cout <<
"210:::::" <<
"handleValidateValueForColumn<T>" << std::endl;
206 return configView->validateValueForColumn<T>(
214 __SS__ <<
"Null configView" << std::endl;
215 __COUT_ERR__ << ss.str();
216 throw std::runtime_error(ss.str());
218 std::cout <<
"210:::::" <<
"handleValidateValueForColumn<string>" << std::endl;
219 return configView->validateValueForColumn(
226 ConfigurationTree getNode (
const std::string& nodeName,
bool doNotThrowOnBrokenUIDLinks=
false)
const;
227 ConfigurationTree getBackNode ( std::string nodeName,
unsigned int backSteps=1)
const;
228 ConfigurationTree getForwardNode ( std::string nodeName,
unsigned int forwardSteps=1)
const;
233 const std::string& getConfigurationName (
void)
const;
234 const std::string& getFieldConfigurationName (
void)
const;
236 const time_t& getConfigurationCreationTime(
void)
const;
237 std::vector<std::string> getChildrenNames (
void)
const;
238 std::vector<std::pair<std::string,ConfigurationTree> > getChildren (std::map<std::string /*relative-path*/, std::string /*value*/> filterMap = std::map<std::string /*relative-path*/, std::string /*value*/>())
const;
239 std::map<std::string,ConfigurationTree> getChildrenMap (
void)
const;
240 std::string getEscapedValue (
void)
const;
241 const std::string& getValueAsString (
bool returnLinkTableValue=
false)
const;
242 const std::string& getUIDAsString (
void)
const;
243 const std::string& getValueDataType (
void)
const;
244 const std::string& getValueType (
void)
const;
245 const std::string& getValueName (
void)
const;
246 std::string getNodeType (
void)
const;
247 const std::string& getDisconnectedTableName (
void)
const;
248 const std::string& getDisconnectedLinkID (
void)
const;
249 const std::string& getChildLinkIndex (
void)
const;
250 std::vector<std::string> getFixedChoices (
void)
const;
256 bool isDefaultValue (
void)
const;
257 bool isRootNode (
void)
const;
258 bool isConfigurationNode (
void)
const;
259 bool isValueNode (
void)
const;
260 bool isDisconnected (
void)
const;
261 bool isLinkNode (
void)
const;
262 bool isGroupLinkNode (
void)
const;
263 bool isUIDLinkNode (
void)
const;
264 bool isUIDNode (
void)
const;
267 void print (
const unsigned int &depth = -1, std::ostream &out = std::cout)
const;
272 out << t.getValueAsString();
277 const unsigned int& getRow (
void)
const;
278 const unsigned int& getColumn (
void)
const;
279 const unsigned int& getFieldRow (
void)
const;
280 const unsigned int& getFieldColumn (
void)
const;
286 RecordField(
const std::string &table,
const std::string &uid,
287 const std::string &columnName,
const std::string &relativePath,
290 ,columnName_(columnName)
291 ,relativePath_(relativePath)
292 ,columnInfo_(columnInfo)
295 std::string tableName_, columnName_, relativePath_;
300 std::vector<ConfigurationTree::RecordField> getCommonFields(
const std::vector<std::string /*relative-path*/> &recordList,
const std::vector<std::string /*relative-path*/> &fieldAcceptList,
const std::vector<std::string /*relative-path*/> &fieldRejectList,
unsigned int depth = -1)
const;
301 std::set<std::string > getUniqueValuesForField(
const std::vector<std::string /*relative-path*/> &recordList,
const std::string &fieldName)
const;
305 ConfigurationTree(
const ConfigurationManager*
const& configMgr,
const ConfigurationBase*
const& config,
const std::string& groupId,
const ConfigurationBase*
const& linkParentConfig,
const std::string &linkColName,
const std::string &linkColValue,
const unsigned int linkBackRow,
const unsigned int linkBackCol,
const std::string& disconnectedTargetName,
const std::string& disconnectedLinkID,
const std::string &childLinkIndex,
const unsigned int row = ConfigurationView::INVALID,
const unsigned int col = ConfigurationView::INVALID);
308 static void recursivePrint(
const ConfigurationTree& t,
unsigned int depth, std::ostream &out, std::string space);
309 static bool wildCardMatch (
const std::string& needle,
const std::string& haystack);
311 void recursiveGetCommonFields(std::vector<ConfigurationTree::RecordField> &fieldCandidateList, std::vector<int> &fieldCount,
const std::vector<std::string /*relative-path*/> &fieldAcceptList,
const std::vector<std::string /*relative-path*/> &fieldRejectList,
unsigned int depth,
const std::string &relativePathBase,
bool inFirstRecord)
const;
322 const std::string groupId_;
324 const std::string linkColName_;
325 const std::string linkColValue_;
326 const unsigned int linkBackRow_;
327 const unsigned int linkBackCol_;
328 const std::string disconnectedTargetName_;
329 const std::string disconnectedLinkID_;
330 const std::string childLinkIndex_;
331 const unsigned int row_;
332 const unsigned int col_;