1 #include "otsdaq-core/ConfigurationInterface/ConfigurationTree.h"
3 #include "otsdaq-core/ConfigurationInterface/ConfigurationManager.h"
4 #include "otsdaq-core/ConfigurationDataFormats/ConfigurationBase.h"
14 #define __MF_SUBJECT__ "ConfigurationTree"
16 const std::string ConfigurationTree::DISCONNECTED_VALUE =
"X";
17 const std::string ConfigurationTree::VALUE_TYPE_DISCONNECTED =
"Disconnected";
18 const std::string ConfigurationTree::VALUE_TYPE_NODE =
"Node";
21 ConfigurationTree::ConfigurationTree()
27 disconnectedTargetName_ (
""),
28 disconnectedLinkID_ (
""),
46 ConfigurationTree::ConfigurationTree(
49 const std::string& groupId,
50 const std::string& linkColName,
51 const std::string& linkColValue,
52 const std::string& disconnectedTargetName,
53 const std::string& disconnectedLinkID,
54 const std::string& childLinkIndex,
55 const unsigned int row,
56 const unsigned int col)
57 : configMgr_ (configMgr),
58 configuration_ (config),
60 linkColName_ (linkColName),
61 linkColValue_ (linkColValue),
62 disconnectedTargetName_ (disconnectedTargetName),
63 disconnectedLinkID_ (disconnectedLinkID),
64 childLinkIndex_ (childLinkIndex),
74 ss << __COUT_HDR_FL__ <<
"Invalid empty pointer given to tree!\n" <<
75 "\n\tconfigMgr_=" << configMgr_ <<
76 "\n\tconfiguration_=" << configuration_ <<
77 "\n\tconfigView_=" << configView_ <<
80 throw std::runtime_error(ss.str());
84 configView_ = &(configuration_->getView());
88 configView_->getColumnInfo(configView_->getColUID()).getType() != ViewColumnInfo::TYPE_UID)
90 __SS__ <<
"Missing UID column (must column of type " << ViewColumnInfo::TYPE_UID <<
91 ") in config view : " << configView_->getTableName() << std::endl;
93 throw std::runtime_error(ss.str());
99 ConfigurationTree::~ConfigurationTree(
void)
110 void ConfigurationTree::print(
const unsigned int &depth, std::ostream &out)
const
112 recursivePrint(*
this,depth,out,
"\t");
116 void ConfigurationTree::recursivePrint(
const ConfigurationTree &t,
unsigned int depth, std::ostream &out, std::string space)
119 out << space << t.getValueName() <<
" :\t" << t.getValueAsString() << std::endl;
124 out << space << t.getValueName();
125 if(t.isDisconnected())
127 out <<
" :\t" << t.getValueAsString() << std::endl;
131 (t.isGroupLinkNode()?
"Group":
"U") <<
132 "ID=" << t.getValueAsString() <<
136 out << space << t.getValueAsString() <<
" : " << std::endl;
142 auto C = t.getChildren();
144 out << space <<
"{" << std::endl;
146 recursivePrint(c.second,depth-1,out,space +
" ");
148 out << space <<
"}" << std::endl;
156 void ConfigurationTree::getValue(std::string& value)
const
160 if(row_ != ConfigurationView::INVALID && col_ != ConfigurationView::INVALID)
161 configView_->getValue(value,row_,col_);
162 else if(row_ == ConfigurationView::INVALID && col_ == ConfigurationView::INVALID)
164 if(isLinkNode() && isDisconnected())
165 value = (groupId_ ==
"") ? getValueName():groupId_;
167 value = (groupId_ ==
"") ? configuration_->getConfigurationName():groupId_;
169 else if(row_ == ConfigurationView::INVALID)
171 __MOUT__ << std::endl;
172 throw std::runtime_error(
"Malformed ConfigurationTree");
174 else if(col_ == ConfigurationView::INVALID)
175 configView_->getValue(value,row_,configView_->getColUID());
178 __MOUT__ << std::endl;
179 throw std::runtime_error(
"Impossible.");
193 std::string ConfigurationTree::getValue()
const
197 std::string value =
"";
198 if(row_ != ConfigurationView::INVALID && col_ != ConfigurationView::INVALID)
199 configView_->getValue(value,row_,col_);
200 else if(row_ == ConfigurationView::INVALID && col_ == ConfigurationView::INVALID)
202 if(isLinkNode() && isDisconnected())
203 value = (groupId_ ==
"") ? getValueName():groupId_;
205 value = (groupId_ ==
"") ? configuration_->getConfigurationName():groupId_;
207 else if(row_ == ConfigurationView::INVALID)
209 __MOUT__ << std::endl;
210 throw std::runtime_error(
"Malformed ConfigurationTree");
212 else if(col_ == ConfigurationView::INVALID)
213 configView_->getValue(value,row_,configView_->getColUID());
216 __MOUT__ << std::endl;
217 throw std::runtime_error(
"Impossible.");
226 std::string ConfigurationTree::getEscapedValue()
const
228 if(row_ != ConfigurationView::INVALID && col_ != ConfigurationView::INVALID)
229 return configView_->getEscapedValueAsString(row_,col_);
231 __SS__ <<
"Can't get escaped value except from a value node!" <<
232 " This node is type '" << getNodeType() <<
"." << std::endl;
233 __MOUT_ERR__ <<
"\n" << ss.str();
234 throw std::runtime_error(ss.str());
239 const std::string& ConfigurationTree::getConfigurationName(
void)
const
243 __SS__ <<
"Can't get configuration name of node with no configuration pointer!" << std::endl;
244 throw std::runtime_error(ss.str());
246 return configuration_->getConfigurationName();
251 const std::string& ConfigurationTree::getDisconnectedTableName(
void)
const
253 if(isLinkNode() && isDisconnected())
return disconnectedTargetName_;
255 __SS__ <<
"Can't get disconnected target name of node unless it is a disconnected link node!" << std::endl;
256 throw std::runtime_error(ss.str());
261 const std::string& ConfigurationTree::getDisconnectedLinkID(
void)
const
263 if(isLinkNode() && isDisconnected())
return disconnectedLinkID_;
265 __SS__ <<
"Can't get disconnected target name of node unless it is a disconnected link node!" << std::endl;
266 throw std::runtime_error(ss.str());
275 __SS__ <<
"Can't get configuration version of node with no config view pointer!" << std::endl;
276 throw std::runtime_error(ss.str());
278 return configView_->getVersion();
283 const time_t& ConfigurationTree::getConfigurationCreationTime(
void)
const
287 __SS__ <<
"Can't get configuration creation time of node with no config view pointer!" << std::endl;
288 throw std::runtime_error(ss.str());
290 return configView_->getCreationTime();
298 std::vector<std::string> ConfigurationTree::getFixedChoices(
void)
const
302 __SS__ <<
"Can't get fixed choices of node with no config view pointer!" << std::endl;
303 throw std::runtime_error(ss.str());
306 if(getValueType() != ViewColumnInfo::TYPE_FIXED_CHOICE_DATA &&
307 getValueType() != ViewColumnInfo::TYPE_BITMAP_DATA)
309 __SS__ <<
"Can't get fixed choices of node with value type of '" <<
310 getValueType() <<
".' Value type must be '" <<
311 ViewColumnInfo::TYPE_BITMAP_DATA <<
"' or '" <<
312 ViewColumnInfo::TYPE_FIXED_CHOICE_DATA <<
".'" << std::endl;
313 throw std::runtime_error(ss.str());
317 std::vector<std::string> retVec;
318 retVec.push_back(configView_->getColumnInfo(col_).getDefaultValue());
319 std::vector<std::string> choices = configView_->getColumnInfo(col_).getDataChoices();
320 for(
const auto &choice:choices)
321 retVec.push_back(choice);
334 const std::string& ConfigurationTree::getValueAsString(
bool returnLinkTableValue)
const
338 if(returnLinkTableValue)
339 return linkColValue_;
340 else if(isDisconnected())
341 return ConfigurationTree::DISCONNECTED_VALUE;
342 else if(row_ == ConfigurationView::INVALID && col_ == ConfigurationView::INVALID)
343 return (groupId_ ==
"")?configuration_->getConfigurationName():groupId_;
344 else if(col_ == ConfigurationView::INVALID)
345 return configView_->getDataView()[row_][configView_->getColUID()];
348 __MOUT__ << std::endl;
349 throw std::runtime_error(
"Impossible Link.");
352 else if(row_ != ConfigurationView::INVALID && col_ != ConfigurationView::INVALID)
353 return configView_->getDataView()[row_][col_];
354 else if(row_ == ConfigurationView::INVALID && col_ == ConfigurationView::INVALID)
355 return (groupId_ ==
"")?configuration_->getConfigurationName():groupId_;
356 else if(row_ == ConfigurationView::INVALID)
358 __MOUT__ << std::endl;
359 throw std::runtime_error(
"Malformed ConfigurationTree");
361 else if(col_ == ConfigurationView::INVALID)
362 return configView_->getDataView()[row_][configView_->getColUID()];
365 __MOUT__ << std::endl;
366 throw std::runtime_error(
"Impossible.");
374 const std::string& ConfigurationTree::getUIDAsString(
void)
const
376 if(isValueNode() || isUIDLinkNode())
377 return configView_->getDataView()[row_][configView_->getColUID()];
380 __SS__ <<
"Can't get UID of node with type '" <<
381 getNodeType() <<
".' Node type must be '" <<
382 ConfigurationTree::NODE_TYPE_VALUE <<
"' or '" <<
383 ConfigurationTree::NODE_TYPE_UID_LINK <<
".'" << std::endl;
384 throw std::runtime_error(ss.str());
391 const std::string& ConfigurationTree::getValueDataType(
void)
const
394 return configView_->getColumnInfo(col_).getDataType();
396 return ViewColumnInfo::DATATYPE_STRING;
402 bool ConfigurationTree::isDefaultValue(
void)
const
404 if(!isValueNode())
return false;
406 if(getValueDataType() == ViewColumnInfo::DATATYPE_STRING)
408 if(getValueType() == ViewColumnInfo::TYPE_ON_OFF ||
409 getValueType() == ViewColumnInfo::TYPE_TRUE_FALSE ||
410 getValueType() == ViewColumnInfo::TYPE_YES_NO)
411 return getValueAsString() == ViewColumnInfo::DATATYPE_BOOL_DEFAULT;
412 else if(getValueType() == ViewColumnInfo::TYPE_COMMENT)
413 return getValueAsString() == ViewColumnInfo::DATATYPE_COMMENT_DEFAULT ||
414 getValueAsString() ==
"";
416 return getValueAsString() == ViewColumnInfo::DATATYPE_STRING_DEFAULT;
418 else if(getValueDataType() == ViewColumnInfo::DATATYPE_NUMBER)
419 return getValueAsString() == ViewColumnInfo::DATATYPE_NUMBER_DEFAULT;
420 else if(getValueDataType() == ViewColumnInfo::DATATYPE_TIME)
421 return getValueAsString() == ViewColumnInfo::DATATYPE_TIME_DEFAULT;
429 const std::string& ConfigurationTree::getValueType(
void)
const
432 return configView_->getColumnInfo(col_).getType();
433 else if(isLinkNode() && isDisconnected())
434 return ConfigurationTree::VALUE_TYPE_DISCONNECTED;
436 return ConfigurationTree::VALUE_TYPE_NODE;
442 const ViewColumnInfo& ConfigurationTree::getColumnInfo(
void)
const
445 return configView_->getColumnInfo(col_);
448 __SS__ <<
"Can only get column info from a value node! " <<
449 "The node type is " << getNodeType() << std::endl;
450 __MOUT__ <<
"\n" << ss.str() << std::endl;
451 throw std::runtime_error(ss.str());
458 const unsigned int& ConfigurationTree::getRow(
void)
const
463 const unsigned int& ConfigurationTree::getColumn(
void)
const
468 const std::string& ConfigurationTree::getChildLinkIndex(
void)
const
472 __SS__ <<
"Can only get link ID from a link! " <<
473 "The node type is " << getNodeType() << std::endl;
474 __MOUT__ <<
"\n" << ss.str() << std::endl;
475 throw std::runtime_error(ss.str());
477 return childLinkIndex_;
483 const std::string& ConfigurationTree::getValueName(
void)
const
486 return configView_->getColumnInfo(col_).getName();
487 else if(isLinkNode())
491 __SS__ <<
"Can only get value name of a value node!" << std::endl;
492 __MOUT__ <<
"\n" << ss.str() << std::endl;
493 throw std::runtime_error(ss.str());
505 if(childPath.length() <= 1)
507 return tree.getNode(childPath);
544 bool doNotThrowOnBrokenUIDLinks)
const
549 if(nodeString.length() < 1)
throw std::runtime_error(
"Invalid node name!");
551 bool startingSlash = nodeString[0] ==
'/';
553 std::string nodeName = nodeString.substr(startingSlash?1:0, nodeString.find(
'/',1)-(startingSlash?1:0));
556 std::string childPath = nodeString.substr(nodeName.length() + (startingSlash?1:0));
565 if(row_ == ConfigurationView::INVALID && col_ == ConfigurationView::INVALID)
579 configView_->findRow(configView_->getColUID(),nodeName)
580 : configView_->findRowInGroup(configView_->getColUID(),
581 nodeName,groupId_,childLinkIndex_) ),
584 else if(row_ == ConfigurationView::INVALID)
587 throw std::runtime_error(
"Malformed ConfigurationTree");
589 else if(col_ == ConfigurationView::INVALID)
601 unsigned int c = configView_->findCol(nodeName);
602 std::pair<
unsigned int ,
unsigned int > linkPair;
603 bool isGroupLink, isLink;
604 if((isLink = configView_->getChildLink(c, &isGroupLink, &linkPair)) &&
615 childConfig = configMgr_->getConfigurationByName(configView_->getDataView()[row_][linkPair.first]);
616 childConfig->getView();
618 if(doNotThrowOnBrokenUIDLinks)
620 childConfig->getView().findRow(childConfig->getView().getColUID(),
621 configView_->getDataView()[row_][linkPair.second]);
637 configView_->getDataView()[row_][c],
638 configView_->getDataView()[row_][linkPair.first],
639 configView_->getDataView()[row_][linkPair.second],
640 configView_->getColumnInfo(c).getChildLinkIndex());
649 configView_->getDataView()[row_][c],
652 configView_->getColumnInfo(c).getChildLinkIndex(),
653 childConfig->getView().findRow(childConfig->getView().getColUID(),
654 configView_->getDataView()[row_][linkPair.second])
668 childConfig = configMgr_->getConfigurationByName(
669 configView_->getDataView()[row_][linkPair.first]);
670 childConfig->getView();
674 if(configView_->getDataView()[row_][linkPair.first] !=
675 ViewColumnInfo::DATATYPE_LINK_DEFAULT)
676 __MOUT_WARN__ <<
"Found disconnected node! Failed link target from nodeName=" <<
677 nodeName <<
" to table:id=" <<
678 configView_->getDataView()[row_][linkPair.first] <<
":" <<
679 configView_->getDataView()[row_][linkPair.second] <<
684 configView_->getDataView()[row_][linkPair.second],
686 configView_->getDataView()[row_][c],
687 configView_->getDataView()[row_][linkPair.first],
688 configView_->getDataView()[row_][linkPair.second],
689 configView_->getColumnInfo(c).getChildLinkIndex()
697 configView_->getDataView()[row_][linkPair.second],
699 configView_->getDataView()[row_][c],
702 configView_->getColumnInfo(c).getChildLinkIndex()
712 configuration_,
"",
"",
"",
"",
"",
"",
718 catch(std::runtime_error &e)
720 __SS__ <<
"\n\nError occurred descending from node '" << getValue() <<
721 "' looking for child '" << nodeName <<
"'\n\n" << std::endl;
722 ss <<
"--- Additional error detail: \n\n" << e.what() << std::endl;
723 throw std::runtime_error(ss.str());
727 __SS__ <<
"\n\nError occurred descending from node '" << getValue() <<
728 "' looking for child '" << nodeName <<
"'\n\n" << std::endl;
729 throw std::runtime_error(ss.str());
733 __SS__ <<
"\n\nError occurred looking for nodeName=" << nodeName <<
"\n\n" <<
734 "Invalid depth! getNode() called from a value point in the Configuration Tree." << std::endl;
735 throw std::runtime_error(ss.str());
740 ConfigurationTree ConfigurationTree::getBackNode(std::string nodeName,
unsigned int backSteps)
const
742 for(
unsigned int i=0; i<backSteps; i++)
743 nodeName = nodeName.substr(0, nodeName.find_last_of(
'/'));
745 return getNode(nodeName);
751 bool ConfigurationTree::isValueNode(
void)
const
753 return (row_ != ConfigurationView::INVALID && col_ != ConfigurationView::INVALID);
761 bool ConfigurationTree::isDisconnected(
void)
const
765 __SS__ <<
"This is not a Link node! Only a Link node can be disconnected." << std::endl;
766 __MOUT__ << ss.str();
767 throw std::runtime_error(ss.str());
770 return !configuration_ || !configView_;
776 bool ConfigurationTree::isLinkNode(
void)
const
778 return linkColName_ !=
"";
784 const std::string ConfigurationTree::NODE_TYPE_GROUP_TABLE =
"GroupConfigurationNode";
785 const std::string ConfigurationTree::NODE_TYPE_TABLE =
"ConfigurationNode";
786 const std::string ConfigurationTree::NODE_TYPE_GROUP_LINK =
"GroupLinkNode";
787 const std::string ConfigurationTree::NODE_TYPE_UID_LINK =
"UIDLinkNode";
788 const std::string ConfigurationTree::NODE_TYPE_VALUE =
"ValueNode";
789 const std::string ConfigurationTree::NODE_TYPE_UID =
"UIDNode";
790 std::string ConfigurationTree::getNodeType(
void)
const
792 if(isConfigurationNode() && groupId_ !=
"")
return ConfigurationTree::NODE_TYPE_GROUP_TABLE;
793 if(isConfigurationNode())
return ConfigurationTree::NODE_TYPE_TABLE;
794 if(isGroupLinkNode())
return ConfigurationTree::NODE_TYPE_GROUP_LINK;
795 if(isLinkNode())
return ConfigurationTree::NODE_TYPE_UID_LINK;
796 if(isValueNode())
return ConfigurationTree::NODE_TYPE_VALUE;
797 return ConfigurationTree::NODE_TYPE_UID;
803 bool ConfigurationTree::isGroupLinkNode(
void)
const
805 return (isLinkNode() && groupId_ !=
"");
811 bool ConfigurationTree::isUIDLinkNode(
void)
const
813 return (isLinkNode() && groupId_ ==
"");
819 bool ConfigurationTree::isUIDNode(
void)
const
821 return (row_ != ConfigurationView::INVALID && col_ == ConfigurationView::INVALID);
841 std::vector<ConfigurationTree::RecordField> ConfigurationTree::getCommonFields(
842 const std::vector<std::string /*uid*/> &recordList,
843 const std::vector<std::string /*relative-path*/> &fieldAcceptList,
844 const std::vector<std::string /*relative-path*/> &fieldRejectList,
845 unsigned int depth)
const
848 if(!isConfigurationNode())
850 __SS__ <<
"Can only get getCommonFields from a table node! " <<
851 "The node type is " << getNodeType() << std::endl;
852 __MOUT__ <<
"\n" << ss.str() << std::endl;
853 throw std::runtime_error(ss.str());
856 std::vector<ConfigurationTree::RecordField> fieldCandidateList;
857 std::vector<int> fieldCount;
895 auto tableName = getConfigurationName();
897 for(
unsigned int i=0;i<recordList.size();++i)
901 auto recordChildren = getNode(recordList[i]).getChildren();
902 for(
const auto &fieldNode : recordChildren)
906 if(fieldNode.second.isValueNode())
909 if(fieldNode.second.getColumnInfo().getType() ==
910 ViewColumnInfo::TYPE_AUTHOR ||
911 fieldNode.second.getColumnInfo().getType() ==
912 ViewColumnInfo::TYPE_TIMESTAMP)
919 found = fieldAcceptList.size()?
false:
true;
920 for(
const auto &fieldFilter : fieldAcceptList)
921 if(fieldFilter[0] ==
'*')
923 if(fieldNode.first ==
924 fieldFilter.substr(1))
930 else if(fieldFilter.size() &&
931 fieldFilter[fieldFilter.size()-1] ==
'*')
933 if(fieldNode.first.substr(0,fieldFilter.size()-1) ==
934 fieldFilter.substr(0,fieldFilter.size()-1))
942 if(fieldNode.first == fieldFilter)
955 for(
const auto &fieldFilter : fieldRejectList)
956 if(fieldFilter[0] ==
'*')
958 if(fieldNode.first ==
959 fieldFilter.substr(1))
965 else if(fieldFilter.size() &&
966 fieldFilter[fieldFilter.size()-1] ==
'*')
968 if(fieldNode.first.substr(0,fieldFilter.size()-1) ==
969 fieldFilter.substr(0,fieldFilter.size()-1))
977 if(fieldNode.first == fieldFilter)
989 fieldCandidateList.push_back(
995 &fieldNode.second.getColumnInfo()
997 fieldCount.push_back(-1);
1003 else if(depth > 0 &&
1004 fieldNode.second.isUIDLinkNode() &&
1005 !fieldNode.second.isDisconnected())
1008 fieldNode.second.recursiveGetCommonFields(
1014 fieldNode.first +
"/",
1027 for(
unsigned int i=0;i<fieldCandidateList.size();++i)
1032 if(fieldCount[i] != -1 &&
1033 fieldCount[i] != (
int)recordList.size())
1038 fieldCount.erase(fieldCount.begin() + i);
1039 fieldCandidateList.erase(fieldCandidateList.begin() + i);
1044 for(
unsigned int i=0;i<fieldCandidateList.size();++i)
1045 __MOUT__ <<
"Final " << fieldCandidateList[i].relativePath_ <<
1046 fieldCandidateList[i].columnName_ << std::endl;
1048 return fieldCandidateList;
1056 std::set<std::string > ConfigurationTree::getUniqueValuesForField(
1057 const std::vector<std::string /*relative-path*/> &recordList,
1058 const std::string &fieldName)
const
1061 if(!isConfigurationNode())
1063 __SS__ <<
"Can only get getCommonFields from a table node! " <<
1064 "The node type is " << getNodeType() << std::endl;
1065 __MOUT__ <<
"\n" << ss.str() << std::endl;
1066 throw std::runtime_error(ss.str());
1069 std::set<std::string > uniqueValues;
1076 for(
unsigned int i=0;i<recordList.size();++i)
1078 __MOUT__ <<
"Checking " << recordList[i] << std::endl;
1086 uniqueValues.emplace(getNode(recordList[i]).getNode(fieldName).getValueAsString(
true));
1089 return uniqueValues;
1095 void ConfigurationTree::recursiveGetCommonFields(
1096 std::vector<ConfigurationTree::RecordField> &fieldCandidateList,
1097 std::vector<int> &fieldCount,
1098 const std::vector<std::string /*relative-path*/> &fieldAcceptList,
1099 const std::vector<std::string /*relative-path*/> &fieldRejectList,
1101 const std::string &relativePathBase,
1128 auto tableName = getConfigurationName();
1129 auto uid = getUIDAsString();
1132 auto recordChildren = getChildren();
1133 for(
const auto &fieldNode : recordChildren)
1135 if(fieldNode.second.isValueNode())
1138 if(fieldNode.second.getColumnInfo().getType() ==
1139 ViewColumnInfo::TYPE_AUTHOR ||
1140 fieldNode.second.getColumnInfo().getType() ==
1141 ViewColumnInfo::TYPE_TIMESTAMP)
1148 found = fieldAcceptList.size()?
false:
true;
1149 for(
const auto &fieldFilter : fieldAcceptList)
1150 if(fieldFilter[0] ==
'*')
1152 if(fieldNode.first ==
1153 fieldFilter.substr(1))
1159 else if(fieldFilter.size() &&
1160 fieldFilter[fieldFilter.size()-1] ==
'*')
1162 if((relativePathBase + fieldNode.first).substr(
1163 0,fieldFilter.size()-1) ==
1164 fieldFilter.substr(0,fieldFilter.size()-1))
1172 if((relativePathBase + fieldNode.first) ==
1185 for(
const auto &fieldFilter : fieldRejectList)
1186 if(fieldFilter[0] ==
'*')
1188 if(fieldNode.first ==
1189 fieldFilter.substr(1))
1195 else if(fieldFilter.size() &&
1196 fieldFilter[fieldFilter.size()-1] ==
'*')
1198 if((relativePathBase + fieldNode.first).substr(
1199 0,fieldFilter.size()-1) ==
1200 fieldFilter.substr(0,fieldFilter.size()-1))
1208 if((relativePathBase + fieldNode.first) ==
1222 fieldCandidateList.push_back(
1228 &fieldNode.second.getColumnInfo()
1230 fieldCount.push_back(1);
1237 for(j=0;j<fieldCandidateList.size();++j)
1239 if((relativePathBase + fieldNode.first) ==
1240 (fieldCandidateList[j].relativePath_ +
1241 fieldCandidateList[j].columnName_))
1252 else if(depth > 0 &&
1253 fieldNode.second.isUIDLinkNode() &&
1254 !fieldNode.second.isDisconnected())
1257 fieldNode.second.recursiveGetCommonFields(
1263 (relativePathBase + fieldNode.first) +
"/",
1274 std::vector<std::pair<std::string,ConfigurationTree> > ConfigurationTree::getChildren(
1275 std::map<std::string /*relative-path*/, std::string /*value*/> filterMap)
const
1277 std::vector<std::pair<std::string,ConfigurationTree> > retMap;
1281 bool filtering = filterMap.size();
1283 std::string fieldValue;
1285 std::vector<std::string> childrenNames = getChildrenNames();
1286 for(
auto &childName : childrenNames)
1296 for(
const auto &filterPair:filterMap)
1298 std::string filterPath = childName +
"/" + filterPair.first;
1304 std::istringstream f(filterPair.second);
1308 while (getline(f, fieldValue,
','))
1316 __MOUT__ <<
"\t\tCheck: " << filterPair.first <<
1317 " == " << fieldValue <<
" ??? " <<
1318 this->getNode(filterPath).getValueAsString(
true) <<
1320 if(this->getNode(filterPath).getValueAsString(
true) ==
1321 ConfigurationView::decodeURIComponent(fieldValue))
1331 __SS__ <<
"Failed to access filter path '" <<
1332 filterPath <<
"' - aborting." << std::endl;
1333 __MOUT_ERR__ <<
"\n" << ss.str();
1334 throw std::runtime_error(ss.str());
1342 __MOUT__ <<
"\tChild accepted: " << childName << std::endl;
1345 retMap.push_back(std::pair<std::string,ConfigurationTree>(childName,
1346 this->getNode(childName,
true)));
1356 std::map<std::string,ConfigurationTree> ConfigurationTree::getChildrenMap(
void)
const
1358 std::map<std::string,ConfigurationTree> retMap;
1362 std::vector<std::string> childrenNames = getChildrenNames();
1363 for(
auto& childName : childrenNames)
1366 retMap.insert(std::pair<std::string,ConfigurationTree>(childName, this->getNode(childName)));
1374 bool ConfigurationTree::isConfigurationNode(
void)
const
1376 return (row_ == ConfigurationView::INVALID && col_ == ConfigurationView::INVALID);
1382 std::vector<std::string> ConfigurationTree::getChildrenNames(
void)
const
1384 std::vector<std::string> retSet;
1388 __SS__ <<
"Can not get children names of '" <<
1389 getValueAsString() <<
1390 "' with null configuration view pointer!" << std::endl;
1391 if(isLinkNode() && isDisconnected())
1392 ss <<
" This node is a disconnected link to " <<
1393 getDisconnectedTableName() << std::endl;
1394 __MOUT_ERR__ <<
"\n" << ss.str();
1395 throw std::runtime_error(ss.str());
1398 if(row_ == ConfigurationView::INVALID && col_ == ConfigurationView::INVALID)
1403 for(
unsigned int r = 0; r<configView_->getNumberOfRows(); ++r)
1404 if(groupId_ ==
"" ||
1405 configView_->isEntryInGroup(r,childLinkIndex_,groupId_))
1408 retSet.push_back(configView_->getDataView()[r][configView_->getColUID()]);
1410 else if(row_ == ConfigurationView::INVALID)
1411 throw std::runtime_error(
"Malformed ConfigurationTree");
1412 else if(col_ == ConfigurationView::INVALID)
1417 for(
unsigned int c = 0; c<configView_->getNumberOfColumns(); ++c)
1418 if(c == configView_->getColUID() ||
1419 configView_->getColumnInfo(c).isChildLinkGroupID() ||
1420 configView_->getColumnInfo(c).isChildLinkUID())
1423 retSet.push_back(configView_->getColumnInfo(c).getName());
1427 __MOUT__ <<
"\n\nError occurred looking for children of nodeName=" << getValueName() <<
"\n\n" << std::endl;
1428 throw std::runtime_error(
"Invalid depth! getChildrenValues() called from a value point in the Configuration Tree.");