Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

RedirectCallback< CB > Class Template Reference

Base class for callback interfaces which allow redirection. More...

#include <CallBack.h>

Inheritance diagram for RedirectCallback< CB >:

ReportCallback List of all members.

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

Detailed Description

template<class CB>
class RedirectCallback< CB >

Base class for callback interfaces which allow redirection.

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 between cbvar.start() and cbvar->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

template<class CB>
RedirectCallback< CB >::RedirectCallback  )  [inline]
 

Constructor.

template<class CB>
virtual RedirectCallback< CB >::~RedirectCallback  )  [inline, virtual]
 

Destructor.


Member Function Documentation

template<class CB>
virtual CB* RedirectCallback< CB >::operator->  )  [inline, virtual]
 

Forward access if redirected, otherwise refer to this.

template<class CB>
CB* RedirectCallback< CB >::redirectTo CB &  to_r  )  [inline, protected]
 

Set redirection to another CB instance.

Returns:
The previois redirection, or NULL if not redirected

template<class CB>
CB* RedirectCallback< CB >::redirectTo CB *  to_r  )  [inline, protected]
 

Set redirection to another CB instance. Clear redirection if NULL.

Returns:
The previois redirection, or NULL if not redirected

template<class CB>
CB* RedirectCallback< CB >::self  )  [inline, private]
 

Expecting to be inherited by CB: dynamic_cast<CB*>(this)


Member Data Documentation

template<class CB>
CB* RedirectCallback< CB >::_redirectTo [private]
 

Target of redirection. NULL if not redirected.


The documentation for this class was generated from the following file:
Generated on Thu Feb 23 23:56:11 2006 for liby2util by doxygen 1.3.6