]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Module factory and init function in modules turned into a neat macro:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Sun, 17 Jun 2007 13:04:25 +0000 (13:04 +0000)
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Sun, 17 Jun 2007 13:04:25 +0000 (13:04 +0000)
INIT_MODULE(MyModuleClassName);
Get cracking, w00t :)

git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@7341 e03df62e-2008-0410-955e-edbf42e46eb7

include/modules.h
src/modules/m_alias.cpp
src/modules/m_testcommand.cpp

index b94abfbbc53c5dac4a4213cd79aee9ff374d7261..332f2b8125428cdafd3ae8c0b6ef3c88957ca5c7 100644 (file)
@@ -6,7 +6,7 @@
  * See: http://www.inspircd.org/wiki/index.php/Credits
  *
  * This program is free but copyrighted software; see
- *            the file COPYING for details.
+ *         the file COPYING for details.
  *
  * ---------------------------------------------------
  */
@@ -1608,4 +1608,20 @@ typedef std::vector<Module*> ModuleList;
  */
 typedef std::vector<ircd_module*> FactoryList;
 
+
+#define MODULE_INIT(y) \
+       class Factory : public ModuleFactory \
+       { \
+        public: \
+               virtual Module * CreateModule(InspIRCd* Me) \
+               { \
+                       return new y(Me); \
+               } \
+       }; \
+       extern "C" DllExport void * init_module(void) \
+       { \
+               return new Factory; \
+       }
+
 #endif
+
index 15a2928ee3e9ad924d8847acea3bcb900c1ae6a0..1e117fb3da9493ac3fc3530c83738a90b5a9a523 100644 (file)
@@ -269,27 +269,5 @@ class ModuleAlias : public Module
        }
 };
 
-
-class ModuleAliasFactory : public ModuleFactory
-{
- public:
-       ModuleAliasFactory()
-       {
-       }
-
-       ~ModuleAliasFactory()
-       {
-       }
-
-               virtual Module * CreateModule(InspIRCd* Me)
-       {
-               return new ModuleAlias(Me);
-       }
-};
-
-
-extern "C" DllExport void * init_module( void )
-{
-       return new ModuleAliasFactory;
-}
+MODULE_INIT(ModuleAlias);
 
index a32559c68521a44b0bf22627fa3626ed37d28010..c0fe10291783cc376b94a3625f24271757962d73 100644 (file)
@@ -102,28 +102,4 @@ class ModuleTestCommand : public Module
        }
 };
 
-
-class ModuleTestCommandFactory : public ModuleFactory
-{
- public:
-       ModuleTestCommandFactory()
-       {
-       }
-       
-       ~ModuleTestCommandFactory()
-       {
-       }
-       
-       virtual Module * CreateModule(InspIRCd* Me)
-       {
-               return new ModuleTestCommand(Me);
-       }
-       
-};
-
-
-extern "C" DllExport void * init_module( void )
-{
-       return new ModuleTestCommandFactory;
-}
-
+MODULE_INIT(ModuleTestCommand);