00001 /* This is for emacs: -*-Mode: C++;-*- */ 00002 #if !defined(__INC_GQL_DRIVER_MANAGER_H) 00003 #define __INC_GQL_DRIVER_MANAGER_H 00004 00005 #include <string> 00006 #include <list> 00007 00008 #include <yehia/plugin.h> 00009 00010 #include <gql++/connection.h> 00011 #include <gql++/driver.h> 00012 00013 namespace GQL 00014 { 00015 00022 class DriverManager : public Yehia::Object 00023 { 00024 public: 00031 DriverManager(Yehia::PluginManager& mgr = Yehia::PluginManager::instance(), 00032 const std::string& area = "gql"); 00033 00035 ~DriverManager(); 00036 00045 Connection *get_connection(const std::string &url, 00046 const std::string &name = std::string(), 00047 const std::string &passwd = std::string()); 00048 00053 bool register_driver(const std::string& id); 00054 00058 void deregister_driver(const std::string& id); 00059 00062 std::list<std::string> get_registered_drivers() const; 00063 00066 const Yehia::PluginNode& get_drivers() const { return *drivers_; } 00067 00068 /* Get a driver by ID. 00069 * \return Driver with ID \p id, 0 if this driver is not registered. */ 00070 Driver *get_driver(const std::string& id); 00071 00074 bool is_auto_load() const { return auto_load_; } 00077 void set_auto_load(bool do_auto) { auto_load_ = do_auto; } 00078 00081 Yehia::PluginManager& plugin_manager() { return pm_; } 00082 private: 00083 Yehia::PluginManager& pm_; 00084 const Yehia::PluginNode *drivers_; 00085 std::string area_name_; 00086 bool auto_load_; 00087 }; 00088 00089 } 00090 00091 #endif