diff options
-rw-r--r-- | project2/Doxyfile | 5 | ||||
-rw-r--r-- | project2/Jamfile.jam | 11 | ||||
-rw-r--r-- | project2/sql/Jamfile.jam | 58 | ||||
-rw-r--r-- | project2/sql/connectionLoader.cpp | 5 | ||||
-rw-r--r-- | project2/sql/connectionLoader.h | 10 | ||||
-rw-r--r-- | project2/sql/mockDatasource.cpp | 7 | ||||
-rw-r--r-- | project2/sql/mockDatasource.h | 3 | ||||
-rw-r--r-- | project2/sql/pch.hpp | 1 | ||||
-rw-r--r-- | project2/sql/rdbmsDataSource.cpp | 6 | ||||
-rw-r--r-- | project2/sql/rdbmsDataSource.h | 3 | ||||
-rw-r--r-- | project2/sql/unittests/Jamfile.jam | 53 |
11 files changed, 11 insertions, 151 deletions
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 : : : : <include>/usr/include/adhocutil ; alias p2parts : : : : @@ -21,10 +16,6 @@ alias p2parts : : : : <library>compression//p2compression <library>streams//p2streams <library>basics//p2basics - <odbc>yes:<library>sql//p2sqlmodODBC - <pq>yes:<library>sql//p2sqlmodPQ - <mysql>yes:<library>sql//p2sqlmodMySQL - <sqlite>yes:<library>sql//p2sqlmodSQLite ; alias p2daemonparts : : : : @@ -45,6 +36,4 @@ build-project files//unittests ; explicit install ; package.install install : : finalbin : finallib ; -package.install installheaders : <install-source-root>. : : : [ 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 : : : : <cflags>"`pkg-config --cflags glibmm-2.4`" <linkflags>"`pkg-config --libs glibmm-2.4`" ; lib boost_filesystem ; -lib fl ; +lib dbppcore : : : : <include>/usr/include/dbpp ; build-project unittests ; -explicit library p2sqlmodMySQL ; -lib p2sqlmodMySQL : - sql-modMySQL.cpp : - <library>../../libmysqlpp//mysqlpp - <library>glibmm - <library>../common//p2common - <library>p2sql - : : - <library>../../libmysqlpp//mysqlpp - ; - -explicit library p2sqlmodSQLite ; -lib p2sqlmodSQLite : - sql-modSQLite.cpp : - <library>../../libsqlitepp//sqlitepp - <library>glibmm - <library>../common//p2common - <library>p2sql - <library>boost_filesystem - : : - <library>../../libsqlitepp//sqlitepp - ; - -explicit library p2sqlmodODBC ; -lib p2sqlmodODBC : - sql-modODBC.cpp : - <library>../../libodbcpp//odbcpp - <library>glibmm - <library>../common//p2common - <library>p2sql - : : - <library>../../libodbcpp//odbcpp - ; - -explicit library p2sqlmodPQ ; -lib p2sqlmodPQ : - sql-modPQ.cpp : - <library>../../libpqpp//pqpp - <library>glibmm - <library>../common//p2common - <library>p2sql - : : - <library>../../libpqpp//pqpp - ; - cpp-pch pch : pch.hpp : - <include>../../libdbpp + <library>dbppcore <library>glibmm <library>../common//p2common ; lib p2sql : pch - sql.ll - [ glob *.cpp : sql-mod*.cpp ] - ../../libdbpp//dbpp + [ glob *.cpp : mockDatasource.cpp ] : <include>. + <library>dbppcore <library>glibmm <library>boost_filesystem <library>../common//p2common <library>../basics//p2basics <library>..//adhocutil - <library>fl : : <include>. + <library>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 <connection.h> - -typedef GenLoader<DB::Connection, std::string, std::string> 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 <connection.h> #include <safeMapFind.h> -DECLARE_CUSTOM_COMPONENT_LOADER("mock", T, MockConnectionLoader, ConnectionLoader); - -std::map<std::string, const MockDatabase *> MockConnectionLoader::mocks; -unsigned int MockConnectionLoader::mocked = 0; +NAMEDFACTORY("mock", MockDatabase, DB::ConnectionFactory); DB::Connection * MockConnectionLoader::create(const std::string & n) const { - return AdHoc::safeMapFind<std::runtime_error>(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<std::string, const MockDatabase *> 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 <pch.hpp> #include "rdbmsDataSource.h" -#include "connectionLoader.h" #include <sys/utsname.h> #include "logger.h" #include "scripts.h" #include <errno.h> -SimpleMessageException(UnknownConnectionProvider); #define LOCK(l) std::lock_guard<std::mutex> _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<std::string>()), - typeId(InstanceMap<ConnectionLoader, std::string>::Get<UnknownConnectionProvider>(node->value("provider", NULL))) + typeId(node->value("provider", NULL).as<std::string>()) { } 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 <connection.h> #include <error.h> #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<ConnectionLoader> typeId; + const std::string typeId; }; typedef std::map<std::string, ConnectionInfo> 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 - : - <library>../../ut//p2ut - <library>../../common//p2common - <library>boost_filesystem - <define>ROOT=\"$(me)\" - : : - <library>../../common//p2common - <library>../../basics//p2basics - <library>../../ut//p2ut - <library>../..//adhocutil - <library>../../xml//p2xml - <library>..//p2sql - <library>boost_system - <library>boost_filesystem - <library>../../ut//boost_utf - <define>ROOT=\"$(me)\" - <define>BOOST_TEST_DYN_LINK - ; - -run - testpq.cpp - : : : - <library>sqlTestCore - <library>..//p2sqlmodPQ - <dependency>pqschema.sql - : testpq ; - -run - testsqlite.cpp - : : : - <library>sqlTestCore - <library>..//p2sqlmodSQLite - <dependency>sqliteschema.sql - : testsqlite ; - -run - testmysql.cpp - : : : - <library>sqlTestCore - <library>..//p2sqlmodMySQL - <dependency>mysqlschema.sql - : testmysql ; - -run - testodbc.cpp - : : : - <library>sqlTestCore - <library>..//p2sqlmodODBC - <dependency>odbcschema.sql - : testodbc ; - |