PluginLoader.h

00001 /***************************************************************************
00002  *                                                                         *
00003  *   (c) Art Tevs, MPI Informatik Saarbruecken                             *
00004  *       mailto: <tevs@mpi-sb.mpg.de>                                      *
00005  *                                                                         *
00006  *   This program is free software; you can redistribute it and/or modify  *
00007  *   it under the terms of the GNU General Public License as published by  *
00008  *   the Free Software Foundation; either version 2 of the License, or     *
00009  *   (at your option) any later version.                                   *
00010  *                                                                         *
00011  ***************************************************************************/
00012 
00013 
00014 #ifndef _NR_PLUGIN_RESOURCE_LOADER_H_
00015 #define _NR_PLUGIN_RESOURCE_LOADER_H_
00016 
00017 //----------------------------------------------------------------------------------
00018 // Includes
00019 //----------------------------------------------------------------------------------
00020 #include "Prerequisities.h"
00021 #include "ResourceLoader.h"
00022 #include "Plugin.h"
00023 #include "ScriptEngine.h"
00024 
00025 //----------------------------------------------------------------------------------
00026 // Define the library loading functions on the appropriate OS API
00027 //----------------------------------------------------------------------------------
00028 #if NR_PLATFORM == NR_PLATFORM_WIN32
00029 #    define NR_PLUGIN_LOAD( a ) LoadLibrary( a )
00030 #    define NR_PLUGIN_GETSYM( a, b ) GetProcAddress( a, b )
00031 #    define NR_PLUGIN_UNLOAD( a ) FreeLibrary( a )
00032 
00033 #elif NR_PLATFORM == NR_PLATFORM_LINUX
00034 #    define NR_PLUGIN_LOAD( a ) dlopen( a, RTLD_LAZY )
00035 #    define NR_PLUGIN_GETSYM( a, b ) dlsym( a, b )
00036 #    define NR_PLUGIN_UNLOAD( a ) dlclose( a )
00037 
00038 #elif NR_PLATFORM == NR_PLATFORM_APPLE
00039 #    define NR_PLUGIN_LOAD( a ) mac_loadExeBundle( a )
00040 #    define NR_PLUGIN_GETSYM( a, b ) mac_getBundleSym( a, b )
00041 #    define NR_PLUGIN_UNLOAD( a ) mac_unloadExeBundle( a )
00042 #endif
00043 
00044 namespace nrEngine{
00045         
00046         //! Plugin loader does handle loading/creating of plugin libraries for the engine
00047         /**
00048         * This is a derived class from ResourceLoader. This class does support loading
00049         * of plugins (*.so, *.dll).
00050         * 
00051         * @see IResourceLoader
00052         * \ingroup plugin
00053         **/
00054         class _NRExport PluginLoader : public IResourceLoader{
00055         public:
00056                         
00057                 /**
00058                 * Declare supported resource types and supported files.
00059                 **/
00060                 PluginLoader();
00061                 
00062                 /**
00063                 * Destructor 
00064                 **/
00065                 ~PluginLoader();
00066 
00067         private:
00068         
00069                 /**
00070                 * Initialize supported resource and file types
00071                 * @see IResourceLoader::initialize()
00072                 **/
00073                 Result initializeResourceLoader();
00074 
00075                 /**
00076                  * @see IResourceLoader::loadResource()
00077                  **/
00078                 Result loadResource(IResource* res, const std::string& fileName, PropertyList* param = NULL);
00079 
00080                 /**
00081                  * @see IResourceLoader::createResource()
00082                  **/
00083                 IResource* createResource(const std::string& resourceType, PropertyList* params = NULL);
00084                         
00085                 /**
00086                  * @see IResourceLoader::createEmptyResource()
00087                  **/
00088                 IResource* createEmptyResource(const std::string& resourceType);
00089 
00090                 /**
00091                  * @see IResourceLoader::getSuffix()
00092                  **/
00093                 std::string getSuffix(const std::string& resType);
00094 
00095 
00096                 //! New scripting function to allow loading of plugins
00097                 ScriptFunctionDef(loadPlugin);
00098                 
00099         };
00100 
00101 };
00102 
00103 #endif

Generated on Wed Sep 12 23:19:42 2007 for nrEngine by  doxygen 1.5.1