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 <utilmm/singleton/use.hh>
00008 #include <utilmm/configfile/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() : std::runtime_error("plugin 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 loadPlugin(std::string const& path);
00055 
00056         typedef void (*PluginEntryPoint)(PluginManager&);
00057 
00058         PluginManager();
00059         ~PluginManager();
00060         
00061     public:
00063         bool add(ExportPlugin* plugin);
00064 
00067         Importer* importer(std::string const& name) const;
00068 
00070         bool add(ImportPlugin* plugin);
00071 
00074         Exporter* exporter(std::string const& name) const;
00075 
00080         void add(TypeDefinitionPlugin* plugin);
00081 
00084         void registerPluginTypes(Registry& registry);
00085 
00089         static std::string save
00090             ( std::string const& kind
00091             , Registry const& registry);
00092 
00095         static std::string save
00096             ( std::string const& kind
00097             , utilmm::config_set const& config
00098             , Registry const& registry);
00099 
00103         static void save
00104             ( std::string const& kind
00105             , Registry const& registry
00106             , std::ostream& into);
00107 
00117         static void save
00118             ( std::string const& kind
00119             , utilmm::config_set const& config
00120             , Registry const& registry
00121             , std::ostream& into);
00122 
00125         static Registry* load
00126             ( std::string const& kind
00127             , std::istream& stream );
00128         
00131         static void load
00132             ( std::string const& kind
00133             , std::istream& stream
00134             , Registry& into );
00135 
00139         static Registry* load
00140             ( std::string const& kind
00141             , std::string const& file );
00142 
00146         static void load
00147             ( std::string const& kind
00148             , std::string const& file
00149             , Registry& into );
00150 
00151 
00154         static Registry* load
00155             ( std::string const& kind
00156             , std::istream& stream
00157             , utilmm::config_set const& config );
00158         
00161         static void load
00162             ( std::string const& kind
00163             , std::istream& stream
00164             , utilmm::config_set const& config
00165             , Registry& into );
00166 
00170         static Registry* load
00171             ( std::string const& kind
00172             , std::string const& file
00173             , utilmm::config_set const& config );
00174 
00178         static void load
00179             ( std::string const& kind
00180             , std::string const& file
00181             , utilmm::config_set const& config
00182             , Registry& into );
00183 
00187         typedef utilmm::singleton::use<PluginManager> self;
00188 
00189     private:
00190         friend class utilmm::singleton::wrapper<PluginManager>;
00191     };
00192 }
00193 
00194 #endif
00195 


typelib
Author(s): Sylvain Joyeux/sylvain.joyeux@m4x.org
autogenerated on Mon Oct 6 2014 03:17:12