From 692a2ff996cf34fc570b1804da8b37fd8157497c Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Fri, 25 Sep 2015 21:39:24 +0100 Subject: Use system dbpp and autoloaded connectors. Breaks and disables Project2 mock datasources --- project2/Doxyfile | 5 +--- project2/Jamfile.jam | 11 -------- project2/sql/Jamfile.jam | 58 ++++---------------------------------- project2/sql/connectionLoader.cpp | 5 ---- project2/sql/connectionLoader.h | 10 ------- project2/sql/mockDatasource.cpp | 7 ++--- project2/sql/mockDatasource.h | 3 -- project2/sql/pch.hpp | 1 - project2/sql/rdbmsDataSource.cpp | 6 ++-- project2/sql/rdbmsDataSource.h | 3 +- project2/sql/unittests/Jamfile.jam | 53 ---------------------------------- 11 files changed, 11 insertions(+), 151 deletions(-) delete mode 100644 project2/sql/connectionLoader.cpp delete mode 100644 project2/sql/connectionLoader.h diff --git a/project2/Doxyfile b/project2/Doxyfile index 8c2cb5f..0de5676 100644 --- a/project2/Doxyfile +++ b/project2/Doxyfile @@ -612,10 +612,7 @@ WARN_LOGFILE = # directories like "/usr/src/myproject". Separate the files or directories # with spaces. -INPUT = . \ - ../libdbpp \ - ../libpqpp \ - ../libodbcpp +INPUT = . # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is diff --git a/project2/Jamfile.jam b/project2/Jamfile.jam index 6779ba8..5b03778 100644 --- a/project2/Jamfile.jam +++ b/project2/Jamfile.jam @@ -1,11 +1,6 @@ import package ; import feature : feature ; -feature odbc : yes no : propagated ; -feature pq : yes no : propagated ; -feature mysql : yes no : propagated ; -feature sqlite : yes no : propagated ; - lib adhocutil : : : : /usr/include/adhocutil ; alias p2parts : : : : @@ -21,10 +16,6 @@ alias p2parts : : : : compression//p2compression streams//p2streams basics//p2basics - yes:sql//p2sqlmodODBC - yes:sql//p2sqlmodPQ - yes:sql//p2sqlmodMySQL - yes:sql//p2sqlmodSQLite ; alias p2daemonparts : : : : @@ -45,6 +36,4 @@ build-project files//unittests ; explicit install ; package.install install : : finalbin : finallib ; -package.install installheaders : . : : : [ glob-tree *.h ] ; -package.install installheadersdb : : : : [ glob ../libdbpp/*.h ] ; diff --git a/project2/sql/Jamfile.jam b/project2/sql/Jamfile.jam index 4bf1088..004b0b5 100644 --- a/project2/sql/Jamfile.jam +++ b/project2/sql/Jamfile.jam @@ -1,79 +1,31 @@ -import lex ; - alias glibmm : : : : "`pkg-config --cflags glibmm-2.4`" "`pkg-config --libs glibmm-2.4`" ; lib boost_filesystem ; -lib fl ; +lib dbppcore : : : : /usr/include/dbpp ; build-project unittests ; -explicit library p2sqlmodMySQL ; -lib p2sqlmodMySQL : - sql-modMySQL.cpp : - ../../libmysqlpp//mysqlpp - glibmm - ../common//p2common - p2sql - : : - ../../libmysqlpp//mysqlpp - ; - -explicit library p2sqlmodSQLite ; -lib p2sqlmodSQLite : - sql-modSQLite.cpp : - ../../libsqlitepp//sqlitepp - glibmm - ../common//p2common - p2sql - boost_filesystem - : : - ../../libsqlitepp//sqlitepp - ; - -explicit library p2sqlmodODBC ; -lib p2sqlmodODBC : - sql-modODBC.cpp : - ../../libodbcpp//odbcpp - glibmm - ../common//p2common - p2sql - : : - ../../libodbcpp//odbcpp - ; - -explicit library p2sqlmodPQ ; -lib p2sqlmodPQ : - sql-modPQ.cpp : - ../../libpqpp//pqpp - glibmm - ../common//p2common - p2sql - : : - ../../libpqpp//pqpp - ; - cpp-pch pch : pch.hpp : - ../../libdbpp + dbppcore glibmm ../common//p2common ; lib p2sql : pch - sql.ll - [ glob *.cpp : sql-mod*.cpp ] - ../../libdbpp//dbpp + [ glob *.cpp : mockDatasource.cpp ] : . + dbppcore glibmm boost_filesystem ../common//p2common ../basics//p2basics ..//adhocutil - fl : : . + dbppcore ; diff --git a/project2/sql/connectionLoader.cpp b/project2/sql/connectionLoader.cpp deleted file mode 100644 index 671fafc..0000000 --- a/project2/sql/connectionLoader.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include "connectionLoader.h" -#include "instanceStore.impl.h" - -INSTANTIATESTORE(std::string, ConnectionLoader); - diff --git a/project2/sql/connectionLoader.h b/project2/sql/connectionLoader.h deleted file mode 100644 index 3a8714c..0000000 --- a/project2/sql/connectionLoader.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef CONNECTIONLOADER_H -#define CONNECTIONLOADER_H - -#include "genLoader.h" -#include - -typedef GenLoader ConnectionLoader; - -#endif - diff --git a/project2/sql/mockDatasource.cpp b/project2/sql/mockDatasource.cpp index 6c281e1..5beb963 100644 --- a/project2/sql/mockDatasource.cpp +++ b/project2/sql/mockDatasource.cpp @@ -2,14 +2,11 @@ #include #include -DECLARE_CUSTOM_COMPONENT_LOADER("mock", T, MockConnectionLoader, ConnectionLoader); - -std::map MockConnectionLoader::mocks; -unsigned int MockConnectionLoader::mocked = 0; +NAMEDFACTORY("mock", MockDatabase, DB::ConnectionFactory); DB::Connection * MockConnectionLoader::create(const std::string & n) const { - return AdHoc::safeMapFind(mocks, n)->second->openConnection(); + return DB::MockDatabase::openConnectionTo(n); } diff --git a/project2/sql/mockDatasource.h b/project2/sql/mockDatasource.h index ee1e976..ed58027 100644 --- a/project2/sql/mockDatasource.h +++ b/project2/sql/mockDatasource.h @@ -7,9 +7,6 @@ class MockConnectionLoader : public ConnectionLoader { public: DB::Connection * create(const std::string &) const; - - static unsigned int mocked; - static std::map mocks; }; #endif diff --git a/project2/sql/pch.hpp b/project2/sql/pch.hpp index 2d8e99b..e3dcda2 100644 --- a/project2/sql/pch.hpp +++ b/project2/sql/pch.hpp @@ -7,7 +7,6 @@ #include "columns.h" #include "command.h" #include "commonObjects.h" -#include "connectionLoader.h" #include "exceptions.h" #include "iHaveParameters.h" #include "logger.h" diff --git a/project2/sql/rdbmsDataSource.cpp b/project2/sql/rdbmsDataSource.cpp index b0989b9..1e2778b 100644 --- a/project2/sql/rdbmsDataSource.cpp +++ b/project2/sql/rdbmsDataSource.cpp @@ -1,12 +1,10 @@ #include #include "rdbmsDataSource.h" -#include "connectionLoader.h" #include #include "logger.h" #include "scripts.h" #include -SimpleMessageException(UnknownConnectionProvider); #define LOCK(l) std::lock_guard _lock##l(l) /// Specialized ElementLoader for instances of RdbmsDataSource; handles persistent DB connections @@ -246,14 +244,14 @@ RdbmsDataSource::RdbmsConnection::isExpired() const RdbmsDataSource::ConnectionInfo::ConnectionInfo(ScriptNodePtr node) : dsn(node->value("dsn", NULL).as()), - typeId(InstanceMap::Get(node->value("provider", NULL))) + typeId(node->value("provider", NULL).as()) { } DB::Connection * RdbmsDataSource::ConnectionInfo::connect() const { - return typeId->create(dsn); + return DB::ConnectionFactory::create(typeId, dsn); } bool diff --git a/project2/sql/rdbmsDataSource.h b/project2/sql/rdbmsDataSource.h index e347961..4b7763f 100644 --- a/project2/sql/rdbmsDataSource.h +++ b/project2/sql/rdbmsDataSource.h @@ -10,7 +10,6 @@ #include #include #include "scriptLoader.h" -#include "connectionLoader.h" /// Project2 component to provide access to transactional RDBMS data sources class RdbmsDataSource : public DataSource { @@ -62,7 +61,7 @@ class RdbmsDataSource : public DataSource { bool operator<(const ConnectionInfo & o) const; const std::string dsn; - const boost::shared_ptr typeId; + const std::string typeId; }; typedef std::map ReadonlyDSNs; // Map hostname to DSN string diff --git a/project2/sql/unittests/Jamfile.jam b/project2/sql/unittests/Jamfile.jam index d59a62e..7b45800 100644 --- a/project2/sql/unittests/Jamfile.jam +++ b/project2/sql/unittests/Jamfile.jam @@ -7,56 +7,3 @@ lib Ice ; path-constant me : . ; -lib sqlTestCore : - testCore.cpp - : - ../../ut//p2ut - ../../common//p2common - boost_filesystem - ROOT=\"$(me)\" - : : - ../../common//p2common - ../../basics//p2basics - ../../ut//p2ut - ../..//adhocutil - ../../xml//p2xml - ..//p2sql - boost_system - boost_filesystem - ../../ut//boost_utf - ROOT=\"$(me)\" - BOOST_TEST_DYN_LINK - ; - -run - testpq.cpp - : : : - sqlTestCore - ..//p2sqlmodPQ - pqschema.sql - : testpq ; - -run - testsqlite.cpp - : : : - sqlTestCore - ..//p2sqlmodSQLite - sqliteschema.sql - : testsqlite ; - -run - testmysql.cpp - : : : - sqlTestCore - ..//p2sqlmodMySQL - mysqlschema.sql - : testmysql ; - -run - testodbc.cpp - : : : - sqlTestCore - ..//p2sqlmodODBC - odbcschema.sql - : testodbc ; - -- cgit v1.2.3