- Main Page
- Modules
- Namespaces
- Classes
- Files
- Related Pages

- File List
- File Members

# FUtils/FUPluginManager.h

    00001 /*
    00002     Copyright (C) 2005-2007 Feeling Software Inc.
    00003     Portions of the code are:
    00004     Copyright (C) 2005-2007 Sony Computer Entertainment America
    00005
    00006     MIT License: http://www.opensource.org/licenses/mit-license.php
    00007 */
    00008
    00009 #ifndef _FU_PLUGIN_MANAGER_H_
    00010 #define _FU_PLUGIN_MANAGER_H_
    00011
    00012 class FUObjectType;
    00013 class FUPlugin;
    00014
    00027 class FCOLLADA_EXPORT FUPluginManager
    00028 {
    00029 public:
    00033     typedef uint32 (*GetPluginCount)(void);
    00034
    00038     typedef const FUObjectType* (*GetPluginType)(uint32 index);
    00039
    00043     typedef FUPlugin* (*CreatePlugin)(uint32 index);
    00044
    00045 private:
    00046     struct PluginLibrary
    00047     {
    00048         fstring filename;
    00049 #if defined(WIN32)
    00050         HMODULE module;
    00051 #elif defined(__APPLE__) || defined(LINUX)
    00052         void* module;
    00053 #endif // WIN32
    00054
    00055         GetPluginCount getPluginCount;
    00056         GetPluginType getPluginType;
    00057         CreatePlugin createPlugin;
    00058     };
    00059     typedef fm::pvector<PluginLibrary> PluginLibraryList;
    00060
    00061     fstring pluginFolderName;
    00062     PluginLibraryList loadedLibraries;
    00063     FUObjectContainer<FUPlugin> loadedPlugins;
    00064
    00065 public:
    00071     FUPluginManager(const fchar* pluginLibraryFilter);
    00072
    00076     virtual ~FUPluginManager();
    00077
    00084     void AddPluginLibrary(FUPluginManager::GetPluginCount fnGetPluginCount, FUPluginManager::GetPluginType fnGetPluginType, FUPluginManager::CreatePlugin fnCreatePlugin);
    00085
    00092     void LoadPlugins(const FUObjectType& pluginType);
    00093
    00097     void UnloadPlugins();
    00098
    00101     inline size_t GetLoadedPluginCount() { return loadedPlugins.size(); }
    00102
    00105     inline FUPlugin** GetLoadedPlugins() { return loadedPlugins.begin(); }
    00106     inline const FUPlugin** GetLoadedPlugins() const { return loadedPlugins.begin(); }
    00111     inline FUPlugin* GetLoadedPlugin(size_t index) { FUAssert(index < loadedPlugins.size(), return NULL); return loadedPlugins.at(index); }
    00112     inline const FUPlugin* GetLoadedPlugin(size_t index) const { FUAssert(index < loadedPlugins.size(), return NULL); return loadedPlugins.at(index); }
    00114 private:
    00115     void LoadPluginsInFolderName(const fstring& folderName, const fchar* pluginLibraryFilter);
    00116 };
    00117
    00118 #endif // _FU_PLUGIN_MANAGER_H_