fractalide / fractalide-oz

Proof of concept
GNU Affero General Public License v3.0
13 stars 4 forks source link

make addinArrayPorts dynamic #45

Closed dmichiels closed 10 years ago

dmichiels commented 10 years ago

To add a selection in a virtual port, for the moment we have to send the action "addinArrayPort" on the component. Then, it's possible to link output port to this selection. So, to do :

foo() output -> input#selection bar()

The steps are :

{Bar addinArrayPort(input selection)}
{Foo bind(output Bar input#selection)}

The idea is to make this more dynamic. When the sender component (ie : foo()) will connect to the array port, it will send the action "connect(input selection)" to bar(), and when it will unbound, it will send the action disconnect(input selection). It can be done automatically in the bind and unBound actions. The recevier component will keep a counter for each "sub-port". When it receive a connect action, it increment the counter, and a disconnect action it decrement it. If the counter go from 0 to 1, the sub-port is added. If the counter go from 1 to 0, the sub-port is deleted.

So, the connect/disconnect events will be hidden for the user, he will just do

{Foo bind(output Bar input#selection)}

And the receiver component will have the selection only when component are bounded to it.