Pergunta

I am searching for a good feedback pattern - concept, perhaps the question could be asked differently, let me know please. Will try to describe it.

Basically what I am looking for is the right way of making a good feedback concept. For example Trigger object triggers a function from other Target object for which Triggerobject has some kind of expectations (maybe more then one parameter). This triggered call can also make more function calls from different kind of objects, so they would all need some kind of access to give there response to Trigger object with result parameters which Trigger object would then compare with expected ones and react upon receiving them.

I need a good concept since it must be possible to spread the functionality over the whole system. If it matters, Source code is written in C++ Qt.

Foi útil?

Solução

I would suggest Observer pattern.

Basically there is an Observable objects which maintains a set of Observers which are registered to that object to listen on some action. When Observable object make such an action, Observers are notified that an action was made and can react on it.

So in your case the Trigger would be an Observable object and Target objects would be Observers. Target objects can be registered on Trigger object and can react (make feedback) on Trigger action.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top