Vuo  2.2.1
VuoCable.cc
Go to the documentation of this file.
1 
10 #include "VuoCable.hh"
11 #include "VuoPublishedPort.hh"
12 
16 VuoCable::VuoCable(VuoNode * fromNode, VuoPort * fromPort, VuoNode * toNode, VuoPort * toPort, bool addCableToPorts)
18 {
19  this->fromNode = fromNode;
20  this->fromPort = fromPort;
21  this->toNode = toNode;
22  this->toPort = toPort;
23 
24  if (addCableToPorts)
25  {
26  if (fromPort)
27  fromPort->addConnectedCable(this);
28 
29  if (toPort)
30  toPort->addConnectedCable(this);
31  }
32 }
33 
38 {
39  return fromNode;
40 }
41 
46 {
47  return fromPort;
48 }
49 
54 {
55  return toNode;
56 }
57 
62 {
63  return toPort;
64 }
65 
71 void VuoCable::setFrom(VuoNode *fromNode, VuoPort *fromPort)
72 {
73  if (this->fromPort)
74  {
75  this->fromPort->removeConnectedCable(this);
76  }
77 
78  if (fromPort)
79  {
80  fromPort->addConnectedCable(this);
81  }
82 
83  this->fromPort = fromPort;
84  this->fromNode = fromNode;
85 }
86 
92 void VuoCable::setTo(VuoNode *toNode, VuoPort *toPort)
93 {
94  if (this->toPort)
95  {
96  this->toPort->removeConnectedCable(this);
97  }
98 
99  if (toPort)
100  {
101  toPort->addConnectedCable(this);
102  }
103 
104  this->toPort = toPort;
105  this->toNode = toNode;
106 }
107 
112 {
114 }
115 
120 {
121  return dynamic_cast<VuoPublishedPort *>(fromPort);
122 }
123 
128 {
129  return dynamic_cast<VuoPublishedPort *>(toPort);
130 }