YARP
Yet Another Robot Platform
node.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2020 Istituto Italiano di Tecnologia (IIT)
3  * All rights reserved.
4  *
5  * This software may be modified and distributed under the terms of the
6  * BSD-3-Clause license. See the accompanying LICENSE file for details.
7  */
8 
9 #include <yarp/manager/node.h>
10 
11 
12 using namespace yarp::manager;
13 
18 bool Node::addSuc(Node* node, float weight, bool _virtual)
19 {
20  __CHECK_NULLPTR(node);
21 
22  if(!hasSuc(node))
23  {
24  Link ln(node, weight, _virtual);
25  sucessors.push_back(ln);
26  }
27  return true;
28 }
29 
30 
31 bool Node::removeSuc(Node* node)
32 {
33  __CHECK_NULLPTR(node);
34 
35  auto it = findSuc(node);
36  if(it != sucessors.end())
37  sucessors.erase(it);
38  return true;
39 }
40 
41 
43 {
44  sucessors.clear();
45 }
46 
47 
48 
49 bool Node::hasSuc(Node* node)
50 {
51  auto it = findSuc(node);
52  if(it == sucessors.end())
53  return false;
54  return true;
55 }
56 
57 
58 
59 LinkIterator Node::findSuc(Node* node)
60 {
61  LinkIterator itr;
62  for(itr=sucessors.begin(); itr<sucessors.end(); itr++)
63  if ((*itr).to() == node)
64  return itr;
65  return sucessors.end();
66 }
yarp::manager
Definition: application.h:24
yarp::manager::Node::removeAllSuc
void removeAllSuc()
Definition: node.cpp:42
node.h
yarp::manager::Node
a Node of a Graph
Definition: node.h:68
yarp::manager::Node::addSuc
bool addSuc(Node *node, float weight, bool _virtual=false)
class Node
Definition: node.cpp:18
__CHECK_NULLPTR
#define __CHECK_NULLPTR(_ptr)
Definition: ymm-types.h:83
yarp::manager::LinkIterator
std::vector< Link >::iterator LinkIterator
Definition: node.h:26
yarp::manager::Node::removeSuc
bool removeSuc(Node *node)
Definition: node.cpp:31
yarp::manager::Node::hasSuc
bool hasSuc(Node *node)
Definition: node.cpp:49