ADD: method to search for all nodes with a given base

This commit is contained in:
Dominik Meyer 2019-04-10 09:53:08 +02:00
parent cf58516daf
commit 6d55169a5f
No known key found for this signature in database
GPG Key ID: B4C312B600606B64

View File

@ -225,12 +225,25 @@ namespace Tree
/** /**
* @brief finds all nodes of a given base * @brief finds all nodes of a given base
* *
* @param base - the base type of the node as a string * @param b - the base type of the node as a string
* @param c - a container for holding all found nodes, has to be holding objects of type std::shared_ptr<Tree::BaseNode> * @param c - a container for holding all found nodes, has to be holding objects of type std::shared_ptr<Tree::BaseNode>
*/ */
template <typename Container> template <class Container>
void findAllBase(const std::string &base, Container &c); void findAllBase(const std::string &b, Container &c)
{
std::list<std::shared_ptr<Tree::BaseNode>>::iterator it;
if (base() == b)
{
c.push_back(shared_from_this());
}
for(it = children.begin(); it != children.end(); ++it)
{
(*it)->findAllBase(b,c);
}
}
/** /**
* @brief checks if the given node is a direct child of this node * @brief checks if the given node is a direct child of this node