#include <CallBack.h>
Inheritance diagram for RedirectCallback< CB >:
Public Member Functions | |
virtual CB * | operator-> () |
RedirectCallback () | |
virtual | ~RedirectCallback () |
Protected Member Functions | |
CB * | redirectTo (CB *to_r) |
CB * | redirectTo (CB &to_r) |
Private Member Functions | |
CB * | self () |
Private Attributes | |
CB * | _redirectTo |
The common way we define a callback interface:
struct InstCallback : public RedirectCallback<InstCallback> { virtual void start() = 0; virtual void progress() = 0; virtual void stop() = 0; };
void InstCallback::start() { ... } void InstCallback::progress() { ... } void InstCallback::stop() { ... }The callback class defines an abstract interface of all functions the sender of the callback may invoke. A default implementation for every function is required, and must provide reasonable defaults for retrurn values and reference arguments passed back to the sender.In other terms, the default implementaion is invoked if there is currently no recipient for a callback. The same way a recipient may invoke the default implementation, if it's got no idea what else to do.
The inherited RedirectCallback defines operator-> which per default refers to this, but may be redirected to some other instance. The redirectTo method used to set or clear any redirection is protected per default. A callback recipient (derived from the inteface class) may adjust its scope as desired, or even overload the operator->.
NOTE: Assume there is an instance
InstCallback cbvar
. There's a sigificant difference betweencbvar.start()
andcbvar->start()
. Invokation via '->' follows any redirection applied, and invokes start() on the final recipient. This is, what a calback sender should do. Invokation via ..' always addresses the current instance ignoring any redirection.See: Report and Report::Send
Constructor & Destructor Documentation
|
Constructor. |
|
Destructor. |
|
Forward access if redirected, otherwise refer to this. |
|
Set redirection to another CB instance.
|
|
Set redirection to another CB instance. Clear redirection if NULL.
|
|
Expecting to be inherited by CB: dynamic_cast<CB*>(this) |
|
Target of redirection. NULL if not redirected. |