The InspIRCd Project
Home | Developers | Wiki | Forums | Bug Tracker | SVN | Download
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

HandlerBase0< ReturnType > Class Template Reference

The templates below can be auto generated by tools/create_templates.pl. More...

#include <caller.h>

List of all members.

Public Member Functions

virtual ReturnType Call ()=0
virtual ~HandlerBase0 ()


Detailed Description

template<typename ReturnType>
class HandlerBase0< ReturnType >

The templates below can be auto generated by tools/create_templates.pl.

They are used to represent a functor with a given number of parameters and a specific return type. To prevent passing the wrong number of parameters and have the compiler detect this error at build-time, each class is numbered according to the number of parameters it takes, e.g. caller0, caller1, caller2. These have been generated from zero parameters to eight.

If you want to declare a functor which takes two parameters, a User and a Channel, and returns bool, simply create it like this:

caller2<bool, User*, Channel*> MyFunction;

and initialize it correctly, when placed into a class you will be able to call it:

bool n = someclass->MyFunction(someuser, somechan);

These functor templates work this way so that you can simply and easily allow for these class methods to be overridden from within a module, e.g. have a module which completely replaces the code f r IsNick, etc. For example, with the example above:

MyNewFunction replaceme(ServerInstance);

someclass->MyFunction =

After this point, calls to someclass->MyFunction will call the new code in your replacement functor.

This is a very powerful feature which should be considered 'advanced' and not for beginners. If you do not understand these templates, STAY AWAY from playing with this until you do, as if you get this wrong, this can generate some pretty long winded and confusing error messages at compile time.

Definition at line 50 of file caller.h.


Constructor & Destructor Documentation

template<typename ReturnType>
virtual HandlerBase0< ReturnType >::~HandlerBase0  )  [inline, virtual]
 

Definition at line 54 of file caller.h.


Member Function Documentation

template<typename ReturnType>
virtual ReturnType HandlerBase0< ReturnType >::Call  )  [pure virtual]
 


The documentation for this class was generated from the following file: