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 __COUT__ <<
"Success following path to tree node!" << std::endl;
135 value = handleValidateValueForColumn(configView_,
136 valueAsTreeNode.getValueAsString(),col_,
identity<T>());
138 __COUT__ <<
"Successful value!" << std::endl;
147 configView_->getValue(value,row_,col_);
149 else if(row_ == ConfigurationView::INVALID && col_ == ConfigurationView::INVALID)
151 __SS__ <<
"Requesting getValue on config node level. Must be a value node." << std::endl;
152 __COUT_ERR__ << ss.str();
153 throw std::runtime_error(ss.str());
155 else if(row_ == ConfigurationView::INVALID)
157 __SS__ <<
"Malformed ConfigurationTree" << std::endl;
158 __COUT_ERR__ << ss.str();
159 throw std::runtime_error(ss.str());
161 else if(col_ == ConfigurationView::INVALID)
163 __SS__ <<
"Requesting getValue on uid node level. Must be a value node." << std::endl;
164 __COUT_ERR__ << ss.str();
165 throw std::runtime_error(ss.str());
169 __SS__ <<
"Impossible" << std::endl;
170 __COUT_ERR__ << ss.str();
171 throw std::runtime_error(ss.str());
176 void getValue (std::string& value)
const;
183 T getValue(
void)
const
186 ConfigurationTree::getValue<T>(value);
191 std::string getValue (
void)
const;
199 __SS__ <<
"Null configView" << std::endl;
200 __COUT_ERR__ << ss.str();
201 throw std::runtime_error(ss.str());
203 std::cout <<
"210:::::" <<
"handleValidateValueForColumn<T>" << std::endl;
204 return configView->validateValueForColumn<T>(
212 __SS__ <<
"Null configView" << std::endl;
213 __COUT_ERR__ << ss.str();
214 throw std::runtime_error(ss.str());
216 std::cout <<
"210:::::" <<
"handleValidateValueForColumn<string>" << std::endl;
217 return configView->validateValueForColumn(
224 ConfigurationTree getNode (
const std::string& nodeName,
bool doNotThrowOnBrokenUIDLinks=
false)
const;
225 ConfigurationTree getBackNode ( std::string nodeName,
unsigned int backSteps=1)
const;
229 const std::string& getConfigurationName (
void)
const;
230 const std::string& getFieldConfigurationName (
void)
const;
232 const time_t& getConfigurationCreationTime(
void)
const;
233 std::vector<std::string> getChildrenNames (
void)
const;
234 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;
235 std::map<std::string,ConfigurationTree> getChildrenMap (
void)
const;
236 std::string getEscapedValue (
void)
const;
237 const std::string& getValueAsString (
bool returnLinkTableValue=
false)
const;
238 const std::string& getUIDAsString (
void)
const;
239 const std::string& getValueDataType (
void)
const;
240 const std::string& getValueType (
void)
const;
241 const std::string& getValueName (
void)
const;
242 std::string getNodeType (
void)
const;
243 const std::string& getDisconnectedTableName (
void)
const;
244 const std::string& getDisconnectedLinkID (
void)
const;
245 const std::string& getChildLinkIndex (
void)
const;
246 std::vector<std::string> getFixedChoices (
void)
const;
252 bool isDefaultValue (
void)
const;
253 bool isConfigurationNode (
void)
const;
254 bool isValueNode (
void)
const;
255 bool isDisconnected (
void)
const;
256 bool isLinkNode (
void)
const;
257 bool isGroupLinkNode (
void)
const;
258 bool isUIDLinkNode (
void)
const;
259 bool isUIDNode (
void)
const;
262 void print (
const unsigned int &depth = -1, std::ostream &out = std::cout)
const;
267 out << t.getValueAsString();
272 const unsigned int& getRow (
void)
const;
273 const unsigned int& getColumn (
void)
const;
274 const unsigned int& getFieldRow (
void)
const;
275 const unsigned int& getFieldColumn (
void)
const;
281 RecordField(
const std::string &table,
const std::string &uid,
282 const std::string &columnName,
const std::string &relativePath,
285 ,columnName_(columnName)
286 ,relativePath_(relativePath)
287 ,columnInfo_(columnInfo)
290 std::string tableName_, columnName_, relativePath_;
295 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;
296 std::set<std::string > getUniqueValuesForField(
const std::vector<std::string /*relative-path*/> &recordList,
const std::string &fieldName)
const;
300 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);
303 static void recursivePrint(
const ConfigurationTree& t,
unsigned int depth, std::ostream &out, std::string space);
304 static bool wildCardMatch (
const std::string& needle,
const std::string& haystack);
306 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;
317 const std::string groupId_;
319 const std::string linkColName_;
320 const std::string linkColValue_;
321 const unsigned int linkBackRow_;
322 const unsigned int linkBackCol_;
323 const std::string disconnectedTargetName_;
324 const std::string disconnectedLinkID_;
325 const std::string childLinkIndex_;
326 const unsigned int row_;
327 const unsigned int col_;