131 Node(
const std::string& name) :
133 name_(new std::string(name)),
144 Node(
int id,
const std::string& name) :
146 name_(new std::string(name)),
213 std::vector<int> sonsId(
sons_.size());
214 for (
size_t i = 0; i <
sons_.size(); i++)
216 sonsId[i] =
sons_[i]->getId();
237 if (!
hasName())
throw NodePException(
"Node::getName: no name associated to this node.",
this);
249 name_ =
new std::string(name);
285 throw NodePException(
"Node::getDistanceToFather: Node has no distance.",
this);
359 if (find(node->sons_.begin(), node->sons_.end(),
this) == node->sons_.end())
360 node->
sons_.push_back(
this);
362 std::cerr <<
"DEVEL warning: Node::setFather. Son node already registered! No pb here, but could be a bug in your implementation..." << std::endl;
413 std::cerr <<
"DEVEL warning: Node::addSon. Son node already registered! No pb here, but could be a bug in your implementation..." << std::endl;
415 node->father_ =
this;
423 sons_.push_back(node);
425 throw NodePException(
"Node::addSon. Trying to add a node which is already present.");
426 node->father_ =
this;
433 if (pos >=
sons_.size())
435 std::vector<Node*>::iterator search = find(
sons_.begin(),
sons_.end(), node);
436 if (search ==
sons_.end() || search ==
sons_.begin() + pos)
439 throw NodePException(
"Node::setSon. Trying to set a node which is already present.");
440 node->father_ =
this;
445 if (pos >=
sons_.size())
457 for (
size_t i = 0; i <
sons_.size(); i++)
459 if (
sons_[i] == node)
462 node->removeFather();
471 while (
sons_.size() != 0)
687 virtual
bool operator==(const
Node& node)
const {
return id_ == node.id_; }