Inheritance diagram for nrEngine::Plugin:
Public Member Functions | |
Plugin () | |
virtual | ~Plugin () |
virtual void * | getSymbol (const std::string &name) const |
Protected Types | |
typedef int(*) | plgInitialize (Engine *, PropertyList *) |
This defines the interface of the initialization function of the plugin. | |
typedef char *(*) | plgError (int) |
Define the type of the error get function of th eplugin. | |
typedef void(*) | plgRelease (void) |
This is the interface of the release function of the plugin. | |
typedef unsigned int(*) | plgEngineVersion (void) |
Interface for the version information. | |
typedef char *(*) | plgVersionString (void) |
Get full version string of the plugin. | |
Protected Member Functions | |
Result | initialize (PropertyList *params=NULL) |
virtual Result | unloadResource () |
virtual Result | reloadResource (PropertyList *params) |
std::string | getLastPluginError () |
Get last plugin error message from the system. | |
Protected Attributes | |
PluginHandle | mPluginHandle |
Handle of the used dynamic library. | |
plgInitialize | m_plgInitialize |
plgError | m_plgError |
plgRelease | m_plgRelease |
plgEngineVersion | m_plgEngineVersion |
plgVersionString | m_plgVersionString |
Friends | |
class | PluginLoader |
Plugin loader is a friend, so it get full accecc to our functions. |
Plugins are used to extend the functionality of the engine without rewriting it. You can just write new plugin and add this to the engine, so the engine could get it loaded. The user will then get the new functionality automaticaly or by using the concept of application - plugin - communication.
Plugins are resources that used in the same way like normal resources.
Each plugin library has to export following symbols:
Following symbols are optional:
Definition at line 123 of file Plugin.h.
void * nrEngine::Plugin::getSymbol | ( | const std::string & | name | ) | const [virtual] |
Retuns the addres of a symbol (function,variable) from the plugin. You have to cast this addres for using.
name | Unique name of the symbol |
Reimplemented in nrEngine::EmptyPlugin.
Definition at line 37 of file Plugin.cpp.
References mPluginHandle.
Referenced by initialize().
Result nrEngine::Plugin::initialize | ( | PropertyList * | params = NULL |
) | [protected] |
This method is called by the plugin loader after it has loaed the library. The plugin object has now to get all symbols and initialize the library.
Definition at line 44 of file Plugin.cpp.
References nrEngine::convertVersionToString(), nrEngine::IResource::getResourceName(), getSymbol(), nrEngine::Engine::instance(), nrEngine::Log::LL_DEBUG, nrEngine::Log::LL_ERROR, nrEngine::Log::LOG_ENGINE, nrEngine::Log::LOG_PLUGIN, m_plgEngineVersion, m_plgError, m_plgInitialize, m_plgRelease, m_plgVersionString, nrEngine::nrEngineVersion, nrEngine::OK, nrEngine::PLG_EXTERNAL_ERROR, nrEngine::PLG_SYMBOL_NOT_FOUND, and nrEngine::PLG_WRONG_VERSION.
Referenced by reloadResource().
Result nrEngine::Plugin::unloadResource | ( | ) | [protected, virtual] |
Derived function from IResource
Implements nrEngine::IResource.
Reimplemented in nrEngine::EmptyPlugin.
Definition at line 123 of file Plugin.cpp.
References getLastPluginError(), nrEngine::IResource::getResourceName(), nrEngine::IResource::isResourceLoaded(), nrEngine::Log::LL_ERROR, nrEngine::Log::LOG_ENGINE, m_plgEngineVersion, m_plgError, m_plgInitialize, m_plgRelease, m_plgVersionString, nrEngine::IResource::markResourceUnloaded(), mPluginHandle, nrEngine::OK, and nrEngine::PLG_UNLOAD_ERROR.
Referenced by ~Plugin().
Result nrEngine::Plugin::reloadResource | ( | PropertyList * | params | ) | [protected, virtual] |
Reload resource. Each resource object should be able to reload itself from the disk or other media. It can use the assigned loader to load files or to make it by itself. At the end the resource should be marked as loaded.
Implements nrEngine::IResource.
Definition at line 157 of file Plugin.cpp.
References getLastPluginError(), nrEngine::IResource::getResourceFilenameList(), nrEngine::IResource::getResourceName(), initialize(), nrEngine::IResource::isResourceLoaded(), nrEngine::Log::LL_ERROR, nrEngine::Log::LOG_ENGINE, mPluginHandle, nrEngine::OK, and nrEngine::PLG_COULD_NOT_LOAD.