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;
69 std::cout << __PRETTY_FUNCTION__ <<
"OPERATOR= COPY CONSTRUCTOR ConfigManager: " << configMgr_ <<
" configuration: " << configuration_ << std::endl;
73 std::cout << __PRETTY_FUNCTION__ <<
"OPERATOR= COPY CONSTRUCTOR CANNOT BE USED - SO YOUR CODE IS WRONG! Crashing now." << std::endl;
74 std::cout << __PRETTY_FUNCTION__ <<
"OPERATOR= COPY CONSTRUCTOR CANNOT BE USED - SO YOUR CODE IS WRONG! Crashing now." << std::endl;
75 std::cout << __PRETTY_FUNCTION__ <<
"OPERATOR= COPY CONSTRUCTOR CANNOT BE USED - SO YOUR CODE IS WRONG! Crashing now." << std::endl;
76 std::cout << __PRETTY_FUNCTION__ <<
"OPERATOR= COPY CONSTRUCTOR CANNOT BE USED - SO YOUR CODE IS WRONG! Crashing now." << std::endl;
77 std::cout << __PRETTY_FUNCTION__ <<
"OPERATOR= COPY CONSTRUCTOR CANNOT BE USED - SO YOUR CODE IS WRONG! Crashing now." << std::endl;
78 std::cout << __PRETTY_FUNCTION__ <<
"OPERATOR= COPY CONSTRUCTOR CANNOT BE USED - SO YOUR CODE IS WRONG! Crashing now." << std::endl;
79 std::cout << __PRETTY_FUNCTION__ <<
"OPERATOR= COPY CONSTRUCTOR CANNOT BE USED - SO YOUR CODE IS WRONG! Crashing now." << std::endl;
84 configMgr_ = a.configMgr_;
85 configuration_ = a.configuration_;
91 configView_ = a.configView_;
92 std::cout << __PRETTY_FUNCTION__ <<
"OPERATOR COPY CONSTRUCTOR" << std::endl;
97 static const std::string DISCONNECTED_VALUE;
98 static const std::string VALUE_TYPE_DISCONNECTED;
99 static const std::string VALUE_TYPE_NODE;
101 static const std::string NODE_TYPE_GROUP_TABLE;
102 static const std::string NODE_TYPE_TABLE;
103 static const std::string NODE_TYPE_GROUP_LINK;
104 static const std::string NODE_TYPE_UID_LINK;
105 static const std::string NODE_TYPE_VALUE;
106 static const std::string NODE_TYPE_UID;
116 void getValue(T& value)
const
118 if(row_ != ConfigurationView::INVALID && col_ != ConfigurationView::INVALID)
125 __MOUT__ <<
"Success following path to tree node!" << std::endl;
135 value = handleValidateValueForColumn(configView_,
136 valueAsTreeNode.getValueAsString(),col_,
identity<T>());
138 __MOUT__ <<
"Successful value!" << std::endl;
147 configView_->getValue(value,row_,col_);
149 else if(row_ == ConfigurationView::INVALID && col_ == ConfigurationView::INVALID)
150 throw std::runtime_error(
"Requesting getValue on config node level. Must be a value node.");
151 else if(row_ == ConfigurationView::INVALID)
153 std::cout << __COUT_HDR_FL__ << std::endl;
154 throw std::runtime_error(
"Malformed ConfigurationTree");
156 else if(col_ == ConfigurationView::INVALID)
157 throw std::runtime_error(
"Requesting getValue on uid node level. Must be a value node.");
160 std::cout << __COUT_HDR_FL__ << std::endl;
161 throw std::runtime_error(
"Impossible");
166 void getValue (std::string& value)
const;
173 T getValue(
void)
const
184 ConfigurationTree::getValue<T>(value);
208 std::string getValue (
void)
const;
216 __SS__ <<
"Null configView" << std::endl;
217 __MOUT_ERR__ << ss.str();
218 throw std::runtime_error(ss.str());
220 std::cout <<
"210:::::" <<
"handleValidateValueForColumn<T>" << std::endl;
221 return configView->validateValueForColumn<T>(
229 __SS__ <<
"Null configView" << std::endl;
230 __MOUT_ERR__ << ss.str();
231 throw std::runtime_error(ss.str());
233 std::cout <<
"210:::::" <<
"handleValidateValueForColumn<string>" << std::endl;
234 return configView->validateValueForColumn(
241 ConfigurationTree getNode (
const std::string& nodeName,
bool doNotThrowOnBrokenUIDLinks=
false)
const;
242 ConfigurationTree getBackNode ( std::string nodeName,
unsigned int backSteps=1)
const;
246 const std::string& getConfigurationName (
void)
const;
248 const time_t& getConfigurationCreationTime(
void)
const;
249 std::vector<std::string> getChildrenNames (
void)
const;
250 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;
251 std::map<std::string,ConfigurationTree> getChildrenMap (
void)
const;
252 std::string getEscapedValue (
void)
const;
253 const std::string& getValueAsString (
bool returnLinkTableValue=
false)
const;
254 const std::string& getUIDAsString (
void)
const;
255 const std::string& getValueDataType (
void)
const;
256 const std::string& getValueType (
void)
const;
257 const std::string& getValueName (
void)
const;
258 std::string getNodeType (
void)
const;
259 const std::string& getDisconnectedTableName (
void)
const;
260 const std::string& getDisconnectedLinkID (
void)
const;
261 const std::string& getChildLinkIndex (
void)
const;
262 std::vector<std::string> getFixedChoices (
void)
const;
268 bool isDefaultValue (
void)
const;
269 bool isConfigurationNode (
void)
const;
270 bool isValueNode (
void)
const;
271 bool isDisconnected (
void)
const;
272 bool isLinkNode (
void)
const;
273 bool isGroupLinkNode (
void)
const;
274 bool isUIDLinkNode (
void)
const;
275 bool isUIDNode (
void)
const;
278 void print (
const unsigned int &depth = -1, std::ostream &out = std::cout)
const;
283 out << t.getValueAsString();
288 const unsigned int& getRow (
void)
const;
289 const unsigned int& getColumn (
void)
const;
295 RecordField(
const std::string &table,
const std::string &uid,
296 const std::string &columnName,
const std::string &relativePath,
299 ,columnName_(columnName)
300 ,relativePath_(relativePath)
301 ,columnInfo_(columnInfo)
304 std::string tableName_, columnName_, relativePath_;
309 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;
310 std::set<std::string > getUniqueValuesForField(
const std::vector<std::string /*relative-path*/> &recordList,
const std::string &fieldName)
const;
314 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 std::string& disconnectedTargetName,
const std::string& disconnectedLinkID,
const std::string &childLinkIndex,
const unsigned int row = ConfigurationView::INVALID,
const unsigned int col = ConfigurationView::INVALID);
317 static void recursivePrint(
const ConfigurationTree& t,
unsigned int depth, std::ostream &out, std::string space);
318 static bool wildCardMatch (
const std::string& needle,
const std::string& haystack);
320 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;
331 const std::string groupId_;
333 const std::string linkColName_;
334 const std::string linkColValue_;
335 const std::string disconnectedTargetName_;
336 const std::string disconnectedLinkID_;
337 const std::string childLinkIndex_;
338 const unsigned int row_;
339 const unsigned int col_;