1 #ifndef _ots_ConfigurationTree_h_
2 #define _ots_ConfigurationTree_h_
4 #include "otsdaq/TableCore/TableView.h"
8 class ConfigurationManager;
19 friend class ConfigurationGUISupervisor;
55 __COUT__ <<
"OPERATOR= COPY CONSTRUCTOR ConfigManager: " << configMgr_
56 <<
" configuration: " << table_ << std::endl;
61 __COUT__ <<
"OPERATOR= COPY CONSTRUCTOR CANNOT BE USED - ConfigurationTree is a "
62 "const class. SO YOUR CODE IS WRONG! You should probably instantiate "
63 "and initialize another ConfigurationTree, rather than assigning to "
64 "an existing ConfigurationTree. Crashing now."
66 __COUT__ <<
"OPERATOR= COPY CONSTRUCTOR CANNOT BE USED - ConfigurationTree is a "
67 "const class. SO YOUR CODE IS WRONG! You should probably instantiate "
68 "and initialize another ConfigurationTree, rather than assigning to "
69 "an existing ConfigurationTree. Crashing now."
71 __COUT__ <<
"OPERATOR= COPY CONSTRUCTOR CANNOT BE USED - ConfigurationTree is a "
72 "const class. SO YOUR CODE IS WRONG! You should probably instantiate "
73 "and initialize another ConfigurationTree, rather than assigning to "
74 "an existing ConfigurationTree. Crashing now."
76 __COUT__ <<
"OPERATOR= COPY CONSTRUCTOR CANNOT BE USED - ConfigurationTree is a "
77 "const class. SO YOUR CODE IS WRONG! You should probably instantiate "
78 "and initialize another ConfigurationTree, rather than assigning to "
79 "an existing ConfigurationTree. Crashing now."
81 __COUT__ <<
"OPERATOR= COPY CONSTRUCTOR CANNOT BE USED - ConfigurationTree is a "
82 "const class. SO YOUR CODE IS WRONG! You should probably instantiate "
83 "and initialize another ConfigurationTree, rather than assigning to "
84 "an existing ConfigurationTree. Crashing now."
86 __COUT__ <<
"OPERATOR= COPY CONSTRUCTOR CANNOT BE USED - ConfigurationTree is a "
87 "const class. SO YOUR CODE IS WRONG! You should probably instantiate "
88 "and initialize another ConfigurationTree, rather than assigning to "
89 "an existing ConfigurationTree. Crashing now."
97 configMgr_ = a.configMgr_;
104 tableView_ = a.tableView_;
105 __COUT__ <<
"OPERATOR COPY CONSTRUCTOR" << std::endl;
109 static const std::string DISCONNECTED_VALUE;
110 static const std::string VALUE_TYPE_DISCONNECTED;
111 static const std::string VALUE_TYPE_NODE;
114 static const std::string NODE_TYPE_TABLE;
115 static const std::string NODE_TYPE_GROUP_LINK;
116 static const std::string NODE_TYPE_UID_LINK;
117 static const std::string NODE_TYPE_VALUE;
118 static const std::string NODE_TYPE_UID;
119 static const std::string NODE_TYPE_ROOT;
121 static const std::string ROOT_NAME;
126 BitMap() : isDefault_(
true), zero_(T()) {}
129 const T& get(
unsigned int row,
unsigned int col)
const
131 return isDefault_ ? zero_ : bitmap_[row][col];
133 unsigned int numberOfRows()
const {
return bitmap_.size(); }
134 unsigned int numberOfColumns(
unsigned int row)
const
136 return bitmap_[row].size();
138 void print(std::ostream& out = std::cout)
const;
141 std::vector<std::vector<T>> bitmap_;
157 void getValue (std::string& value)
const;
182 T handleValidateValueForColumn(
187 std::string handleValidateValueForColumn(
196 std::map<std::string, ConfigurationTree>
getNodes (
const std::string& nodeString)
const;
197 ConfigurationTree getBackNode (std::string nodeName,
unsigned int backSteps = 1)
const;
198 ConfigurationTree getForwardNode (std::string nodeName,
unsigned int forwardSteps = 1)
const;
212 std::vector<std::string>
getChildrenNames (
bool byPriority =
false,
bool onlyStatusTrue =
false)
const;
213 std::vector<std::vector<std::pair<
215 std::string > filterMap = std::map<std::string /*relative-path*/, std::string /*value*/>(),
216 bool onlyStatusTrue =
false)
const;
217 std::vector<std::pair<std::string,
219 std::string > filterMap = std::map<std::string /*relative-path*/, std::string /*value*/>(),
220 bool byPriority =
false,
221 bool onlyStatusTrue =
false)
const;
222 std::map<std::string, ConfigurationTree>
getChildrenMap (std::map<std::string ,
223 std::string > filterMap = std::map<std::string /*relative-path*/, std::string /*value*/>(),
224 bool onlyStatusTrue =
false)
const;
225 bool passFilterMap (
const std::string& childName, std::map<std::string /*relative-path*/, std::string /*value*/> filterMap)
const;
227 const std::string&
getValueAsString (
bool returnLinkTableValue =
false)
const;
231 const std::string&
getAuthor (
void)
const;
237 std::string getNodeType (
void)
const;
248 inline bool isRootNode (
void)
const {
return (!
isLinkNode() && !table_); }
249 inline bool isTableNode (
void)
const {
return (table_ && row_ == TableView::INVALID && col_ == TableView::INVALID); }
259 bool isStatusNode (
void)
const;
263 void print (
const unsigned int& depth = -1, std::ostream& out = std::cout)
const;
264 std::string
nodeDump (
bool forcePrintout =
false)
const;
277 const unsigned int&
getRow (
void)
const;
278 const unsigned int&
getColumn (
void)
const;
288 const std::string& columnName,
289 const std::string& relativePath,
292 , columnName_(columnName)
293 , relativePath_(relativePath)
294 , columnInfo_(columnInfo)
298 std::string tableName_, columnName_, relativePath_;
304 const std::vector<std::string /*relative-path*/>& recordList,
305 const std::vector<std::string /*relative-path*/>& fieldAcceptList,
306 const std::vector<std::string /*relative-path*/>& fieldRejectList,
307 unsigned int depth = -1,
308 bool autoSelectFilterFields =
false)
const;
310 const std::vector<std::string /*relative-path*/>& recordList,
311 const std::string& fieldName,
312 std::string* fieldGroupIDChildLinkIndex = 0)
const;
318 const std::string& groupId,
319 const TableBase*
const& linkParentConfig,
320 const std::string& linkColName,
321 const std::string& linkColValue,
322 const unsigned int linkBackRow,
323 const unsigned int linkBackCol,
324 const std::string& disconnectedTargetName,
325 const std::string& disconnectedLinkID,
326 const std::string& childLinkIndex,
327 const unsigned int row = TableView::INVALID,
328 const unsigned int col = TableView::INVALID);
331 ConfigurationTree recursiveGetNode (
const std::string& nodeName,
bool doNotThrowOnBrokenUIDLinks,
const std::string& originalNodeString)
const;
332 static void recursivePrint (
const ConfigurationTree& t,
unsigned int depth, std::ostream& out, std::string space);
334 void recursiveGetCommonFields (
335 std::vector<ConfigurationTree::RecordField>& fieldCandidateList,
336 std::vector<int>& fieldCount,
337 const std::vector<std::string /*relative-path*/>& fieldAcceptList,
338 const std::vector<std::string /*relative-path*/>& fieldRejectList,
340 const std::string& relativePathBase,
341 bool inFirstRecord)
const;
352 const std::string groupId_;
355 const std::string linkColName_;
356 const std::string linkColValue_;
357 const unsigned int linkBackRow_;
358 const unsigned int linkBackCol_;
359 const std::string disconnectedTargetName_;
361 const std::string disconnectedLinkID_;
362 const std::string childLinkIndex_;
363 const unsigned int row_;
364 const unsigned int col_;
367 static time_t LAST_NODE_DUMP_TIME;
370 #include "otsdaq/ConfigurationInterface/ConfigurationTree.icc"
381 out <<
"Bitmap print of empty bitmap.";
385 out <<
"Bitmap print of size " << bitmap_.size() <<
" x " << bitmap_[0].size() << __E__;
387 for(
unsigned int c = 0; c < bitmap_[0].size(); ++c)
388 out << std::right << std::setw(15) << c <<
' ';
389 out <<
"\n-------+-";
390 for(
unsigned int c = 0; c < bitmap_[0].size(); ++c)
391 out <<
"---------------+";
392 for(
unsigned int r = 0; r < bitmap_.size(); ++r)
394 out <<
"\n" << std::right << std::setw(6) << r <<
" : ";
396 for(
unsigned int c = 0; c < bitmap_[r].size(); ++c)
397 out << std::right << std::setw(15) << std::fixed << std::setprecision(3) << (uint16_t)get(r,c) <<
' ';
399 for(
unsigned int c = 0; c < bitmap_[r].size(); ++c)
400 out << std::right << std::setw(15) << std::fixed << std::setprecision(3) << get(r,c) <<
' ';
402 out <<
"\n=======+=";
403 for(
unsigned int c = 0; c < bitmap_[0].size(); ++c)
404 out <<
"===============+";
418 out <<
"Bitmap print of empty bitmap.";
422 out <<
"Bitmap print of size " << bitmap_.size() <<
" x " << bitmap_[0].size() << __E__;
424 for(
unsigned int c = 0; c < bitmap_[0].size(); ++c)
425 out << std::right << std::setw(15) << c <<
' ';
426 out <<
"\n-------+-";
427 for(
unsigned int c = 0; c < bitmap_[0].size(); ++c)
428 out <<
"---------------+";
429 for(
unsigned int r = 0; r < bitmap_.size(); ++r)
431 out <<
"\n" << std::right << std::setw(6) << r <<
" : ";
432 for(
unsigned int c = 0; c < bitmap_[r].size(); ++c)
433 out << std::right << std::setw(15) << get(r,c) <<
' ';
435 out <<
"\n=======+=";
436 for(
unsigned int c = 0; c < bitmap_[0].size(); ++c)
437 out <<
"===============+";
<virtual so future plugins can inherit from multiple table base classes
const unsigned int & getRow(void) const
getRow
const std::string & getValueDataType(void) const
bool isUIDNode(void) const
std::map< std::string, ConfigurationTree > getNodes(const std::string &nodeString) const
getNodes
const TableVersion & getTableVersion(void) const
getTableVersion
bool isDisconnected(void) const
const std::string & getAuthor(void) const
getAuthor
const std::string & getComment(void) const
getComment
std::vector< std::string > getChildrenNames(bool byPriority=false, bool onlyStatusTrue=false) const
bool isEnabled(void) const
same as status()
static const std::string NODE_TYPE_GROUP_TABLE
bool isValueNumberDataType(void) const
ConfigurationTree getNode(const std::string &nodeName, bool doNotThrowOnBrokenUIDLinks=false) const
navigating between nodes
const std::string & getTableName(void) const
getTableName
T getValueWithDefault(const T &defaultValue) const
const unsigned int & getFieldRow(void) const
std::map< std::string, ConfigurationTree > getChildrenMap(std::map< std::string, std::string > filterMap=std::map< std::string, std::string >(), bool onlyStatusTrue=false) const
std::string nodeDump(bool forcePrintout=false) const
used for debugging (when throwing exception)
const std::string & getValueName(void) const
const std::string & getValueAsString(bool returnLinkTableValue=false) const
const ConfigurationManager * getConfigurationManager(void) const
extracting information from node
const std::string & getChildLinkIndex(void) const
getChildLinkIndex
void print(const unsigned int &depth=-1, std::ostream &out=std::cout) const
bool isGroupIDNode(void) const
void getValue(T &value) const
const std::string & getDisconnectedTableName(void) const
getDisconnectedTableName
bool isValueBoolType(void) const
std::vector< std::pair< std::string, ConfigurationTree > > getChildren(std::map< std::string, std::string > filterMap=std::map< std::string, std::string >(), bool byPriority=false, bool onlyStatusTrue=false) const
std::vector< std::string > getFixedChoices(void) const
bool hasComment(void) const
hasComment
bool isLinkNode(void) const
const std::string & getDefaultValue(void) const
const time_t & getTableCreationTime(void) const
getTableCreationTime
std::string getParentLinkIndex(void) const
getParentLinkIndex
const std::string & getUIDAsString(void) const
bool status(void) const
same as isEnabled()
std::vector< ConfigurationTree::RecordField > getCommonFields(const std::vector< std::string > &recordList, const std::vector< std::string > &fieldAcceptList, const std::vector< std::string > &fieldRejectList, unsigned int depth=-1, bool autoSelectFilterFields=false) const
const unsigned int & getNodeRow(void) const
getNodeRow
std::set< std::string > getSetOfGroupIDs(void) const
bool isValueNode(void) const
const std::string & getFieldName(void) const
alias for getValueName
std::vector< std::vector< std::string > > getChildrenNamesByPriority(bool onlyStatusTrue=false) const
std::set< std::string > getUniqueValuesForField(const std::vector< std::string > &recordList, const std::string &fieldName, std::string *fieldGroupIDChildLinkIndex=0) const
const std::string & getValueType(void) const
bool passFilterMap(const std::string &childName, std::map< std::string, std::string > filterMap) const
~ConfigurationTree(void)
destructor
bool isGroupLinkNode(void) const
std::string getParentLinkID(void) const
getParentLinkID
const std::string & getFieldTableName(void) const
const unsigned int & getColumn(void) const
getColumn
const std::string & getDisconnectedLinkID(void) const
getDisconnectedLinkID
const std::string & getParentTableName(void) const
getParentTableName
bool isUIDLinkNode(void) const
const std::string & getParentRecordName(void) const
getParentRecordName
std::string getEscapedValue(void) const
friend std::ostream & operator<<(std::ostream &out, const ConfigurationTree &t)
make stream output easy
const TableViewColumnInfo & getColumnInfo(void) const
bool isDefaultValue(void) const
boolean info
std::vector< std::vector< std::pair< std::string, ConfigurationTree > > > getChildrenByPriority(std::map< std::string, std::string > filterMap=std::map< std::string, std::string >(), bool onlyStatusTrue=false) const
const std::string & getParentLinkColumnName(void) const
getParentLinkColumnName
T getValue(void) const
defined in included .icc source
const unsigned int & getFieldColumn(void) const
friend ConfigurationTree
so ConfigurationTree can access private
void print(std::ostream &out=std::cout) const
extracting information from a list of records
static std::string stackTrace(void)