Skip to content

Peer-to-peer port connector

Etienne Lac requested to merge port-class-connector into master

Description

Auto-detection of class-bound connectors (if any) during peer-to-peer port connections.

Conditions are:

  • Both ports are of the same type.
  • There exists an inner class Connector in the port class.
  • Inner connector class is derived from BaseConnector.

Example

from cosapp.base import Port, BaseConnector

class MyPort(Port): 
    """Port class with specific peer-to-peer connector"""
    def setup(self):
        self.add_variable('x', 0.0)
        # and son on

    class Connector(BaseConnector):
        """Peer-to-peer connector"""
        def transfer(self):
            # Specify how transfer works for that particular port type

In the example above, all connections involving two instances of MyPort will use MyPort.Connector.

Side changes

A minor bug concerning custom connector update has been fixed. Incidentally, BaseConnector.mapping has been made immutable.

Edited by Etienne Lac

Merge request reports