From d5a8a14abbbdb41c753502ea25e2c327ada106f3 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 29 Nov 2012 11:32:43 +0200 Subject: Namespace management for static multi-database support Now in libodb the odb::core namespace is split into odb::common (database- independent stuff) and odb::core proper, which imports odb::common. Each database runtime now defines odb::::core namespace which also imports odb::common and adds the database-specific bits. The overall idea is that one can do using namespace odb::::core just like for odb::core. --- odb/callback.hxx | 3 ++- odb/exception.hxx | 3 ++- odb/exceptions.hxx | 3 ++- odb/forward.hxx | 21 +++++++++++++++++++-- odb/lazy-ptr.hxx | 4 ++-- odb/nullable.hxx | 4 +++- odb/prepared-query.hxx | 4 ++-- odb/result.hxx | 4 ++-- odb/schema-catalog.hxx | 4 ++-- 9 files changed, 36 insertions(+), 14 deletions(-) (limited to 'odb') diff --git a/odb/callback.hxx b/odb/callback.hxx index 20326e4..6a836e3 100644 --- a/odb/callback.hxx +++ b/odb/callback.hxx @@ -7,6 +7,7 @@ #include +#include // odb::core #include namespace odb @@ -32,7 +33,7 @@ namespace odb value v_; }; - namespace core + namespace common { using odb::callback_event; } diff --git a/odb/exception.hxx b/odb/exception.hxx index 004ed65..823d785 100644 --- a/odb/exception.hxx +++ b/odb/exception.hxx @@ -9,6 +9,7 @@ #include +#include // odb::core #include namespace odb @@ -19,7 +20,7 @@ namespace odb what () const throw () = 0; }; - namespace core + namespace common { using odb::exception; } diff --git a/odb/exceptions.hxx b/odb/exceptions.hxx index 90729fc..df14928 100644 --- a/odb/exceptions.hxx +++ b/odb/exceptions.hxx @@ -9,6 +9,7 @@ #include +#include // odb::core #include #include @@ -188,7 +189,7 @@ namespace odb std::string what_; }; - namespace core + namespace common { using odb::null_pointer; diff --git a/odb/forward.hxx b/odb/forward.hxx index 705acd3..fe23c5f 100644 --- a/odb/forward.hxx +++ b/odb/forward.hxx @@ -14,6 +14,19 @@ namespace odb { + // Common and core namespaces. The idea is that you can use the + // using directive to get database-independent (common) names or + // all core names (core). + // + namespace common {} + + namespace core + { + using namespace common; + } + + // + // class database; class connection; typedef details::shared_ptr connection_ptr; @@ -21,6 +34,11 @@ namespace odb class statement; class session; + namespace common + { + using odb::session; + } + namespace core { using odb::database; @@ -28,7 +46,6 @@ namespace odb using odb::connection_ptr; using odb::transaction; using odb::statement; - using odb::session; } // Tracing. @@ -36,7 +53,7 @@ namespace odb class tracer; // Not in core. extern LIBODB_EXPORT tracer& stderr_tracer; - namespace core + namespace common { using odb::stderr_tracer; } diff --git a/odb/lazy-ptr.hxx b/odb/lazy-ptr.hxx index 8df47b9..3de8dab 100644 --- a/odb/lazy-ptr.hxx +++ b/odb/lazy-ptr.hxx @@ -10,7 +10,7 @@ #include // std::auto_ptr, std::shared_ptr/weak_ptr #include // std::move -#include // odb::database +#include // odb::core, odb::database #include #include #include // ODB_CXX11 @@ -627,7 +627,7 @@ namespace odb #endif // ODB_CXX11 - namespace core + namespace common { using odb::lazy_ptr; using odb::lazy_auto_ptr; diff --git a/odb/nullable.hxx b/odb/nullable.hxx index e3c9bc8..565b4ee 100644 --- a/odb/nullable.hxx +++ b/odb/nullable.hxx @@ -7,6 +7,8 @@ #include +#include // odb::core + namespace odb { template @@ -52,7 +54,7 @@ namespace odb bool null_; }; - namespace core + namespace common { using odb::nullable; } diff --git a/odb/prepared-query.hxx b/odb/prepared-query.hxx index 53d8110..928f078 100644 --- a/odb/prepared-query.hxx +++ b/odb/prepared-query.hxx @@ -7,7 +7,7 @@ #include -#include +#include // odb::core #include #include #include @@ -162,7 +162,7 @@ namespace odb prepared_query_impl* impl_; }; - namespace core + namespace common { using odb::prepared_query; } diff --git a/odb/result.hxx b/odb/result.hxx index 5db08cd..d90ceb0 100644 --- a/odb/result.hxx +++ b/odb/result.hxx @@ -9,7 +9,7 @@ #include // std::ptrdiff_t, std::size_t -#include +#include // odb::core #include #include @@ -215,7 +215,7 @@ namespace odb details::shared_ptr impl_; }; - namespace core + namespace common { using odb::result; using odb::result_iterator; diff --git a/odb/schema-catalog.hxx b/odb/schema-catalog.hxx index d79d0b3..861c3d0 100644 --- a/odb/schema-catalog.hxx +++ b/odb/schema-catalog.hxx @@ -9,7 +9,7 @@ #include -#include +#include // odb::core #include @@ -22,7 +22,7 @@ namespace odb create_schema (database&, const std::string& name = ""); }; - namespace core + namespace common { using odb::schema_catalog; } -- cgit v1.1