F
Federico Degrandis
Hello everyone!
I should implement a kind of fluent interface I'm just a little perplexed
about how to do:
GetBus (Bus interface)
.. GetSensor (NumSens)
.. GetComponent (Name)
.. GetDimension (Name)
.. ApplyFilter (filtername)
.. ApplyFilter (filtername)
.. ApplyFeatures (FeatureName)
.. GetResults ()
These are basically methods that the user can call and have to be invoked
in this order (the ApplyFilter can called several times)
GetBus returns an instance of Bus, GetSensor instance of Sensor
GetComponent instance of Component and so on.
At first I thought to put the method GetBus inside a class
FluentFlow, GetSensor inside the Bus class and GetComponent in Sensor class.
The problem is that at the end GetResults must interact with the instance of
Bus (in order to
run some threads).
The solutions that came to my mind are:
- Use some kind of message broker where basically the class that
contains the method getResults () tells the instance of Bus to run the
thread
- Include all methods in the FluentFlow class (the problem is that they
only be called in that order)
- Create classes XXXFluentInterface managed by the FluentFlow class in order
to
handle even the order of the methods (GetBus will return BusFluentInterface
that will have a method GetSensor returning SensorFluentInterface)
Any idea?
Cheers
Federico
I should implement a kind of fluent interface I'm just a little perplexed
about how to do:
GetBus (Bus interface)
.. GetSensor (NumSens)
.. GetComponent (Name)
.. GetDimension (Name)
.. ApplyFilter (filtername)
.. ApplyFilter (filtername)
.. ApplyFeatures (FeatureName)
.. GetResults ()
These are basically methods that the user can call and have to be invoked
in this order (the ApplyFilter can called several times)
GetBus returns an instance of Bus, GetSensor instance of Sensor
GetComponent instance of Component and so on.
At first I thought to put the method GetBus inside a class
FluentFlow, GetSensor inside the Bus class and GetComponent in Sensor class.
The problem is that at the end GetResults must interact with the instance of
Bus (in order to
run some threads).
The solutions that came to my mind are:
- Use some kind of message broker where basically the class that
contains the method getResults () tells the instance of Bus to run the
thread
- Include all methods in the FluentFlow class (the problem is that they
only be called in that order)
- Create classes XXXFluentInterface managed by the FluentFlow class in order
to
handle even the order of the methods (GetBus will return BusFluentInterface
that will have a method GetSensor returning SensorFluentInterface)
Any idea?
Cheers
Federico