mirror of
https://github.com/inspircd/inspircd.git
synced 2025-03-10 02:59:01 -04:00
Module factory and init function in modules turned into a neat macro:
INIT_MODULE(MyModuleClassName); Get cracking, w00t :) git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@7341 e03df62e-2008-0410-955e-edbf42e46eb7
This commit is contained in:
parent
c51f67a37c
commit
84472069ba
@ -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
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user