Merge branch 'development'
This commit is contained in:
commit
243d8783ce
@ -168,7 +168,21 @@ namespace Tree
|
||||
*
|
||||
* @param c - a shared_ptr to a BaseNode
|
||||
*/
|
||||
void addChild(const std::shared_ptr<Tree::BaseNode> &c) {c->setParent(shared_from_this()); children.push_back(c); }
|
||||
void addChild(const std::shared_ptr<Tree::BaseNode> &c) {
|
||||
if (c!=nullptr)
|
||||
{
|
||||
c->setParent(shared_from_this());
|
||||
children.push_back(c);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief prepends a child to the node which is already a shared_ptr
|
||||
*
|
||||
* @param c - a shared_ptr to a BaseNode
|
||||
*/
|
||||
void prependChild(const std::shared_ptr<Tree::BaseNode> &c) {c->setParent(shared_from_this()); children.push_front(c); }
|
||||
|
||||
/**
|
||||
* @brief adds a container of nodes to the list of children
|
||||
@ -180,6 +194,15 @@ namespace Tree
|
||||
void addChildren(Iter begin, Iter end) { std::copy( begin, end, std::back_inserter( children ) );}
|
||||
|
||||
|
||||
/**
|
||||
* @brief prepends a container of nodes to the list of children
|
||||
*
|
||||
* @param begin - iterator to the beginning of the container of objects of type std::shared_ptr<Tree::BaseNode>
|
||||
* @param end - iterator to the end of the container of objects of type std::shared_ptr<Tree::BaseNode>
|
||||
*/
|
||||
template <typename Iter>
|
||||
void prependChildren(Iter begin, Iter end) { std::copy( begin, end, std::front_inserter( children ) );}
|
||||
|
||||
/**
|
||||
* @brief finds the next node in the tree of a given type
|
||||
*
|
||||
@ -202,12 +225,25 @@ namespace Tree
|
||||
/**
|
||||
* @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>
|
||||
*/
|
||||
template <typename Container>
|
||||
void findAllBase(const std::string &base, Container &c);
|
||||
template <class Container>
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user