diff options
Diffstat (limited to 'project2/rdbmsDataSource.h')
-rw-r--r-- | project2/rdbmsDataSource.h | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/project2/rdbmsDataSource.h b/project2/rdbmsDataSource.h index 857173b..0e175e7 100644 --- a/project2/rdbmsDataSource.h +++ b/project2/rdbmsDataSource.h @@ -8,6 +8,23 @@ #include "dataSource.h" #include "../libdbpp/connection.h" #include "../libdbpp/error.h" +#include "xmlObjectLoader.h" + +/// Base class to implement DB connection type modules +class ConnectionLoader : public ComponentLoader { + public: + virtual DB::Connection * connect(const std::string & dsn) const = 0; +}; + +/// Helper implemention for specific DB types +template <class DBType> +class ConnectionLoaderImpl : public ConnectionLoader { + public: + virtual DB::Connection * connect(const std::string & dsn) const + { + return new DBType(dsn); + } +}; /// Project2 component to provide access to transactional RDBMS data sources class RdbmsDataSource : public DataSource { @@ -37,7 +54,7 @@ class RdbmsDataSource : public DataSource { private: std::string dsn; - int typeId; + boost::shared_ptr<ConnectionLoader> typeId; }; typedef boost::shared_ptr<RdbmsConnection> ConnectionPtr; |