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