pluginmanager.hh
Go to the documentation of this file.
00001 #ifndef TYPELIB_PLUGINMANAGER_HH
00002 #define TYPELIB_PLUGINMANAGER_HH
00003 
00004 #include <map>
00005 #include <string>
00006 #include <vector>
00007 #include <typelib/utilmm/singleton/use.hh>
00008 #include <typelib/utilmm/configset.hh>
00009 #include <stdexcept>
00010 
00011 namespace Typelib
00012 {
00013     class Registry;
00014     
00015     class Exporter;
00016     class ExportPlugin;
00017 
00018     class Importer;
00019     class ImportPlugin;
00020 
00021     class TypeDefinitionPlugin;
00022     
00024     struct PluginNotFound : std::runtime_error
00025     {
00026         PluginNotFound(const std::string& name) : std::runtime_error("plugin '"+name+"' not found") { }
00027     };
00028 
00030     struct ExportError : std::runtime_error
00031     { 
00032         ExportError(std::string const& msg) : std::runtime_error(msg) {}
00033     };
00034 
00048     class PluginManager
00049     {
00050         std::map<std::string, ExportPlugin*> m_exporters;
00051         std::map<std::string, ImportPlugin*> m_importers;
00052         std::vector<TypeDefinitionPlugin*> m_definition_plugins;
00053         std::vector<void*> m_library_handles;
00054         bool loadPluginFromDirectory(std::string const& directory);
00055         bool loadPlugin(std::string const& path);
00056 
00057         typedef void (*PluginEntryPoint)(PluginManager&);
00058 
00059         PluginManager();
00060         ~PluginManager();
00061         
00062     public:
00064         bool add(ExportPlugin* plugin);
00065 
00068         Importer* importer(std::string const& name) const;
00069 
00071         bool add(ImportPlugin* plugin);
00072 
00075         Exporter* exporter(std::string const& name) const;
00076 
00081         void add(TypeDefinitionPlugin* plugin);
00082 
00085         void registerPluginTypes(Registry& registry);
00086 
00090         static std::string save
00091             ( std::string const& kind
00092             , Registry const& registry);
00093 
00096         static std::string save
00097             ( std::string const& kind
00098             , utilmm::config_set const& config
00099             , Registry const& registry);
00100 
00104         static void save
00105             ( std::string const& kind
00106             , Registry const& registry
00107             , std::ostream& into);
00108 
00118         static void save
00119             ( std::string const& kind
00120             , utilmm::config_set const& config
00121             , Registry const& registry
00122             , std::ostream& into);
00123 
00126         static Registry* load
00127             ( std::string const& kind
00128             , std::istream& stream );
00129         
00132         static void load
00133             ( std::string const& kind
00134             , std::istream& stream
00135             , Registry& into );
00136 
00140         static Registry* load
00141             ( std::string const& kind
00142             , std::string const& file );
00143 
00147         static void load
00148             ( std::string const& kind
00149             , std::string const& file
00150             , Registry& into );
00151 
00152 
00155         static Registry* load
00156             ( std::string const& kind
00157             , std::istream& stream
00158             , utilmm::config_set const& config );
00159         
00162         static void load
00163             ( std::string const& kind
00164             , std::istream& stream
00165             , utilmm::config_set const& config
00166             , Registry& into );
00167 
00171         static Registry* load
00172             ( std::string const& kind
00173             , std::string const& file
00174             , utilmm::config_set const& config );
00175 
00179         static void load
00180             ( std::string const& kind
00181             , std::string const& file
00182             , utilmm::config_set const& config
00183             , Registry& into );
00184 
00188         typedef utilmm::singleton::use<PluginManager> self;
00189 
00190     private:
00191         friend class utilmm::singleton::wrapper<PluginManager>;
00192     };
00193 }
00194 
00195 #endif
00196 


typelib
Author(s): Sylvain Joyeux/sylvain.joyeux@m4x.org
autogenerated on Sat Jun 8 2019 18:49:22