11standard library package Interfaces {
2- doc
3- /*
4- * This package defines the base types for interfaces and related structural elements in the SysML language.
5- */
6-
7- private import Connections::Connection;
8- private import Connections::connections;
9- private import Connections::BinaryConnection;
10- private import Connections::binaryConnections;
11- private import Ports::Port;
12-
13- abstract interface def Interface :> Connection {
14- doc
15- /*
16- * Interface is the most general class of links between Ports on Parts
17- * within some containing structure. Interface is the base type of all
18- * InterfaceDefinitions.
19- */
20- }
21-
22- abstract interface def BinaryInterface :> Interface, BinaryConnection {
23- doc
24- /*
25- * BinaryInterface is the most general class of links between two Ports
26- * on Parts within some containing structure. BinaryInterface is the base
27- * type of all binary InterfaceDefinitions with exactly two ends.
28- */
29-
30- end source: Port :>> BinaryConnection::source;
31- end target: Port :>> BinaryConnection::target;
32- }
33-
34- abstract interface interfaces: Interface[0..*] nonunique :> connections {
35- doc
36- /*
37- * interfaces is the base feature of all InterfaceUsages.
38- */
39- }
40-
41- abstract interface binaryInterfaces: BinaryInterface[0..*] nonunique :> interfaces, binaryConnections {
42- doc
43- /*
44- * interfaces is the base feature of all binary InterfaceUsages.
45- */
46- }
47-
2+ doc
3+ /*
4+ * This package defines the base types for interfaces and related structural elements in the SysML language.
5+ */
6+
7+ private import Connections::Connection;
8+ private import Connections::connections;
9+ private import Connections::BinaryConnection;
10+ private import Connections::binaryConnections;
11+ private import Ports::Port;
12+
13+ private import ScalarValues::Natural;
14+ private import SequenceFunctions::size;
15+ private import SequenceFunctions::excludingAt;
16+ private import ControlFunctions::selectOne;
17+
18+ private import SequenceFunctions::notEmpty;
19+
20+ private calc def excludingOnce {
21+ doc
22+ /*
23+ * Return a sequence that is the same as the input sequence, but with a single
24+ * instance of a given value removed. The given value must be in the input sequence.
25+ */
26+ in seq[1..*] nonunique ordered;
27+ in value[1] :> seq;
28+
29+ private attribute position : Natural[1] = (1..size(seq))->selectOne{in i; seq#(i) == value};
30+ seq->excludingAt(position)
31+ }
32+
33+ abstract interface def Interface :> Connection {
34+ doc
35+ /*
36+ * Interface is the most general class of links between Ports on Parts
37+ * within some containing structure. Interface is the base type of all
38+ * InterfaceDefinitions.
39+ *
40+ * Transfers outgoing from any one of the participant Ports of an Interface
41+ * may be targeted to one of the other participant Ports (depending on any
42+ * other Interfaces in which the Port is also participating).
43+ */
44+
45+ ref port :>> participant : Port [2..*] nonunique ordered {
46+ doc
47+ /*
48+ * The participants of an Interface must be Ports. The interfacingPorts of
49+ * each participant Port include all the other participants in the Interface.
50+ */
51+
52+ protected ref thisParticipant :>> self;
53+ protected ref otherParticipants : Port [1..*] nonunique :> interfacingPorts
54+ default participant->excludingOnce(thisParticipant);
55+ }
56+ }
57+
58+ abstract interface def BinaryInterface :> Interface, BinaryConnection {
59+ doc
60+ /*
61+ * BinaryInterface is the most general class of links between two Ports
62+ * on Parts within some containing structure. BinaryInterface is the base
63+ * type of all binary InterfaceDefinitions which have exactly two ends.
64+ *
65+ * Transfers outgoing from each participant Port of a BinaryInterface may be
66+ * targeted to the other participant Port (depending on any other Interfaces
67+ * in which the Port is also participating).
68+ */
69+
70+ ref port :>> Interface::participant, BinaryConnection::participant[2] nonunique ordered;
71+
72+ end port source: Port :>> BinaryConnection::source;
73+ end port target: Port :>> BinaryConnection::target;
74+ }
75+
76+ abstract interface interfaces: Interface[0..*] nonunique :> connections {
77+ doc
78+ /*
79+ * interfaces is the base feature of all InterfaceUsages.
80+ */
81+ }
82+
83+ abstract interface binaryInterfaces: BinaryInterface[0..*] nonunique :> interfaces, binaryConnections {
84+ doc
85+ /*
86+ * interfaces is the base feature of all binary InterfaceUsages.
87+ */
88+ }
4889}
0 commit comments