X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=include%2Fcaller.h;h=66603575221e794e395b315606738b522c81d2d1;hb=74066e0f563ef630e432d3bbb10544318b70ade3;hp=396a5ba5a660c9da4f2813e49b6c28c4fe5591e9;hpb=529f16e84b4ba1328a13be32e40a71156c4725f8;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/include/caller.h b/include/caller.h index 396a5ba5a..666035752 100644 --- a/include/caller.h +++ b/include/caller.h @@ -2,8 +2,8 @@ * | Inspire Internet Relay Chat Daemon | * +------------------------------------+ * - * InspIRCd: (C) 2002-2007 InspIRCd Development Team - * See: http://www.inspircd.org/wiki/index.php/Credits + * InspIRCd: (C) 2002-2009 InspIRCd Development Team + * See: http://wiki.inspircd.org/Credits * * This program is free but copyrighted software; see * the file COPYING for details. @@ -14,17 +14,17 @@ #ifndef __CALLER__H__ #define __CALLER__H__ -/* The templates below can be auto generated by tools/create_templates.pl. +/** 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 userrec and a chanrec, + * 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 MyFunction; + * caller2 MyFunction; * * and initialize it correctly, when placed into a class you will be able to call it: * @@ -32,13 +32,21 @@ * * 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. 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. + * 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. */ - template class CoreExport HandlerBase0 { public: @@ -137,7 +145,7 @@ template class CoreExport caller1 : publi { public: caller1(HandlerBase1* initial) - : caller< HandlerBase1 >::caller(initial) + : caller< HandlerBase1 >(initial) { } virtual ReturnType operator() (Param1 param1) @@ -150,7 +158,7 @@ template class CoreExpor { public: caller2(HandlerBase2* initial) - : caller< HandlerBase2 >::caller(initial) + : caller< HandlerBase2 >(initial) { } virtual ReturnType operator() (Param1 param1, Param2 param2) @@ -163,7 +171,7 @@ template * initial) - : caller< HandlerBase3 >::caller(initial) + : caller< HandlerBase3 >(initial) { } virtual ReturnType operator() (Param1 param1, Param2 param2, Param3 param3) @@ -176,7 +184,7 @@ template * initial) - : caller< HandlerBase4 >::caller(initial) + : caller< HandlerBase4 >(initial) { } virtual ReturnType operator() (Param1 param1, Param2 param2, Param3 param3, Param4 param4) @@ -189,7 +197,7 @@ template * initial) - : caller< HandlerBase5 >::caller(initial) + : caller< HandlerBase5 >(initial) { } virtual ReturnType operator() (Param1 param1, Param2 param2, Param3 param3, Param4 param4, Param5 param5) @@ -202,7 +210,7 @@ template * initial) - : caller< HandlerBase6 >::caller(initial) + : caller< HandlerBase6 >(initial) { } virtual ReturnType operator() (Param1 param1, Param2 param2, Param3 param3, Param4 param4, Param5 param5, Param6 param6) @@ -215,7 +223,7 @@ template * initial) - : caller< HandlerBase7 >::caller(initial) + : caller< HandlerBase7 >(initial) { } virtual ReturnType operator() (Param1 param1, Param2 param2, Param3 param3, Param4 param4, Param5 param5, Param6 param6, Param7 param7) @@ -228,7 +236,7 @@ template * initial) - : caller< HandlerBase8 >::caller(initial) + : caller< HandlerBase8 >(initial) { } virtual ReturnType operator() (Param1 param1, Param2 param2, Param3 param3, Param4 param4, Param5 param5, Param6 param6, Param7 param7, Param8 param8) @@ -237,14 +245,38 @@ template { InspIRCd* Server; public: NAME(InspIRCd* Srv) : Server(Srv) { } virtual ~NAME() { } virtual RETURN Call(); }; + class CoreExport NAME : public HandlerBase0 { public: NAME() { } virtual ~NAME() { } virtual RETURN Call(); } #define DEFINE_HANDLER1(NAME, RETURN, V1) \ - class CoreExport NAME : public HandlerBase1 { InspIRCd* Server; public: NAME(InspIRCd* Srv) : Server(Srv) { } virtual ~NAME() { } virtual RETURN Call(V1); }; + class CoreExport NAME : public HandlerBase1 { public: NAME() { } virtual ~NAME() { } virtual RETURN Call(V1); } #define DEFINE_HANDLER2(NAME, RETURN, V1, V2) \ - class CoreExport NAME : public HandlerBase2 { InspIRCd* Server; public: NAME(InspIRCd* Srv) : Server(Srv) { } virtual ~NAME() { } virtual RETURN Call(V2); }; + class CoreExport NAME : public HandlerBase2 { public: NAME() { } virtual ~NAME() { } virtual RETURN Call(V1, V2); } -#endif +#define DEFINE_HANDLER3(NAME, RETURN, V1, V2, V3) \ + class CoreExport NAME : public HandlerBase3 { public: NAME() { } virtual ~NAME() { } virtual RETURN Call(V1, V2, V3); } + +#define DEFINE_HANDLER4(NAME, RETURN, V1, V2, V3, V4) \ + class CoreExport NAME : public HandlerBase4 { public: NAME() { } virtual ~NAME() { } virtual RETURN Call(V1, V2, V3, V4); } + +#define DEFINE_HANDLER5(NAME, RETURN, V1, V2, V3, V4, V5) \ + class CoreExport NAME : public HandlerBase5 { public: NAME() { } virtual ~NAME() { } virtual RETURN Call(V1, V2, V3, V4, V5); } + +#define DEFINE_HANDLER6(NAME, RETURN, V1, V2, V3, V4, V5, V6) \ + class CoreExport NAME : public HandlerBase6 { public: NAME() { } virtual ~NAME() { } virtual RETURN Call(V1, V2, V3, V4, V5, V6); } +#define DEFINE_HANDLER7(NAME, RETURN, V1, V2, V3, V4, V5, V6, V7) \ + class CoreExport NAME : public HandlerBase7 { public: NAME() { } virtual ~NAME() { } virtual RETURN Call(V1, V2, V3, V4, V5, V6, V7); } + +#define DEFINE_HANDLER8(NAME, RETURN, V1, V2, V3, V4, V5, V6, V7, V8) \ + class CoreExport NAME : public HandlerBase8 { public: NAME() { } virtual ~NAME() { } virtual RETURN Call(V1, V2, V3, V4, V5, V6, V7, V8); } + +#endif