How would you model a USB cable using interfaces so that the cable itself is unidirectional(different jacks) but in theory I could connect the "output" side to the "input" side but not input to input.
e.g., I'm trying to model the following
* -> + -> * -> + etc...
but never have something like * -> * -> ... or + -> + -> ...
but each * and + is basically interchangeable. I just want to make sure *'s go through the -> processes before they are allowed to be used again.
The idea is pretty simple, outputs can be used as inputs BUT inputs can be used as outputs... but inputs and outputs are pretty much interchangable data wise(just a stream of data).
(it seems I have to use an adapter pattern but I'd like to somehow use the composite pattern so I don't have to explicitly adapt anything. I'd like it just to work plug and play and have the appropriate connection chosen)
e.g.,
interface data;
interface input : data;
interface output : data;
this allows inputs to go to inputs or outputs.