engine question
| Mon, 2005-02-14 05:37 | |
|
In light of some document discoveries, I reduced my question to the following:
If my engine keeps updating data to be displayed by AppUi, how do I let the AppUi know that the data it is displaying is not valid any more. In other words, what is the best way to implement a refresh mechanism for the AppUi so that at a given rate, it calls a bunch of engine API to update its views? CActive? or have the engine periodically call a callback function inside AppUi to tell it to refresh? I appreciate any ideas, comments... Thanks! |
|






Forum posts: 76
If my engine keeps updating data to be displayed by AppUi, how do I let the AppUi know that the data it is displaying is not valid any more. In other words, what is the best way to implement a refresh mechanism for the AppUi so that at a given rate, it calls a bunch of engine API to update its views? CActive? or have the engine periodically call a callback function inside AppUi to tell it to refresh?
I appreciate any ideas, comments...
Thanks!
What you're describing seems to be polling, the AppUi periodically checking the engine to see if anything has changed and updating the display if it has. This is not the best solution to the problem.
The normal way to tackle these problems is to have the engine notify the AppUi whenever any data that would cause display updates changes. This would commonly be accomplished through the Subscriber/Publisher pattern of behaviour.
You would define a pure virtual interface mixin class as an interface that an observer should implement, for e.g.
{
virtual void ChangeNotifyL() = 0;
};
The AppUi (or view or CCoeControl display object) would inherit from the interface and implement the change notification function which would query the engine's data and order a redraw of the interface.
The engine will contain functions to add and remove an MEngineObserver derived object to the engines list of observers to notify when the engines internal state changes. (The list of observers might just be one observer with a simple SetObserver() function).
Now, each time something of interest changes in the engine, the observers ChangeNotifyL() function will be called and the UI updated to reflect the changes in the engines state.
This is more efficient than continuously polling the engine to assess state changes. This method is also UI independent. Assuming the engine is platform independent, your app can easily be ported between different UIs (Series60/UIQ) by simply getting the relevant interface object to inherit from the same MEngineObserver interface defined above.
Hope that helps!