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

Report< CB > Class Template Reference

Hook managing callback sending and recieving. More...

#include <CallBack.h>

List of all members.

Public Member Functions

 Report ()
virtual ~Report ()


Detailed Description

template<class CB>
class Report< CB >

Hook managing callback sending and recieving.

See RedirectCallback for how to define a callback interface class.

A Report is the instance of a callback interface, the sender addresses. Usg. a Report will define all interface methods to use the provided default implementation. The inherited callback interface itself is inaccessible from outside Report (and deived classes are encourgaged tokeep it that way). But it may be redirected to any real recipient using redirectTo.

A sender may invoke the callbacks by creating an instance of Send. Send provides the callback inteface via operator->. Additionally it triggers reportbegin and reportend (see ReportCallback).

What's to be done is, define the abstract callback interface and provide a reasonable default implementation:

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() { ... }

Create a Report class:

class InstReport : public Report<InstCallback> { virtual void reportbegin() { InstCallback::reportbegin(); } virtual void reportend() { InstCallback::reportend(); } virtual void start() { InstCallback::start(); } virtual void progress() { InstCallback::progress(); } virtual void stop() { InstCallback::stop(); } };

InstReport instReport;

Send reports to instReport:

void inst() { InstReport::Send report( instReport ); 1 // construction of report report->start(); 2 ... report->progress(); 3 ... report->stop(); 4 } 5 // destruction of report

Create a recipient:

class InstRecieve : public InstCallback { virtual void reportbegin() { ... } virtual void reportend() { ... } virtual void start() { ... } virtual void progress() { ... } virtual void stop() { ... } };

InstRecieve instRecieve;

Let it recieve reports to instReport:

instReport.redirectTo( instRecieve );

Invocation of inst() now triggers:

1 instRecieve->reportbegin(); 2 instRecieve->start(); 3 instRecieve->progress(); 4 instRecieve->stop(); 5 instRecieve->reportend();


Constructor & Destructor Documentation

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

Constructor.

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

Destructor.


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