When you want to add a new middleware to MORSE, you need first to create a ‘datastream’ manager. Basically, its role is to make the link between components and datastream handler. From an implementation point of view, it must be a subclass or morse.core.datastream.DatastreamManager. In addition to classic method __init__ and __del__, you may want to override the method morse.core.datastream.DatastreamManager.register_component() which really includes the logic of registration. However, in general, the default implementation is enough. You can find some example of overloading in morse.middleware.socket_datastream.Socket.register_component() where we store additional informations for the sake of different services.
If you need to run some general datastream/middleware code once by simulation turn, you can also override the morse.core.datastream.DatastreamManager.action`() method.
To match the MORSE organisation, we expect the following file hierarchy:
To facilitate the use of your middleware, you can add some entries in morse.builder.data. In particular, you need to add an entry for your datastream manager in morse.builder.data.MORSE_DATASTREAM_MODULE, and add the necessary entries for the different datastream handler in morse.builder.data.MORSE_DATASTREAM_DICT.