- /** Instance pointer to be passed to init_*() when it is called.
- */
- InspIRCd* ServerInstance;
-
- public:
- /** Default constructor.
- * This constructor passes its paramerers down through DLLFactoryBase and then DLLManager
- * to load the module, then calls the factory function to retrieve a pointer to a ModuleFactory
- * class. It is then down to the core to call the ModuleFactory::CreateModule() method and
- * receive a Module* which it can insert into its module lists.
- */
- DLLFactory(InspIRCd* Instance, const char *fname, const char *func_name)
- : DLLManager(Instance, fname), init_func(NULL), ServerInstance(Instance)
- {
- const char* error = LastError();
-
- if(!error)
- {
- if(!GetSymbol((void **)&init_func, func_name))
- {
- throw FindSymbolException("Missing " + std::string(func_name) + "() entrypoint!");
- }
- }
- else
- {
- throw LoadModuleException(error);
- }
- }
-
- ReturnType* CallInit()
- {
- if(init_func)
- {
- return init_func(ServerInstance);
- }
- else
- {
- return NULL;
- }
- }
-
- /** The destructor deletes the ModuleFactory pointer.
- */
- ~DLLFactory()
- {
- }