28 std::string s_indent(
int depth)
30 const int multiplier = 4;
31 return std::string(multiplier * depth,
'.');
35 std::string poolToString(
const INode& node)
37 std::ostringstream result;
45 for (
auto par : pars) {
46 result <<
"'" << par->getName() <<
"':" << par->value();
48 if (index != pars.size())
57 std::string nodeString(
const INode& node,
int depth)
59 std::ostringstream result;
60 result << s_indent(depth) << node.
displayName() << poolToString(node) <<
"\n";
72 std::vector<std::tuple<const INode*, int, const INode*>> result;
73 result.push_back({node, level,
nullptr});
75 for (
const auto& [subchild, sublevel, subparent] :
progenyPlus(child, level + 1))
76 result.push_back({subchild, sublevel, child});
83 std::ostringstream result;
84 for (
const auto& [child, depth, parent] :
progenyPlus(node))
85 result << nodeString(*child, depth);
91 std::vector<std::string> pathElements;
92 const INode* current = node;
93 while (current && current != root) {
95 pathElements.push_back(
"/");
96 current = current->
parent();
98 if (root !=
nullptr && current != root)
99 throw std::runtime_error(
"NodeUtils::nodePath() -> Error. Node doesn't "
100 "belong to root's branch");
101 std::reverse(pathElements.begin(), pathElements.end());
102 std::ostringstream result;
103 std::copy(pathElements.begin(), pathElements.end(), std::ostream_iterator<std::string>(result));
Defines the macro ASSERT.
Defines collection of utility functions for INode.
Defines class ParameterPool.
Defines class RealParameter.
Base class for tree-like structures containing parameterized objects.
std::string displayName() const
Returns display name, composed from the name of node and it's copy number.
const INode * parent() const
virtual std::vector< const INode * > getChildren() const
Returns a vector of children.
ParameterPool * parameterPool() const
Returns pointer to the parameter pool.
const std::vector< RealParameter * > parameters() const
Returns full vector of parameters.
std::vector< std::tuple< const INode *, int, const INode * > > progenyPlus(const INode *node, int level=0)
Returns a vector of triples (descendant, depth, parent)
std::string nodeToString(const INode *node)
Returns multiline string representing tree structure starting from given node.
std::string nodePath(const INode *node, const INode *root=nullptr)
Returns path composed of node's displayName, with respect to root node.