ADD: method to find all nodes of specific type
This commit is contained in:
parent
243d8783ce
commit
b7b350a9e1
@ -216,11 +216,25 @@ namespace Tree
|
||||
/**
|
||||
* @brief finds all nodes of a given type
|
||||
*
|
||||
* @param type - the type of the node as a string
|
||||
* @param t - the 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>
|
||||
*/
|
||||
template <typename Container>
|
||||
void findAll(const std::string &type, Container &c);
|
||||
void findAll(const std::string &t, Container &c)
|
||||
{
|
||||
std::list<std::shared_ptr<Tree::BaseNode>>::iterator it;
|
||||
|
||||
if (type() == t)
|
||||
{
|
||||
c.push_back(shared_from_this());
|
||||
}
|
||||
|
||||
for(it = children.begin(); it != children.end(); ++it)
|
||||
{
|
||||
(*it)->findAll(t,c);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief finds all nodes of a given base
|
||||
|
Loading…
Reference in New Issue
Block a user