5 #ifndef BPP_PHYL_LEGACY_TREE_AWARENODE_H
6 #define BPP_PHYL_LEGACY_TREE_AWARENODE_H
13 #include "../../Tree/TreeExceptions.h"
106 template<
class N,
class E,
class I>
132 std::vector<unsigned int> sonsId(
sons_.size());
133 for (
size_t i = 0; i <
sons_.size(); i++)
135 sonsId[i] =
sons_[i]->getId();
256 sons_.insert(
sons_.begin() +
static_cast<ptrdiff_t
>(pos), node);
258 std::cerr <<
"DEVEL warning: AwareNode::addSon. Son node already registered! No pb here, but could be a bug in your implementation..." << std::endl;
266 sons_.push_back(node);
268 throw Exception(
"AwareNode::addSon. Trying to add a node which is already present.");
275 if (pos >=
sons_.size())
277 std::vector<AwareNode*>::iterator search = find(
sons_.begin(),
sons_.end(), node);
278 if (search ==
sons_.end() || search ==
sons_.begin() +
static_cast<ptrdiff_t
>(pos))
281 throw Exception(
"AwareNode::setSon. Trying to set a node which is already present.");
286 if (pos >=
sons_.size())
288 sons_.erase(
sons_.begin() +
static_cast<ptrdiff_t
>(pos));
295 for (
size_t i = 0; i <
sons_.size(); i++)
297 if (
sons_[i] == node)
299 sons_.erase(
sons_.begin() +
static_cast<ptrdiff_t
>(i));
311 virtual void swap(
size_t branch1,
size_t branch2);
334 template<
class N,
class E,
class I>
339 std::shared_ptr<N> thisN = tree->
getNode(index);
343 std::vector< std::shared_ptr<N>> vS = tree->
getSons(thisN);
345 for (
typename std::vector<std::shared_ptr<N>>::iterator it = vS.begin(); it != vS.end(); it++)
virtual std::shared_ptr< N > getNode(NodeIndex nodeIndex) const=0
std::vector< std::shared_ptr< N > > getSons(const std::shared_ptr< N > node) const
bool hasFather(const std::shared_ptr< N > nodeObject) const
std::shared_ptr< N > getFatherOfNode(const std::shared_ptr< N > nodeObject) const
A node class aware of its neighbours.
AwareNode()
Build a new void Node object.
AwareNode & operator=(const AwareNode &node)
Assignation operator.
virtual bool hasNoSon() const
virtual size_t getNumberOfSons() const
virtual size_t getSonPosition(const AwareNode *son) const
virtual std::vector< unsigned int > getSonsId() const
virtual std::vector< AwareNode * > & getSons()
AwareNode(unsigned int id)
Build a new Node with specified id.
virtual bool hasFather() const
Tell if this node has a father node.
virtual void setId(unsigned int id)
Set this node's id.
virtual AwareNode * getFather()
Get the father of this node is there is one.
const AwareNode * operator[](int i) const
virtual const AwareNode * getFather() const
Get the father of this node is there is one.
virtual const AwareNode * getSon(size_t pos) const
virtual void removeSon(size_t pos)
virtual void setSon(size_t pos, AwareNode *node)
virtual void removeSons()
AwareNode * clone() const
virtual void swap(size_t branch1, size_t branch2)
virtual void removeSon(AwareNode *node)
virtual void addSon(AwareNode *node)
virtual void removeFather()
Remove the father of this node.
std::vector< AwareNode * > sons_
virtual unsigned int getId() const
Get the node's id.
virtual void setDistanceToFather(double distance)
Set or update the distance toward the father node.
AwareNode * operator[](int i)
virtual void setFather(AwareNode *node)
Set the father node of this node.
void updateTree(AssociationTreeGraphImplObserver< N, E, I > *tree, unsigned int index)
update information from TreeObserver
virtual void addSon(size_t pos, AwareNode *node)
virtual AwareNode * getSon(size_t pos)
virtual double getDistanceToFather() const
Get the distance to the father node is there is one, otherwise throw a NodeException.
std::string toString(T t)
Defines the basic types of data flow nodes.