InspIRCd  2.0
 All Classes Namespaces Functions Variables Typedefs Enumerations
Public Member Functions | List of all members
HandlerBase0< ReturnType > Class Template Referenceabstract

#include <caller.h>

Inheritance diagram for HandlerBase0< ReturnType >:
classbase

Public Member Functions

virtual ReturnType Call ()=0
 
- Public Member Functions inherited from classbase
virtual CullResult cull ()
 

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 for IsNick, etc. For example, with the example above:

MyNewFunction replaceme(ServerInstance);

someclass->MyFunction = &replaceme;

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.


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