@Override public <P extends PortType> Channel<P> connect(PortCore<P> positivePort, PortCore<P> negativePort) { UniDirectionalChannel<P> c = new UniDirectionalChannel(positivePort, negativePort, direction); positivePort.addChannel(c); negativePort.addChannel(c); return c; }
@Override public <P extends PortType> Channel<P> connect(PortCore<P> positivePort, PortCore<P> negativePort) { BiDirectionalChannel<P> c = new BiDirectionalChannel(positivePort, negativePort); positivePort.addChannel(c); negativePort.addChannel(c); return c; }
@Override public <P extends PortType> Channel<P> connect(PortCore<P> positivePort, PortCore<P> negativePort, ChannelSelector selector) { BiDirectionalChannel<P> c = new BiDirectionalChannel(positivePort, negativePort); Class<? extends KompicsEvent> eventType = selector.getEventType(); if (selector.isPositive()) { if (!c.portType.hasPositive(eventType)) { throw new RuntimeException("Port type " + c.portType + " has no positive " + eventType); } positivePort.addChannel(c, selector); negativePort.addChannel(c); } else { if (!c.portType.hasNegative(eventType)) { throw new RuntimeException("Port type " + c.portType + " has no negative " + eventType); } positivePort.addChannel(c); negativePort.addChannel(c, selector); } return c; }
@Override public <P extends PortType> Channel<P> connect(PortCore<P> positivePort, PortCore<P> negativePort, ChannelSelector selector) { UniDirectionalChannel<P> c = new UniDirectionalChannel(positivePort, negativePort, direction); Class<? extends KompicsEvent> eventType = selector.getEventType(); if (selector.isPositive()) { if (!c.portType.hasPositive(eventType)) { throw new RuntimeException("Port type " + c.portType + " has no positive " + eventType); } if (this.direction != Direction.TO_NEGATIVE) { throw new RuntimeException("Selectors have to be added to the sending side of a one-way channel!"); } positivePort.addChannel(c, selector); negativePort.addChannel(c); } else { if (!c.portType.hasNegative(eventType)) { throw new RuntimeException("Port type " + c.portType + " has no negative " + eventType); } if (this.direction != Direction.TO_POSITIVE) { throw new RuntimeException("Selectors have to be added to the sending side of a one-way channel!"); } positivePort.addChannel(c); negativePort.addChannel(c, selector); } return c; }