diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2012-10-08 16:09:08 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2012-10-08 16:09:08 +0200 |
commit | 4eb0df751704345ec8744fe012e64064d5cdb754 (patch) | |
tree | 8043a94c33c5938073acce7137560a765efcaf1f /odb/relational/common.cxx | |
parent | 2731c14f6b16b8b40eb9b1c9061e6e296f3d49f8 (diff) |
Ground work for multi-database support
All generated code now includes database id. The database-specific
database class interface has been updated to include all the database
operations. The database-specific tests now use this interface.
Diffstat (limited to 'odb/relational/common.cxx')
-rw-r--r-- | odb/relational/common.cxx | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/odb/relational/common.cxx b/odb/relational/common.cxx index 3916184..e9b3485 100644 --- a/odb/relational/common.cxx +++ b/odb/relational/common.cxx @@ -88,8 +88,8 @@ namespace relational { string const& fq_name (class_fq_name (c)); string guard ( - make_guard ( - "ODB_ALIAS_TRAITS_" + alias + "_FOR_" + flat_name (fq_name))); + make_guard ("ODB_" + string (db.string ()) + "_ALIAS_TRAITS_" + + alias + "_FOR_" + flat_name (fq_name))); if (specs_.find (guard) != specs_.end ()) return; @@ -107,19 +107,20 @@ namespace relational << "#define " << guard << endl; os << "template <bool d>" << endl - << "struct alias_traits< " << fq_name << ", " << tag << ", d >" + << "struct alias_traits< " << fq_name << ", id_" << db << ", " << + tag << ", d >" << "{" << "static const char table_name[];"; if (poly_derived) os << "typedef alias_traits< " << class_fq_name (*poly_base) << ", " << - tag << " > base_traits;"; + "id_" << db << ", " << tag << " > base_traits;"; os << "};"; os << "template <bool d>" << endl - << "const char alias_traits< " << fq_name << ", " << tag << - ", d >::" << endl + << "const char alias_traits< " << fq_name << ", id_" << db << ", " << + tag << ", d >::" << endl << "table_name[] = "; if (poly_root != 0) @@ -146,7 +147,8 @@ namespace relational query_columns_base (semantics::class_& c) //@@ context::{cur,top}_object : decl_ (false) { - scope_ = "query_columns_base< " + class_fq_name (c) + " >"; + scope_ = "query_columns_base< " + class_fq_name (c) + ", id_" + + db.string () + " >"; } void query_columns_base:: @@ -244,7 +246,8 @@ namespace relational string const& fq_name (class_fq_name (c)); os << "typedef" << endl - << "odb::alias_traits< " << fq_name << ", " << tag << " >" << endl + << "odb::alias_traits< " << fq_name << ", id_" << db << ", " << + tag << " >" << endl << name << "_alias_;" << endl; @@ -254,6 +257,7 @@ namespace relational << "odb::query_pointer<" << endl << " odb::pointer_query_columns<" << endl << " " << fq_name << "," << endl + << " id_" << db << "," << endl << " " << name << "_alias_ > >" << endl << name << "_type_ ;" << endl @@ -284,7 +288,7 @@ namespace relational : ptr_ (ptr), decl_ (false), in_ptr_ (false) { scope_ = ptr ? "pointer_query_columns" : "query_columns"; - scope_ += "< " + class_fq_name (c) + ", A >"; + scope_ += "< " + class_fq_name (c) + ", id_" + db.string () + ", A >"; } void query_columns:: @@ -474,6 +478,7 @@ namespace relational << "odb::query_pointer<" << endl << " odb::pointer_query_columns<" << endl << " " << class_fq_name (c) << "," << endl + << " id_" << db << "," << endl << " " << name << "_alias_ > >" << endl << name << "_pointer_type_;" << endl; @@ -519,6 +524,7 @@ namespace relational << "odb::query_pointer<" << endl << " odb::pointer_query_columns<" << endl << " " << class_fq_name (c) << "," << endl + << " id_" << db << "," << endl << " " << name << "_alias_ > >" << endl << name << "_pointer_type_;" << endl; |