source: nrEngine/include/PluginLoader.h @ 35

Revision 35, 3.3 KB checked in by art, 12 years ago (diff)

Big changes in resource managment system. Interface functions were renamed.
Resource loading is now done throughthe resource and not through the loader.

Line 
1/***************************************************************************
2 *                                                                         *
3 *   (c) Art Tevs, MPI Informatik Saarbruecken                             *
4 *       mailto: <tevs@mpi-sb.mpg.de>                                      *
5 *                                                                         *
6 *   This program is free software; you can redistribute it and/or modify  *
7 *   it under the terms of the GNU General Public License as published by  *
8 *   the Free Software Foundation; either version 2 of the License, or     *
9 *   (at your option) any later version.                                   *
10 *                                                                         *
11 ***************************************************************************/
12
13
14#ifndef _NR_PLUGIN_RESOURCE_LOADER_H_
15#define _NR_PLUGIN_RESOURCE_LOADER_H_
16
17//----------------------------------------------------------------------------------
18// Includes
19//----------------------------------------------------------------------------------
20#include "Prerequisities.h"
21#include "ResourceLoader.h"
22#include "Plugin.h"
23#include "ScriptEngine.h"
24
25//----------------------------------------------------------------------------------
26// Define the library loading functions on the appropriate OS API
27//----------------------------------------------------------------------------------
28#if NR_PLATFORM == NR_PLATFORM_WIN32
29#    define NR_PLUGIN_LOAD( a ) LoadLibrary( a )
30#    define NR_PLUGIN_GETSYM( a, b ) GetProcAddress( a, b )
31#    define NR_PLUGIN_UNLOAD( a ) FreeLibrary( a )
32
33#elif NR_PLATFORM == NR_PLATFORM_LINUX
34#    define NR_PLUGIN_LOAD( a ) dlopen( a, RTLD_LAZY )
35#    define NR_PLUGIN_GETSYM( a, b ) dlsym( a, b )
36#    define NR_PLUGIN_UNLOAD( a ) dlclose( a )
37
38#elif NR_PLATFORM == NR_PLATFORM_APPLE
39#    define NR_PLUGIN_LOAD( a ) mac_loadExeBundle( a )
40#    define NR_PLUGIN_GETSYM( a, b ) mac_getBundleSym( a, b )
41#    define NR_PLUGIN_UNLOAD( a ) mac_unloadExeBundle( a )
42#endif
43
44namespace nrEngine{
45       
46        //! Plugin loader does handle loading/creating of plugin libraries for the engine
47        /**
48        * This is a derived class from ResourceLoader. This class does support loading
49        * of plugins (*.so, *.dll).
50        *
51        * @see IResourceLoader
52        * \ingroup plugin
53        **/
54        class _NRExport PluginLoader : public IResourceLoader{
55        public:
56                       
57                /**
58                * Declare supported resource types and supported files.
59                **/
60                PluginLoader();
61               
62                /**
63                * Destructor
64                **/
65                ~PluginLoader();
66
67        private:
68       
69                /**
70                * Initialize supported resource and file types
71                * @see IResourceLoader::initialize()
72                **/
73                Result initializeResourceLoader();
74
75                /**
76                 * @see IResourceLoader::loadResource()
77                 **/
78                Result loadResource(IResource* res, const std::string& fileName, PropertyList* param = NULL);
79
80                /**
81                 * @see IResourceLoader::createResource()
82                 **/
83                IResource* createResource(const std::string& resourceType, PropertyList* params = NULL);
84                       
85                /**
86                 * @see IResourceLoader::createEmptyResource()
87                 **/
88                IResource* createEmptyResource(const std::string& resourceType);
89
90                /**
91                 * @see IResourceLoader::getSuffix()
92                 **/
93                std::string getSuffix(const std::string& resType);
94
95
96                //! New scripting function to allow loading of plugins
97                ScriptFunctionDef(loadPlugin);
98               
99        };
100
101};
102
103#endif
Note: See TracBrowser for help on using the repository browser.