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 <utilmm/singleton/use.hh>
00007 #include <utilmm/configfile/configset.hh>
00008 #include <stdexcept>
00009 
00010 namespace Typelib
00011 {
00012     class Registry;
00013     
00014     class Exporter;
00015     class ExportPlugin;
00016 
00017     class Importer;
00018     class ImportPlugin;
00019     
00021     struct PluginNotFound : std::runtime_error
00022     {
00023         PluginNotFound() : std::runtime_error("plugin not found") { }
00024     };
00025 
00027     struct ExportError : std::runtime_error
00028     { 
00029         ExportError(char const* msg) : std::runtime_error(msg) {}
00030     };
00031 
00045     class PluginManager
00046     {
00047         std::map<std::string, ExportPlugin*> m_exporters;
00048         std::map<std::string, ImportPlugin*> m_importers;
00049 
00050         PluginManager();
00051         ~PluginManager();
00052         
00053     public:
00055         bool add(ExportPlugin* plugin);
00056 
00059         Importer* importer(std::string const& name) const;
00060 
00062         bool add(ImportPlugin* plugin);
00063 
00066         Exporter* exporter(std::string const& name) const;
00067 
00071         static std::string save
00072             ( std::string const& kind
00073             , Registry const& registry);
00074 
00077         static std::string save
00078             ( std::string const& kind
00079             , utilmm::config_set const& config
00080             , Registry const& registry);
00081 
00085         static void save
00086             ( std::string const& kind
00087             , Registry const& registry
00088             , std::ostream& into);
00089 
00099         static void save
00100             ( std::string const& kind
00101             , utilmm::config_set const& config
00102             , Registry const& registry
00103             , std::ostream& into);
00104 
00107         static Registry* load
00108             ( std::string const& kind
00109             , std::istream& stream );
00110         
00113         static void load
00114             ( std::string const& kind
00115             , std::istream& stream
00116             , Registry& into );
00117 
00121         static Registry* load
00122             ( std::string const& kind
00123             , std::string const& file );
00124 
00128         static void load
00129             ( std::string const& kind
00130             , std::string const& file
00131             , Registry& into );
00132 
00133 
00136         static Registry* load
00137             ( std::string const& kind
00138             , std::istream& stream
00139             , utilmm::config_set const& config );
00140         
00143         static void load
00144             ( std::string const& kind
00145             , std::istream& stream
00146             , utilmm::config_set const& config
00147             , Registry& into );
00148 
00152         static Registry* load
00153             ( std::string const& kind
00154             , std::string const& file
00155             , utilmm::config_set const& config );
00156 
00160         static void load
00161             ( std::string const& kind
00162             , std::string const& file
00163             , utilmm::config_set const& config
00164             , Registry& into );
00165 
00169         typedef utilmm::singleton::use<PluginManager> self;
00170 
00171     private:
00172         friend class utilmm::singleton::wrapper<PluginManager>;
00173     };
00174 }
00175 
00176 #endif
00177 

Generated on Thu Jan 22 16:37:20 2009 for typeLib by doxygen 1.5.6
SourceForge.net Project Page