Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

plugin.h

Go to the documentation of this file.
00001 #ifndef PLUGIN_H
00002 #define PLUGIN_H
00003 
00004 #include <kore/kore.h>
00005 #include <kore/module.h>
00006 
00007 /*
00008  * Each Kore dll has to export a function with this signature, in order
00009  * to be used as a Kore plugin (this function is similar to main()):
00010  * extern "C" {
00011  *      Plugin* plugin(HMODULE libHandle, const char* libName, const char* libPath, int libFlags );
00012  * }
00013  * The default implementation for this function should look like:
00014  * Plugin* plugin(HMODULE libHandle, const char* libName, const char* libPath, int libFlags )
00015  * {
00016  *      return new Plugin( libHandle, libName, libPath, libFlags );
00017  * }
00018  * The PLUGIN_MAIN_HDR and PLUGIN_MAIN_BODY are convenience macros for
00019  * the interface and the implementation of the plugin(...) function.
00020  * "handle", "name", "path", "flags" are the NAMES of the corresponding parameters.
00021  * "Type" is the plugin class name (i.e. "MyPlugin").
00022  * I.e. for MyPlugin the user should include the following:
00023  * myplugin.h:
00024  * ==========
00025  * extern "C"
00026  * {
00027  *      PLUGIN_MAIN_HDR( handle, name, path, flags );
00028  * };
00029  * myplugin.cpp:
00030  * ============
00031  * PLUGIN_MAIN_BODY( MyPlugin, handle, name, path, flags );
00032  */
00033 #define PLUGIN_MAIN_HDR(handle,name,path,flags) \
00034     Plugin* plugin(HMODULE handle, const char* name, const char* path, int flags)
00035 #define PLUGIN_MAIN_BODY(Type,handle,name,path,flags) \
00036     PLUGIN_MAIN_HDR(handle,name,path,flags) \
00037     { \
00038         return new Type(handle,name,path,flags); \
00039     }
00040 
00041 namespace kore
00042 {
00043 
00053 class KORE_API Plugin: public Module
00054 {
00055 public:
00059     Plugin();
00070     Plugin(HMODULE handle, const char* libname, const char* libpath, int flags);
00074     virtual ~Plugin();
00075 
00079     virtual void pluginLoaded();
00083     virtual void unloadingPlugin();
00089     virtual void initPlugin();
00095     virtual void finalizePlugin();
00096 
00101     virtual HMODULE libHandle() const;
00102 protected:
00103 private:
00104     // common initialization routine for Plugin's constructors.
00105     void commonInit();
00106     // default Plugin version
00107     const Version* _pluginVersion;
00108     // Kernel API version required by this Plugin
00109     const Version* _pluginAPIVersion;
00110     // Plugin info
00111     const Info* _pluginInfo;
00112     // dll's name
00113     const char* _libName;
00114     // dll's path
00115     const char* _libPath;
00116     // flags used when opening the dll (platform dependant)
00117     int _libFlags;
00118     // platform-dependant representation of the actual dll
00119     HMODULE _libHandle;
00120 };
00121 
00122 };
00123 
00124 #endif

Generated on Sat Feb 16 03:44:39 2002 for Korelib by doxygen1.2.12 written by Dimitri van Heesch, © 1997-2001