]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - include/caller.h
And another error fix
[user/henk/code/inspircd.git] / include / caller.h
index 9f251d16c6c281f34a384ec3527ab97ae1d685d8..5850ae2a6a568ba9e86ef7204f4fa5e6d4eada30 100644 (file)
  *
  * 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 f r 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 <typename ReturnType> class CoreExport HandlerBase0
@@ -237,5 +246,40 @@ template <typename ReturnType, typename Param1, typename Param2, typename Param3
        }
 };
 
+/** These shorthand macros are used to define a functor class which only implements Call(). Most functors are like this.
+ * If you want something more complex, define them by hand.
+ *
+ * The first parameter to each macro is the class name to define, the second parameter is the return value of Call().
+ * The following parameters are the parameter types for Call(), and again, the macro is numbered to match the number of
+ * parameters, to prevent mistakes.
+ */
+
+#define DEFINE_HANDLER0(NAME, RETURN) \
+       class CoreExport NAME : public HandlerBase0<RETURN> { InspIRCd* Server; public: NAME(InspIRCd* Srv) : Server(Srv) { } virtual ~NAME() { } virtual RETURN Call(); };
+
+#define DEFINE_HANDLER1(NAME, RETURN, V1) \
+       class CoreExport NAME : public HandlerBase1<RETURN, V1> { InspIRCd* Server; public: NAME(InspIRCd* Srv) : Server(Srv) { } virtual ~NAME() { } virtual RETURN Call(V1); };
+
+#define DEFINE_HANDLER2(NAME, RETURN, V1, V2) \
+       class CoreExport NAME : public HandlerBase2<RETURN, V1, V2> { InspIRCd* Server; public: NAME(InspIRCd* Srv) : Server(Srv) { } virtual ~NAME() { } virtual RETURN Call(V1, V2); };
+
+#define DEFINE_HANDLER3(NAME, RETURN, V1, V2, V3) \
+       class CoreExport NAME : public HandlerBase3<RETURN, V1, V2, V3> { InspIRCd* Server; public: NAME(InspIRCd* Srv) : Server(Srv) { } virtual ~NAME() { } virtual RETURN Call(V1, V2, V3); };
+
+#define DEFINE_HANDLER4(NAME, RETURN, V1, V2, V3, V4) \
+       class CoreExport NAME : public HandlerBase4<RETURN, V1, V2, V3, V4> { InspIRCd* Server; public: NAME(InspIRCd* Srv) : Server(Srv) { } virtual ~NAME() { } virtual RETURN Call(V1, V2, V3, V4); };
+
+#define DEFINE_HANDLER5(NAME, RETURN, V1, V2, V3, V4, V5) \
+       class CoreExport NAME : public HandlerBase5<RETURN, V1, V2, V3, V4, V5> { InspIRCd* Server; public: NAME(InspIRCd* Srv) : Server(Srv) { } 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<RETURN, V1, V2, V3, V4, V5, V6> { InspIRCd* Server; public: NAME(InspIRCd* Srv) : Server(Srv) { } 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<RETURN, V1, V2, V3, V4, V5, V6, V7> { InspIRCd* Server; public: NAME(InspIRCd* Srv) : Server(Srv) { } 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<RETURN, V1, V2, V3, V4, V5, V6, V7, V8> { InspIRCd* Server; public: NAME(InspIRCd* Srv) : Server(Srv) { } virtual ~NAME() { } virtual RETURN Call(V1, V2, V3, V4, V5, V6, V7, V8); };
+
 #endif