1 #ifndef _ots_ConfigurationTree_h_
2 #define _ots_ConfigurationTree_h_
4 #include "otsdaq-core/ConfigurationDataFormats/ConfigurationView.h"
16 class ConfigurationManager;
17 class ConfigurationBase;
18 class ConfigurationView;
22 friend class ConfigurationGUISupervisor;
51 std::cout << __PRETTY_FUNCTION__ <<
"OPERATOR= COPY CONSTRUCTOR ConfigManager: " << configMgr_ <<
" configuration: " << configuration_ << std::endl;
55 std::cout << __PRETTY_FUNCTION__ <<
"OPERATOR= COPY CONSTRUCTOR CANNOT BE USED - SO YOUR CODE IS WRONG! Crashing now." << std::endl;
56 std::cout << __PRETTY_FUNCTION__ <<
"OPERATOR= COPY CONSTRUCTOR CANNOT BE USED - SO YOUR CODE IS WRONG! Crashing now." << std::endl;
57 std::cout << __PRETTY_FUNCTION__ <<
"OPERATOR= COPY CONSTRUCTOR CANNOT BE USED - SO YOUR CODE IS WRONG! Crashing now." << std::endl;
58 std::cout << __PRETTY_FUNCTION__ <<
"OPERATOR= COPY CONSTRUCTOR CANNOT BE USED - SO YOUR CODE IS WRONG! Crashing now." << std::endl;
59 std::cout << __PRETTY_FUNCTION__ <<
"OPERATOR= COPY CONSTRUCTOR CANNOT BE USED - SO YOUR CODE IS WRONG! Crashing now." << std::endl;
60 std::cout << __PRETTY_FUNCTION__ <<
"OPERATOR= COPY CONSTRUCTOR CANNOT BE USED - SO YOUR CODE IS WRONG! Crashing now." << std::endl;
61 std::cout << __PRETTY_FUNCTION__ <<
"OPERATOR= COPY CONSTRUCTOR CANNOT BE USED - SO YOUR CODE IS WRONG! Crashing now." << std::endl;
66 configMgr_ = a.configMgr_;
67 configuration_ = a.configuration_;
73 configView_ = a.configView_;
74 std::cout << __PRETTY_FUNCTION__ <<
"OPERATOR COPY CONSTRUCTOR" << std::endl;
79 static const std::string DISCONNECTED_VALUE;
80 static const std::string VALUE_TYPE_DISCONNECTED;
81 static const std::string VALUE_TYPE_NODE;
83 static const std::string NODE_TYPE_GROUP_TABLE;
84 static const std::string NODE_TYPE_TABLE;
85 static const std::string NODE_TYPE_GROUP_LINK;
86 static const std::string NODE_TYPE_UID_LINK;
87 static const std::string NODE_TYPE_VALUE;
88 static const std::string NODE_TYPE_UID;
98 void getValue(T& value)
const
100 if(row_ != ConfigurationView::INVALID && col_ != ConfigurationView::INVALID)
101 configView_->getValue(value,row_,col_);
102 else if(row_ == ConfigurationView::INVALID && col_ == ConfigurationView::INVALID)
103 throw std::runtime_error(
"Requesting getValue on config node level. Must be a value node.");
104 else if(row_ == ConfigurationView::INVALID)
106 std::cout << __COUT_HDR_FL__ << std::endl;
107 throw std::runtime_error(
"Malformed ConfigurationTree");
109 else if(col_ == ConfigurationView::INVALID)
110 throw std::runtime_error(
"Requesting getValue on uid node level. Must be a value node.");
113 std::cout << __COUT_HDR_FL__ << std::endl;
114 throw std::runtime_error(
"Impossible");
122 T getValue(
void)
const
125 if(row_ != ConfigurationView::INVALID && col_ != ConfigurationView::INVALID)
127 configView_->getValue(value,row_,col_);
130 else if(row_ == ConfigurationView::INVALID && col_ == ConfigurationView::INVALID)
131 throw std::runtime_error(
"Requesting getValue on config node level. Must be a value node.");
132 else if(row_ == ConfigurationView::INVALID)
134 std::cout << __COUT_HDR_FL__ << std::endl;
135 throw std::runtime_error(
"Malformed ConfigurationTree");
137 else if(col_ == ConfigurationView::INVALID)
138 throw std::runtime_error(
"Requesting getValue on uid node level. Must be a value node.");
141 std::cout << __COUT_HDR_FL__ << std::endl;
142 throw std::runtime_error(
"Impossible");
147 ConfigurationTree getNode (
const std::string& nodeName,
bool doNotThrowOnBrokenUIDLinks=
false)
const;
148 ConfigurationTree getBackNode ( std::string nodeName,
unsigned int backSteps=1)
const;
152 const std::string& getConfigurationName (
void)
const;
154 const time_t& getConfigurationCreationTime(
void)
const;
155 std::vector<std::string> getChildrenNames (
void)
const;
156 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;
157 std::map<std::string,ConfigurationTree> getChildrenMap (
void)
const;
158 void getValue (std::string& value)
const;
159 std::string getValue (
void)
const;
160 std::string getEscapedValue (
void)
const;
161 const std::string& getValueAsString (
bool returnLinkTableValue=
false)
const;
162 const std::string& getUIDAsString (
void)
const;
163 const std::string& getValueDataType (
void)
const;
164 const std::string& getValueType (
void)
const;
165 const std::string& getValueName (
void)
const;
166 std::string getNodeType (
void)
const;
167 const std::string& getDisconnectedTableName (
void)
const;
168 const std::string& getDisconnectedLinkID (
void)
const;
169 const std::string& getChildLinkIndex (
void)
const;
170 std::vector<std::string> getFixedChoices (
void)
const;
173 const unsigned int& getRow (
void)
const;
174 const unsigned int& getColumn (
void)
const;
180 RecordField(
const std::string &table,
const std::string &uid,
181 const std::string &columnName,
const std::string &relativePath,
184 ,columnName_(columnName)
185 ,relativePath_(relativePath)
186 ,columnInfo_(columnInfo)
189 std::string tableName_, columnName_, relativePath_;
194 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;
195 std::set<std::string > getUniqueValuesForField(
const std::vector<std::string /*relative-path*/> &recordList,
const std::string &fieldName)
const;
202 bool isDefaultValue (
void)
const;
203 bool isConfigurationNode (
void)
const;
204 bool isValueNode (
void)
const;
205 bool isDisconnected (
void)
const;
206 bool isLinkNode (
void)
const;
207 bool isGroupLinkNode (
void)
const;
208 bool isUIDLinkNode (
void)
const;
209 bool isUIDNode (
void)
const;
212 void print (
const unsigned int &depth = -1, std::ostream &out = std::cout)
const;
217 out << t.getValueAsString();
222 ConfigurationTree(
const ConfigurationManager*
const& configMgr,
const ConfigurationBase*
const& config,
const std::string& groupId,
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);
225 static void recursivePrint(
const ConfigurationTree& t,
unsigned int depth, std::ostream &out, std::string space);
227 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;
239 const std::string groupId_;
240 const std::string linkColName_;
241 const std::string linkColValue_;
242 const std::string disconnectedTargetName_;
243 const std::string disconnectedLinkID_;
244 const std::string childLinkIndex_;
245 const unsigned int row_;
246 const unsigned int col_;