1 | <?php |
||
15 | final class Socket implements SocketInterface |
||
16 | { |
||
17 | /** |
||
18 | * The id of the socket. |
||
19 | * |
||
20 | * @var string |
||
21 | */ |
||
22 | private $id; |
||
23 | |||
24 | /** |
||
25 | * Whether or not the socket is enabled. |
||
26 | * |
||
27 | * @var bool |
||
28 | */ |
||
29 | private $enabled; |
||
30 | |||
31 | /** |
||
32 | * The name of the socket. |
||
33 | * |
||
34 | * @var string |
||
35 | */ |
||
36 | private $name; |
||
37 | |||
38 | /** |
||
39 | * The nodes that are connected to this socket. |
||
40 | * |
||
41 | * @var NodeInterface[] |
||
42 | */ |
||
43 | private $nodes; |
||
44 | |||
45 | /** |
||
46 | * Initializes a new instance of this class. |
||
47 | * |
||
48 | * @param string $name The name of the socket. |
||
49 | */ |
||
50 | public function __construct($name) |
||
56 | |||
57 | /** |
||
58 | * Activates this socket. |
||
59 | */ |
||
60 | public function activate() |
||
68 | |||
69 | /** |
||
70 | * Adds a node to the connection list. |
||
71 | * |
||
72 | * @param NodeInterface $node The node to add. |
||
73 | */ |
||
74 | public function addNode(NodeInterface $node) |
||
78 | |||
79 | /** |
||
80 | * Removes all the connections from this socket. |
||
81 | */ |
||
82 | public function clearNodes() |
||
86 | |||
87 | /** |
||
88 | * Gets the id of the node. |
||
89 | * |
||
90 | * @return string |
||
91 | */ |
||
92 | public function getId() |
||
99 | |||
100 | /** |
||
101 | * Gets the name of the socket. |
||
102 | * |
||
103 | * @return string |
||
104 | */ |
||
105 | public function getName() |
||
109 | |||
110 | /** |
||
111 | * Gets the node at the given index. |
||
112 | * |
||
113 | * @param int $index The index of the node to get. |
||
114 | * @return NodeInterface |
||
115 | */ |
||
116 | public function getNode($index) |
||
124 | |||
125 | /** |
||
126 | * Gets the amount of nodes that this socket has. |
||
127 | * |
||
128 | * @return int |
||
129 | */ |
||
130 | public function getNodeCount() |
||
134 | |||
135 | /** |
||
136 | * Gets a list with all the connected nodes. |
||
137 | * |
||
138 | * @return NodeInterface[] |
||
139 | */ |
||
140 | public function getNodes() |
||
144 | |||
145 | /** |
||
146 | * Checks if there are nodes bound to this socket. |
||
147 | * |
||
148 | * @return bool |
||
149 | */ |
||
150 | public function hasNodes() |
||
154 | |||
155 | /** |
||
156 | * Checks if the socket is enabled. |
||
157 | * |
||
158 | * @return bool |
||
159 | */ |
||
160 | public function isEnabled() |
||
164 | |||
165 | /** |
||
166 | * Removes the given node from the connections list. |
||
167 | * |
||
168 | * @param NodeInterface $node The node to remove. |
||
169 | */ |
||
170 | public function removeNode(NodeInterface $node) |
||
184 | |||
185 | /** |
||
186 | * Enables or disables the socket. |
||
187 | * |
||
188 | * @param bool $enabled The flag to set. |
||
189 | * @return Socket |
||
190 | */ |
||
191 | public function setEnabled($enabled) |
||
195 | |||
196 | /** |
||
197 | * Sets the node on the given index. |
||
198 | * |
||
199 | * @param int $index The index in the list to set the node for. |
||
200 | * @param NodeInterface $node The node to set. |
||
201 | */ |
||
202 | public function setNode($index, NodeInterface $node) |
||
206 | } |
||
207 |