24 NodeMeta nodeMetaUnion(
const std::vector<ParaMeta>& base,
const NodeMeta& other)
26 return {other.className, other.tooltip,
algo::concat(base, other.paraMeta)};
29 INode::INode(
const NodeMeta& meta,
const std::vector<double>& PValues)
31 m_NP(meta.paraMeta.size())
34 setName(meta.className);
35 parameterPool()->clear();
36 for (
size_t i = 0; i < m_NP; ++i) {
38 const ParaMeta& pm = meta.paraMeta[i];
39 auto& reg = registerParameter(pm.name, &m_P[i]);
41 if (pm.vMin == -INF) {
42 ASSERT(pm.vMax == +INF);
44 }
else if (pm.vMax == +INF) {
48 reg.setLimited(pm.vMin, pm.vMax);
55 return NodeUtils::nodeToString(*
this);
58 void INode::registerChild(
INode* node)
61 node->setParent(
this);
69 void INode::setParent(
const INode* newParent)
74 const INode* INode::parent()
const
79 INode* INode::parent()
81 return const_cast<INode*
>(m_parent);
86 if (node->parent() !=
this)
89 int result(-1), count(0);
93 throw std::runtime_error(
"INode::copyNumber() -> Error. Nullptr as child.");
98 if (child->getName() == node->getName())
102 return count > 1 ? result : -1;
107 std::string result = getName();
111 result = result + std::to_string(index);
122 while (!it.isDone()) {
123 const INode* child = it.getCurrent();
124 const std::string path = NodeUtils::nodePath(*child, this->parent()) +
"/";
129 return result.release();
Defines and implements namespace algo with some algorithms.
Defines class IterationStrategy and children.
Defines classes IteratorState, IteratorMemento and NodeIterator.
Defines collection of utility functions for INode.
Defines class ParameterPool.
Defines class RealParameter.
Base class for tree-like structures containing parameterized objects.
virtual std::string treeToString() const
Returns multiline string representing tree structure below the node.
std::string displayName() const
Returns display name, composed from the name of node and it's copy number.
virtual std::vector< const INode * > getChildren() const
Returns a vector of children (const).
ParameterPool * createParameterTree() const
Creates new parameter pool, with all local parameters and those of its children.
int copyNumber(const INode *node) const
Returns copyNumber of child, which takes into account existence of children with same name.
ParameterPool * parameterPool() const
Returns pointer to the parameter pool.
Iterator through INode tree of objects.
Container with parameters for IParameterized object.
void copyToExternalPool(const std::string &prefix, ParameterPool *other_pool) const
Copies parameters of given pool to other pool, prepeding prefix to the parameter names.
std::vector< T > concat(const std::vector< T > &v1, const std::vector< T > &v2)
Returns the concatenation of two std::vectors.