-
-class CoreExport FindSymbolException : public CoreException
-{
- public:
- /** This constructor can be used to specify an error message before throwing.
- */
- FindSymbolException(const std::string &message)
- : CoreException(message, "the core")
- {
- }
-
- /** This destructor solves world hunger, cancels the world debt, and causes the world to end.
- * Actually no, it does nothing. Never mind.
- * @throws Nothing!
- */
- virtual ~FindSymbolException() throw() {};
-};
-
-class Module;
-/** This is the highest-level class of the DLLFactory system used to load InspIRCd modules and commands.
- * All the dirty mucking around with dl*() is done by DLLManager, all this does it put a pretty shell on
- * it and make it nice to use to load modules and core commands. This class is quite specialised for these
- * two uses and it may not be useful more generally -- use DLLManager directly for that.
- */
-class CoreExport DLLFactory : public DLLManager
-{
- public:
- typedef Module* (initfunctype)();
-
- /** Pointer to the init function.
- */
- initfunctype* const init_func;
-
- /** 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(const char *fname, const char *func_name)
- : DLLManager(fname), init_func(NULL)
- {
- 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);
- }
- }
-
- /** The destructor deletes the ModuleFactory pointer.
- */
- ~DLLFactory()
- {
- }
-};
-
-#endif
-