1function isReplacement = addNode(self, node)
4% Copyright (c) 2012-2026, Imperial College London
8hasSameName = cellfun(@(x) strcmp(x.name,node.name), {self.nodes{1:end}});
11 oldNode = self.nodes{find(hasSameName)}; %#ok<FNDSB>
12 node.index = oldNode.index;
13 self.nodes{oldNode.index,1} = node;
14 if isa(node,
'Station')
15 self.stations{oldNode.stationIndex,1} = node;
16 node.stationIndex = oldNode.stationIndex;
18 self.setUsedLangFeature(
class(node)); % station type
19 self.setUsedLangFeature(
class(node.input)); % station type
20 self.setUsedLangFeature(
class(node.server)); % station type
21 self.setUsedLangFeature(
class(node.output)); % station type
24 line_error(mfilename,
'A node with an identical name already exists.');
28self.nodes{end+1,1} = node;
29node.index = length(self.nodes);
31 self.stations{end+1,1} = node;
32 node.stationIndex = length(self.stations);
34self.setUsedLangFeature(
class(node)); % station type
35self.setUsedLangFeature(
class(node.input)); % station type
36self.setUsedLangFeature(
class(node.server)); % station type
37self.setUsedLangFeature(
class(node.output)); % station type