aboutsummaryrefslogtreecommitdiff
path: root/odb
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2012-10-08 16:09:08 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2012-10-08 16:09:08 +0200
commit4eb0df751704345ec8744fe012e64064d5cdb754 (patch)
tree8043a94c33c5938073acce7137560a765efcaf1f /odb
parent2731c14f6b16b8b40eb9b1c9061e6e296f3d49f8 (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')
-rw-r--r--odb/relational/common.cxx24
-rw-r--r--odb/relational/header.cxx319
-rw-r--r--odb/relational/header.hxx92
-rw-r--r--odb/relational/inline.hxx82
-rw-r--r--odb/relational/mssql/common.cxx3
-rw-r--r--odb/relational/mysql/common.cxx3
-rw-r--r--odb/relational/mysql/source.cxx2
-rw-r--r--odb/relational/oracle/common.cxx3
-rw-r--r--odb/relational/pgsql/common.cxx3
-rw-r--r--odb/relational/pgsql/source.cxx6
-rw-r--r--odb/relational/schema.hxx4
-rw-r--r--odb/relational/source.cxx27
-rw-r--r--odb/relational/source.hxx80
-rw-r--r--odb/relational/sqlite/common.cxx3
-rw-r--r--odb/relational/sqlite/source.cxx2
15 files changed, 401 insertions, 252 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;
diff --git a/odb/relational/header.cxx b/odb/relational/header.cxx
index 538962b..41b4960 100644
--- a/odb/relational/header.cxx
+++ b/odb/relational/header.cxx
@@ -41,23 +41,6 @@ traverse_object (type& c)
<< "static const class_kind kind = class_object;"
<< "};";
- // pointer_query_columns & query_columns
- //
- if (options.generate_query ())
- {
- // If we don't have object pointers, then also generate
- // query_columns (in this case pointer_query_columns and
- // query_columns are the same and the former inherits from
- // the latter). Otherwise we have to postpone query_columns
- // generation until the second pass to deal with forward-
- // declared objects.
- //
- if (!has_a (c, test_pointer | include_base))
- query_columns_type_->traverse (c);
-
- pointer_query_columns_type_->traverse (c);
- }
-
// object_traits
//
os << "template <>" << endl
@@ -65,8 +48,6 @@ traverse_object (type& c)
<< "{"
<< "public:" << endl;
- object_public_extra_pre (c);
-
// object_type & pointer_type
//
os << "typedef " << type << " object_type;"
@@ -76,31 +57,30 @@ traverse_object (type& c)
// polymorphic, root_type, base_type, etc.
//
- os << "static const bool polymorphic = " << (poly ? "true" : "false") << ";";
+ os << "static const bool polymorphic = " << (poly ? "true" : "false") << ";"
+ << endl;
if (poly)
{
- os << "typedef " << class_fq_name (*poly_root) << " root_type;"
- << "typedef object_traits<root_type> root_traits;";
+ os << "typedef " << class_fq_name (*poly_root) << " root_type;";
if (poly_derived)
{
os << "typedef " << class_fq_name (*poly_base) << " base_type;"
- << "typedef object_traits<base_type> base_traits;"
- << "typedef root_traits::discriminator_type discriminator_type;"
- << "typedef odb::polymorphic_concrete_info<root_type> info_type;";
+ << "typedef object_traits<root_type>::discriminator_type " <<
+ "discriminator_type;"
+ << "typedef polymorphic_concrete_info<root_type> info_type;";
if (abst)
- os << "typedef odb::polymorphic_abstract_info<root_type> " <<
+ os << "typedef polymorphic_abstract_info<root_type> " <<
"abstract_info_type;";
- else
- os << "typedef odb::polymorphic_entry<object_type> entry_type;";
// Calculate our hierarchy depth (number of classes).
//
size_t depth (polymorphic_depth (c));
- os << "static const std::size_t depth = " << depth << "UL;";
+ os << endl
+ << "static const std::size_t depth = " << depth << "UL;";
}
else
{
@@ -108,35 +88,21 @@ traverse_object (type& c)
semantics::type& t (utype (*discriminator, hint));
os << "typedef " << t.fq_name (hint) << " discriminator_type;"
- << endl;
-
- os << "struct discriminator_image_type"
- << "{";
-
- discriminator_image_member_->traverse (*discriminator);
-
- if (optimistic != 0)
- version_image_member_->traverse (*optimistic);
-
- os << "std::size_t version;"
- << "};";
-
- os << "typedef odb::polymorphic_map<object_type> map_type;"
- << "typedef odb::polymorphic_concrete_info<object_type> info_type;";
+ << "typedef polymorphic_map<object_type> map_type;"
+ << "typedef polymorphic_concrete_info<object_type> info_type;";
if (abst)
- os << "typedef odb::polymorphic_abstract_info<object_type> " <<
+ os << "typedef polymorphic_abstract_info<object_type> " <<
"abstract_info_type;";
- else
- os << "typedef odb::polymorphic_entry<object_type> entry_type;";
- os << "static const std::size_t depth = 1UL;";
+ os << endl
+ << "static const std::size_t depth = 1UL;";
}
- }
- os << endl;
+ os << endl;
+ }
- // id_type & id_image_type
+ // id_type, version_type, etc.
//
if (id != 0)
{
@@ -152,17 +118,13 @@ traverse_object (type& c)
os << "typedef object_traits< " << type << " >::version_type " <<
"version_type;";
+ os << endl;
+
if (poly_derived)
- os << "typedef object_traits< " << type << " >:: id_image_type " <<
- "id_image_type;"
- << "static const bool auto_id = false;"
- << endl;
+ os << "static const bool auto_id = false;";
else
- os << "typedef object_traits< " << type << " >::id_image_type " <<
- "id_image_type;"
- << "static const bool auto_id = object_traits< " << type <<
- " >::auto_id;"
- << endl;
+ os << "static const bool auto_id = object_traits< " << type <<
+ " >::auto_id;";
}
else
{
@@ -179,26 +141,18 @@ traverse_object (type& c)
os << "typedef " << t.fq_name (hint) << " version_type;";
}
- os << "static const bool auto_id = " << (auto_id ? "true;" : "false;")
- << endl;
-
- os << "struct id_image_type"
- << "{";
-
- id_image_member_->traverse (*id);
-
- if (optimistic != 0)
- version_image_member_->traverse (*optimistic);
-
- os << "std::size_t version;"
- << "};";
+ os << endl
+ << "static const bool auto_id = " << (auto_id ? "true;" : "false;");
}
+
+ os << endl;
}
else if (!reuse_abst)
{
// Object without id.
//
os << "typedef void id_type;"
+ << endl
<< "static const bool auto_id = false;"
<< endl;
}
@@ -208,6 +162,157 @@ traverse_object (type& c)
os << "static const bool abstract = " << (abst ? "true" : "false") << ";"
<< endl;
+ // id ()
+ //
+ if (id != 0 || !reuse_abst)
+ {
+ // We want to generate a dummy void id() accessor even if this
+ // object has no id to help us in the runtime. This way we can
+ // write generic code that will work for both void and non-void
+ // ids.
+ //
+ os << "static id_type" << endl
+ << "id (const object_type&);"
+ << endl;
+ }
+
+ if (!reuse_abst)
+ {
+ // Cache traits typedefs.
+ //
+ if (id == 0)
+ {
+ os << "typedef" << endl
+ << "no_id_pointer_cache_traits<pointer_type>" << endl
+ << "pointer_cache_traits;"
+ << endl
+ << "typedef" << endl
+ << "no_id_reference_cache_traits<object_type>" << endl
+ << "reference_cache_traits;"
+ << endl;
+ }
+ else
+ {
+ char const* p (session (c) ? "odb::" : "no_op_");
+
+ if (poly_derived)
+ {
+ os << "typedef" << endl
+ << p << "pointer_cache_traits<" <<
+ "object_traits<root_type>::pointer_type>" << endl
+ << "pointer_cache_traits;"
+ << endl
+ << "typedef" << endl
+ << p << "reference_cache_traits<root_type>" << endl
+ << "reference_cache_traits;"
+ << endl;
+ }
+ else
+ {
+ os << "typedef" << endl
+ << p << "pointer_cache_traits<pointer_type>" << endl
+ << "pointer_cache_traits;"
+ << endl
+ << "typedef" << endl
+ << p << "reference_cache_traits<object_type>" << endl
+ << "reference_cache_traits;"
+ << endl;
+ }
+ }
+ }
+
+ os << "};";
+
+ // pointer_query_columns & query_columns
+ //
+ if (options.generate_query ())
+ {
+ // If we don't have object pointers, then also generate
+ // query_columns (in this case pointer_query_columns and
+ // query_columns are the same and the former inherits from
+ // the latter). Otherwise we have to postpone query_columns
+ // generation until the second pass to deal with forward-
+ // declared objects.
+ //
+ if (!has_a (c, test_pointer | include_base))
+ query_columns_type_->traverse (c);
+
+ pointer_query_columns_type_->traverse (c);
+ }
+
+ // object_traits_impl
+ //
+ os << "template <>" << endl
+ << "class access::object_traits_impl< " << type << ", id_" << db <<
+ " >:" << endl
+ << " public access::object_traits< " << type << " >"
+ << "{"
+ << "public:" << endl;
+
+ object_public_extra_pre (c);
+
+ // Polymorphic root_traits, base_traits, and discriminator_image_type.
+ //
+ if (poly)
+ {
+ if (!abst)
+ os << "typedef polymorphic_entry<object_type, id_" << db <<
+ "> entry_type;";
+
+ os << "typedef object_traits_impl<root_type, id_" << db << "> " <<
+ "root_traits;";
+
+ if (poly_derived)
+ {
+ os << "typedef object_traits_impl<base_type, id_" << db << "> " <<
+ "base_traits;"
+ << endl;
+ }
+ else
+ {
+ os << endl
+ << "struct discriminator_image_type"
+ << "{";
+
+ discriminator_image_member_->traverse (*discriminator);
+
+ if (optimistic != 0)
+ version_image_member_->traverse (*optimistic);
+
+ os << "std::size_t version;"
+ << "};";
+ }
+ }
+
+ // id_image_type
+ //
+ if (id != 0)
+ {
+ if (base_id)
+ {
+ semantics::class_& b (
+ dynamic_cast<semantics::class_&> (id->scope ()));
+ string const& type ();
+
+ os << "typedef object_traits_impl< " << class_fq_name (b) << ", " <<
+ "id_" << db << " >::id_image_type id_image_type;"
+ << endl;
+ }
+ else
+ {
+ os << "struct id_image_type"
+ << "{";
+
+ id_image_member_->traverse (*id);
+
+ if (optimistic != 0)
+ version_image_member_->traverse (*optimistic);
+
+ os << "std::size_t version;"
+ << "};";
+ }
+ }
+
// Polymorphic map.
//
if (poly)
@@ -236,19 +341,9 @@ traverse_object (type& c)
// Functions (abstract and concrete).
//
- // id ()
- //
if (id != 0 || !reuse_abst)
- {
- // We want to generate a dummy void id() accessor even if this
- // object has no id to help us in the runtime. This way we can
- // write generic code that will work for both void and non-void
- // ids.
- //
- os << "static id_type" << endl
- << "id (const object_type&);"
+ os << "using object_traits<object_type>::id;"
<< endl;
- }
if (!poly_derived && id != 0)
{
@@ -370,45 +465,6 @@ traverse_object (type& c)
return;
}
- // Cache traits typedefs.
- //
- if (id == 0)
- {
- os << "typedef" << endl
- << "odb::no_id_pointer_cache_traits<pointer_type>" << endl
- << "pointer_cache_traits;"
- << "typedef" << endl
- << "odb::no_id_reference_cache_traits<object_type>" << endl
- << "reference_cache_traits;"
- << endl;
- }
- else
- {
- char const* p (session (c) ? "" : "no_op_");
-
- if (poly_derived)
- {
- os << "typedef" << endl
- << "odb::" << p << "pointer_cache_traits<" <<
- "root_traits::pointer_type>" << endl
- << "pointer_cache_traits;"
- << "typedef" << endl
- << "odb::" << p << "reference_cache_traits<root_type>" << endl
- << "reference_cache_traits;"
- << endl;
- }
- else
- {
- os << "typedef" << endl
- << "odb::" << p << "pointer_cache_traits<pointer_type>" << endl
- << "pointer_cache_traits;"
- << "typedef" << endl
- << "odb::" << p << "reference_cache_traits<object_type>" << endl
- << "reference_cache_traits;"
- << endl;
- }
- }
-
// Statements typedefs.
//
if (poly)
@@ -418,6 +474,7 @@ traverse_object (type& c)
<< db << "::polymorphic_derived_object_statements" <<
"<object_type>" << endl
<< "statements_type;"
+ << endl
<< "typedef" << endl
<< db << "::polymorphic_root_object_statements<root_type>" << endl
<< "root_statements_type;"
@@ -426,6 +483,7 @@ traverse_object (type& c)
os << "typedef" << endl
<< db << "::polymorphic_root_object_statements<object_type>" << endl
<< "statements_type;"
+ << endl
<< "typedef statements_type root_statements_type;"
<< "typedef " << db << "::object_statements<object_type> " <<
"base_statements_type;"
@@ -451,7 +509,7 @@ traverse_object (type& c)
{
// query_base_type
//
- os << "typedef " << db << "::query query_base_type;"
+ os << "typedef " << db << "::query_base query_base_type;"
<< endl;
}
@@ -736,6 +794,19 @@ traverse_object (type& c)
}
os << "};";
+
+
+ // object_traits_impl< , id_default>
+ //
+ // Note that it is not generated for reuse-abstract classes.
+ //
+ os << "template <>" << endl
+ << "class access::object_traits_impl< " << type << ", " <<
+ "id_default >:" << endl
+ << " public access::object_traits_impl< " << type << ", " <<
+ "id_" << db << " >"
+ << "{"
+ << "};";
}
void relational::header::
diff --git a/odb/relational/header.hxx b/odb/relational/header.hxx
index 25f9480..9d932ae 100644
--- a/odb/relational/header.hxx
+++ b/odb/relational/header.hxx
@@ -64,9 +64,11 @@ namespace relational
string const& type (class_fq_name (c));
if (obj)
- os << "object_traits< " << type << " >::image_type";
+ os << "object_traits_impl< " << type << ", id_" << db <<
+ " >::image_type";
else
- os << "composite_value_traits< " << type << " >::image_type";
+ os << "composite_value_traits< " << type << ", id_" << db <<
+ " >::image_type";
}
private:
@@ -117,7 +119,7 @@ namespace relational
os << "{";
if (poly_derived)
- os << "object_traits<base_type>::image_type* base;"
+ os << "base_traits::image_type* base;"
<< endl;
names (c);
@@ -173,7 +175,7 @@ namespace relational
}
os << (ptr_ ? "pointer_query_columns" : "query_columns") << "< " <<
- class_fq_name (c) << ", ";
+ class_fq_name (c) << ", id_" << db << ", ";
// If our base is polymorphic, then it has its own table/alias.
//
@@ -213,7 +215,7 @@ namespace relational
<< "//" << endl
<< "typedef " <<
(ptr_ ? "pointer_query_columns" : "query_columns") << "< " <<
- class_fq_name (c) << ", ";
+ class_fq_name (c) << ", id_" << db << ", ";
if (polymorphic (c))
os << "typename A::base_traits";
@@ -246,7 +248,8 @@ namespace relational
if (ptr_)
{
os << "template <typename A>" << endl
- << "struct pointer_query_columns< " << type << ", A >";
+ << "struct pointer_query_columns< " << type << ", id_" << db <<
+ ", A >";
// If we don't have pointers (in the whole hierarchy), then
// pointer_query_columns and query_columns are the same.
@@ -254,7 +257,7 @@ namespace relational
if (!has_a (c, test_pointer | include_base))
{
os << ":" << endl
- << " query_columns< " << type << ", A >"
+ << " query_columns< " << type << ", id_" << db << ", A >"
<< "{"
<< "};";
}
@@ -298,7 +301,8 @@ namespace relational
// table alias (A) template argument.
//
os << "template <>" << endl
- << "struct query_columns_base< " << type << " >"
+ << "struct query_columns_base< " << type << ", id_" <<
+ db << " >"
<< "{";
instance<query_columns_base> t;
@@ -308,11 +312,11 @@ namespace relational
}
os << "template <typename A>" << endl
- << "struct query_columns< " << type << ", A >";
+ << "struct query_columns< " << type << ", id_" << db << ", A >";
if (has_ptr)
os << ":" << endl
- << " query_columns_base< " << type << " >";
+ << " query_columns_base< " << type << ", id_" << db << " >";
{
instance<query_columns_bases> b (ptr_, !has_ptr);
@@ -540,10 +544,11 @@ namespace relational
string const& type (class_fq_name (b));
if (object (b))
- os << ": access::object_traits< " << type << " >::" << name;
+ os << ": access::object_traits_impl< " << type << ", id_" <<
+ db << " >::" << name;
else
- os << ": access::composite_value_traits< " << type << " >::" <<
- public_name (m) << "_traits"; // No prefix_.
+ os << ": access::composite_value_traits< " << type << ", id_" <<
+ db << " >::" << public_name (m) << "_traits"; // No prefix_.
}
os << "{";
@@ -1012,24 +1017,38 @@ namespace relational
os << "// " << class_name (c) << endl
<< "//" << endl;
+ // class_traits
+ //
os << "template <>" << endl
<< "struct class_traits< " << type << " >"
<< "{"
<< "static const class_kind kind = class_view;"
<< "};";
+ // view_traits
+ //
os << "template <>" << endl
<< "class access::view_traits< " << type << " >"
<< "{"
<< "public:" << endl;
- view_public_extra_pre (c);
-
// view_type & pointer_type
//
os << "typedef " << type << " view_type;"
- << "typedef " << c.get<string> ("object-pointer") << " pointer_type;"
- << endl;
+ << "typedef " << c.get<string> ("object-pointer") << " pointer_type;";
+
+ os << "};";
+
+ // view_traits_impl
+ //
+ os << "template <>" << endl
+ << "class access::view_traits_impl< " << type << ", id_" <<
+ db << " >:" << endl
+ << " public access::view_traits< " << type << " >"
+ << "{"
+ << "public:" << endl;
+
+ view_public_extra_pre (c);
// image_type
//
@@ -1041,7 +1060,7 @@ namespace relational
// query_base_type and query_columns (definition generated by class2).
//
- os << "typedef " << db << "::query query_base_type;"
+ os << "typedef " << db << "::query_base query_base_type;"
<< "struct query_columns";
if (c.get<size_t> ("object-count") == 0)
@@ -1112,6 +1131,16 @@ namespace relational
view_public_extra_post (c);
os << "};";
+
+ // view_traits_impl< , id_default>
+ //
+ os << "template <>" << endl
+ << "class access::view_traits_impl< " << type << ", " <<
+ "id_default >:" << endl
+ << " public access::view_traits_impl< " << type << ", " <<
+ "id_" << db << " >"
+ << "{"
+ << "};";
}
virtual void
@@ -1129,7 +1158,8 @@ namespace relational
<< "};";
os << "template <>" << endl
- << "class access::composite_value_traits< " << type << " >"
+ << "class access::composite_value_traits< " << type << ", " <<
+ "id_" << db << " >"
<< "{"
<< "public:" << endl;
@@ -1306,7 +1336,8 @@ namespace relational
}
}
- os << "struct access::view_traits< " << type << " >::query_columns";
+ os << "struct access::view_traits_impl< " << type << ", id_" <<
+ db << " >::query_columns";
if (obj_count > 1)
{
@@ -1329,19 +1360,20 @@ namespace relational
<< "//" << endl
<< "typedef" << endl
<< "odb::pointer_query_columns<" << endl
- << " " << otype << "," << endl;
+ << " " << otype << "," << endl
+ << " id_" << db << "," << endl;
if (alias && (polymorphic (o) ||
table.qualified () ||
i->alias != table.uname ()))
{
string tag (escape (i->alias + "_alias_tag"));
- os << " odb::alias_traits< " << otype << ", " <<
- tag << " > >" << endl;
+ os << " odb::alias_traits< " << otype << ", id_" << db <<
+ ", " << tag << " > >" << endl;
}
else
- os << " odb::access::object_traits< " << otype <<
- " > >" << endl;
+ os << " odb::access::object_traits_impl< " << otype <<
+ ", id_" << db << " > >" << endl;
os << oname << ";"
<< endl;
@@ -1370,18 +1402,20 @@ namespace relational
os << ":" << endl
<< " odb::pointer_query_columns<" << endl
- << " " << otype << "," << endl;
+ << " " << otype << "," << endl
+ << " id_" << db << "," << endl;
if (alias && (polymorphic (o) ||
table.qualified () ||
vo->alias != table.uname ()))
{
string tag (escape (vo->alias + "_alias_tag"));
- os << " odb::alias_traits< " << otype << ", " <<
- tag << " > >";
+ os << " odb::alias_traits< " << otype << ", id_" <<
+ db << ", " << tag << " > >";
}
else
- os << " odb::access::object_traits< " << otype << " > >";
+ os << " odb::access::object_traits_impl< " << otype <<
+ ", id_" << db << " > >";
os << "{"
<< "};";
diff --git a/odb/relational/inline.hxx b/odb/relational/inline.hxx
index 76c29f1..7e70ab1 100644
--- a/odb/relational/inline.hxx
+++ b/odb/relational/inline.hxx
@@ -121,7 +121,8 @@ namespace relational
virtual void
traverse_composite (member_info& mi)
{
- string traits ("composite_value_traits< " + mi.fq_type () + " >");
+ string traits ("composite_value_traits< " + mi.fq_type () + ", id_" +
+ db.string () + " >");
if (get_)
os << "r = r && " << traits << "::get_null (" <<
@@ -145,7 +146,8 @@ namespace relational
if (!composite (c))
return;
- string traits ("composite_value_traits< " + class_fq_name (c) + " >");
+ string traits ("composite_value_traits< " + class_fq_name (c) +
+ ", id_" + db.string () + " >");
// If the derived value type is readonly, then set will never be
// called with sk == statement_update.
@@ -245,13 +247,13 @@ namespace relational
string const& type (class_fq_name (c));
string traits ("access::object_traits< " + type + " >");
+ string traits_impl ("access::object_traits_impl< " + type +
+ ", id_" + db.string () + " >");
os << "// " << class_name (c) << endl
<< "//" << endl
<< endl;
- object_extra (c);
-
// id (object_type)
//
if (id != 0 || !reuse_abst)
@@ -285,6 +287,8 @@ namespace relational
os << "}";
}
+ object_extra (c);
+
if (id != 0 && base_id)
{
if (!poly_derived)
@@ -294,12 +298,12 @@ namespace relational
if (options.generate_query ())
{
os << "inline" << endl
- << traits << "::id_type" << endl
- << traits << "::" << endl
+ << traits_impl << "::id_type" << endl
+ << traits_impl << "::" << endl
<< "id (const image_type& i)"
<< "{"
- << "return object_traits< " << class_fq_name (*base) <<
- " >::id (i);"
+ << "return object_traits_impl< " << class_fq_name (*base) <<
+ ", id_" << db << " >::id (i);"
<< "}";
}
@@ -308,12 +312,12 @@ namespace relational
if (optimistic != 0)
{
os << "inline" << endl
- << traits << "::version_type" << endl
- << traits << "::" << endl
+ << traits_impl << "::version_type" << endl
+ << traits_impl << "::" << endl
<< "version (const image_type& i)"
<< "{"
- << "return object_traits< " << class_fq_name (*base) <<
- " >::version (i);"
+ << "return object_traits_impl< " << class_fq_name (*base) <<
+ ", id_" << db << " >::version (i);"
<< "}";
}
}
@@ -321,21 +325,21 @@ namespace relational
// bind (id_image_type)
//
os << "inline" << endl
- << "void " << traits << "::" << endl
+ << "void " << traits_impl << "::" << endl
<< "bind (" << bind_vector << " b, id_image_type& i" <<
(optimistic != 0 ? ", bool bv" : "") << ")"
<< "{"
- << "object_traits< " << class_fq_name (*base) <<
- " >::bind (b, i" << (optimistic != 0 ? ", bv" : "") << ");"
+ << "object_traits_impl< " << class_fq_name (*base) << ", id_" <<
+ db << " >::bind (b, i" << (optimistic != 0 ? ", bv" : "") << ");"
<< "}";
os << "inline" << endl
- << "void " << traits << "::" << endl
+ << "void " << traits_impl << "::" << endl
<< "init (id_image_type& i, const id_type& id" <<
(optimistic != 0 ? ", const version_type* v" : "") << ")"
<< "{"
- << "object_traits< " << class_fq_name (*base) <<
- " >::init (i, id" << (optimistic != 0 ? ", v" : "") << ");"
+ << "object_traits_impl< " << class_fq_name (*base) << ", id_" <<
+ db << " >::init (i, id" << (optimistic != 0 ? ", v" : "") << ");"
<< "}";
}
@@ -346,7 +350,7 @@ namespace relational
// check_version
//
os << "inline" << endl
- << "bool " << traits << "::" << endl
+ << "bool " << traits_impl << "::" << endl
<< "check_version (const std::size_t* v, const image_type& i)"
<< "{"
<< "return ";
@@ -366,7 +370,7 @@ namespace relational
// update_version
//
os << "inline" << endl
- << "void " << traits << "::" << endl
+ << "void " << traits_impl << "::" << endl
<< "update_version (std::size_t* v, const image_type& i, " <<
db << "::binding* b)"
<< "{";
@@ -401,7 +405,7 @@ namespace relational
if (id != 0 && !poly && optimistic == 0)
{
os << "inline" << endl
- << "void " << traits << "::" << endl
+ << "void " << traits_impl << "::" << endl
<< "erase (database& db, const object_type& obj)"
<< "{"
<< "callback (db, obj, callback_event::pre_erase);"
@@ -413,7 +417,7 @@ namespace relational
// callback ()
//
os << "inline" << endl
- << "void " << traits << "::" << endl
+ << "void " << traits_impl << "::" << endl
<< "callback (database& db, object_type& x, callback_event e)"
<< endl
<< "{"
@@ -425,7 +429,7 @@ namespace relational
os << "}";
os << "inline" << endl
- << "void " << traits << "::" << endl
+ << "void " << traits_impl << "::" << endl
<< "callback (database& db, const object_type& x, callback_event e)"
<< "{"
<< "ODB_POTENTIALLY_UNUSED (db);"
@@ -440,7 +444,7 @@ namespace relational
if (id != 0 && !(poly_derived || has_a (c, test_container)))
{
os << "inline" << endl
- << "void " << traits << "::" << endl
+ << "void " << traits_impl << "::" << endl
<< "load_ (";
if (poly && !poly_derived)
@@ -458,13 +462,13 @@ namespace relational
// root_image ()
//
os << "inline" << endl
- << traits << "::root_traits::image_type&" << endl
- << traits << "::" << endl
+ << traits_impl << "::root_traits::image_type&" << endl
+ << traits_impl << "::" << endl
<< "root_image (image_type& i)"
<< "{";
if (poly_derived)
- os << "return object_traits<base_type>::root_image (*i.base);";
+ os << "return base_traits::root_image (*i.base);";
else
os << "return i;";
@@ -473,15 +477,13 @@ namespace relational
// clone_image ()
//
os << "inline" << endl
- << traits << "::image_type*" << endl
- << traits << "::" << endl
+ << traits_impl << "::image_type*" << endl
+ << traits_impl << "::" << endl
<< "clone_image (const image_type& i)"
<< "{";
if (poly_derived)
- os << "typedef object_traits<base_type> base_traits;"
- << endl
- << "details::unique_ptr<base_traits::image_type> p (" << endl
+ os << "details::unique_ptr<base_traits::image_type> p (" << endl
<< "base_traits::clone_image (*i.base));"
<< "image_type* c (new image_type (i));"
<< "c->base = p.release ();"
@@ -494,14 +496,12 @@ namespace relational
// copy_image ()
//
os << "inline" << endl
- << "void " << traits << "::" << endl
+ << "void " << traits_impl << "::" << endl
<< "copy_image (image_type& d, const image_type& s)"
<< "{";
if (poly_derived)
- os << "typedef object_traits<base_type> base_traits;"
- << endl
- << "base_traits::image_type* b (d.base);"
+ os << "base_traits::image_type* b (d.base);"
<< "base_traits::copy_image (*b, *s.base);"
<< "d = s;" // Overwrites the base pointer.
<< "d.base = b;";
@@ -513,12 +513,12 @@ namespace relational
// free_image ()
//
os << "inline" << endl
- << "void " << traits << "::" << endl
+ << "void " << traits_impl << "::" << endl
<< "free_image (image_type* i)"
<< "{";
if (poly_derived)
- os << "object_traits<base_type>::free_image (i->base);";
+ os << "base_traits::free_image (i->base);";
os << "delete i;"
<< "}";
@@ -534,7 +534,8 @@ namespace relational
traverse_view (type& c)
{
string const& type (class_fq_name (c));
- string traits ("access::view_traits< " + type + " >");
+ string traits ("access::view_traits_impl< " + type + ", id_" +
+ db.string () + " >");
os << "// " << class_name (c) << endl
<< "//" << endl
@@ -561,7 +562,8 @@ namespace relational
traverse_composite (type& c)
{
string const& type (class_fq_name (c));
- string traits ("access::composite_value_traits< " + type + " >");
+ string traits ("access::composite_value_traits< " + type + ", id_" +
+ db.string () + " >");
os << "// " << class_name (c) << endl
<< "//" << endl
diff --git a/odb/relational/mssql/common.cxx b/odb/relational/mssql/common.cxx
index b2f982a..d802e54 100644
--- a/odb/relational/mssql/common.cxx
+++ b/odb/relational/mssql/common.cxx
@@ -202,7 +202,8 @@ namespace relational
void member_image_type::
traverse_composite (member_info& mi)
{
- type_ = "composite_value_traits< " + mi.fq_type () + " >::image_type";
+ type_ = "composite_value_traits< " + mi.fq_type () +
+ ", id_mssql >::image_type";
}
void member_image_type::
diff --git a/odb/relational/mysql/common.cxx b/odb/relational/mysql/common.cxx
index b8fa4c3..9d62b6b 100644
--- a/odb/relational/mysql/common.cxx
+++ b/odb/relational/mysql/common.cxx
@@ -168,7 +168,8 @@ namespace relational
void member_image_type::
traverse_composite (member_info& mi)
{
- type_ = "composite_value_traits< " + mi.fq_type () + " >::image_type";
+ type_ = "composite_value_traits< " + mi.fq_type () +
+ ", id_mysql >::image_type";
}
void member_image_type::
diff --git a/odb/relational/mysql/source.cxx b/odb/relational/mysql/source.cxx
index 15a4fcf..a9e7a16 100644
--- a/odb/relational/mysql/source.cxx
+++ b/odb/relational/mysql/source.cxx
@@ -340,7 +340,7 @@ namespace relational
traverse_composite (member_info& mi)
{
os << "if (composite_value_traits< " << mi.fq_type () <<
- " >::grow (" << endl
+ ", id_mysql >::grow (" << endl
<< "i." << mi.var << "value, t + " << index_ << "UL))"
<< "{"
<< "grew = true;"
diff --git a/odb/relational/oracle/common.cxx b/odb/relational/oracle/common.cxx
index e9d8390..04bb0f8 100644
--- a/odb/relational/oracle/common.cxx
+++ b/odb/relational/oracle/common.cxx
@@ -188,7 +188,8 @@ namespace relational
void member_image_type::
traverse_composite (member_info& mi)
{
- type_ = "composite_value_traits< " + mi.fq_type () + " >::image_type";
+ type_ = "composite_value_traits< " + mi.fq_type () +
+ ", id_oracle >::image_type";
}
void member_image_type::
diff --git a/odb/relational/pgsql/common.cxx b/odb/relational/pgsql/common.cxx
index 3d7e01e..811269e 100644
--- a/odb/relational/pgsql/common.cxx
+++ b/odb/relational/pgsql/common.cxx
@@ -144,7 +144,8 @@ namespace relational
void member_image_type::
traverse_composite (member_info& mi)
{
- type_ = "composite_value_traits< " + mi.fq_type () + " >::image_type";
+ type_ = "composite_value_traits< " + mi.fq_type () +
+ ", id_pgsql >::image_type";
}
void member_image_type::
diff --git a/odb/relational/pgsql/source.cxx b/odb/relational/pgsql/source.cxx
index 6a3d761..da07073 100644
--- a/odb/relational/pgsql/source.cxx
+++ b/odb/relational/pgsql/source.cxx
@@ -289,7 +289,7 @@ namespace relational
traverse_composite (member_info& mi)
{
os << "if (composite_value_traits< " << mi.fq_type () <<
- " >::grow (" << endl
+ ", id_pgsql >::grow (" << endl
<< "i." << mi.var << "value, t + " << index_ << "UL))"
<< "{"
<< "grew = true;"
@@ -636,7 +636,7 @@ namespace relational
string const& n (class_fq_name (c));
string const& fn (flat_name (n));
- string traits ("access::object_traits< " + n + " >");
+ string traits ("access::object_traits_impl< " + n + ", id_pgsql >");
os << "const char " << traits << "::" << endl
<< "persist_statement_name[] = " << strlit (fn + "_persist") << ";"
@@ -786,7 +786,7 @@ namespace relational
{
string const& n (class_fq_name (c));
string const& fn (flat_name (n));
- string traits ("access::view_traits< " + n + " >");
+ string traits ("access::view_traits_impl< " + n + ", id_pgsql >");
os << "const char " << traits << "::" << endl
<< "query_statement_name[] = " << strlit (fn + "_query") << ";"
diff --git a/odb/relational/schema.hxx b/odb/relational/schema.hxx
index 56857f3..a236fd5 100644
--- a/odb/relational/schema.hxx
+++ b/odb/relational/schema.hxx
@@ -864,7 +864,8 @@ namespace relational
++end; // Transform the range from [begin, end] to [begin, end).
string const& type (class_fq_name (c));
- string traits ("access::object_traits< " + type + " >");
+ string traits ("access::object_traits_impl< " + type + ", id_" +
+ db.string () + " >");
// create_schema ()
//
@@ -941,6 +942,7 @@ namespace relational
os << "static const schema_catalog_entry" << endl
<< "schema_catalog_entry_" << flat_name (type) << "_ (" << endl
+ << "id_" << db << "," << endl
<< strlit (options.schema_name ()) << "," << endl
<< "&" << traits << "::create_schema);"
<< endl;
diff --git a/odb/relational/source.cxx b/odb/relational/source.cxx
index 5a02703..8981417 100644
--- a/odb/relational/source.cxx
+++ b/odb/relational/source.cxx
@@ -49,7 +49,8 @@ traverse_object (type& c)
}
string const& type (class_fq_name (c));
- string traits ("access::object_traits< " + type + " >");
+ string traits ("access::object_traits_impl< " + type + ", id_" +
+ db.string () + " >");
column_count_type const& cc (column_count (c));
os << "// " << class_name (c) << endl
@@ -187,7 +188,7 @@ traverse_object (type& c)
<< "//" << endl
<< "if (--d != 0)"
<< "{"
- << "if (object_traits<base_type>::grow (*i.base, " <<
+ << "if (base_traits::grow (*i.base, " <<
"t + " << cols << "UL" <<
(poly_base != poly_root ? ", d" : "") << "))" << endl
<< "i.base->version++;"
@@ -268,7 +269,7 @@ traverse_object (type& c)
os << "// " << class_name (*poly_base) << " base" << endl
<< "//" << endl
<< "if (sk == statement_select)" << endl
- << "object_traits<base_type>::";
+ << "base_traits::";
if (poly_base == poly_root)
os << "bind (b + n, *i.base, sk);";
@@ -360,7 +361,7 @@ traverse_object (type& c)
os << "// " << class_name (*poly_base) << " base" << endl
<< "//" << endl
<< "if (--d != 0)" << endl
- << "object_traits<base_type>::init (o, *i.base, db" <<
+ << "base_traits::init (o, *i.base, db" <<
(poly_base != poly_root ? ", d" : "") << ");"
<< endl;
}
@@ -450,7 +451,8 @@ traverse_object (type& c)
<< "typeid (" << type << ")," << endl;
if (poly_derived)
- os << "&object_traits< " << class_fq_name (*poly_base) << " >::info";
+ os << "&object_traits_impl< " << class_fq_name (*poly_base) <<
+ ", id_" << db << " >::info";
else
os << "0";
@@ -463,7 +465,7 @@ traverse_object (type& c)
os << "," << endl
<< strlit (string (n, 2, string::npos)) << "," << endl
<< "&odb::create_impl< " << type << " >," << endl
- << "&odb::dispatch_impl< " << type << " >," << endl;
+ << "&odb::dispatch_impl< " << type << ", id_" << db << " >," << endl;
if (poly_derived)
os << "&statements_type::delayed_loader";
@@ -883,7 +885,7 @@ traverse_object (type& c)
// hierarchy.
//
if (poly_derived)
- os << "object_traits<base_type>::persist (db, obj, false, false);"
+ os << "base_traits::persist (db, obj, false, false);"
<< endl;
os << "image_type& im (sts.image ());"
@@ -1135,7 +1137,7 @@ traverse_object (type& c)
//
if (!readonly_base)
{
- os << "object_traits<base_type>::update (db, obj, false, false);"
+ os << "base_traits::update (db, obj, false, false);"
<< endl;
}
else
@@ -1550,7 +1552,7 @@ traverse_object (type& c)
// Call our base last (we erase polymorphic objects from base
// to derived in order not to trigger cascading deletes).
//
- os << "object_traits<base_type>::erase (db, id, false, false);"
+ os << "base_traits::erase (db, id, false, false);"
<< endl;
}
@@ -1787,7 +1789,7 @@ traverse_object (type& c)
// Call our base last (we erase polymorphic objects from base
// to derived in order not to trigger cascading deletes).
//
- os << "object_traits<base_type>::erase (db, obj, false, false);"
+ os << "base_traits::erase (db, obj, false, false);"
<< endl;
}
@@ -2349,7 +2351,7 @@ traverse_object (type& c)
if (poly_derived)
os << "if (--d != 0)" << endl
- << "object_traits<base_type>::load_ (sts.base_statements (), obj" <<
+ << "base_traits::load_ (sts.base_statements (), obj" <<
(poly_base != poly_root ? ", d" : "") << ");"
<< endl;
@@ -2658,7 +2660,8 @@ void relational::source::class_::
traverse_view (type& c)
{
string const& type (class_fq_name (c));
- string traits ("access::view_traits< " + type + " >");
+ string traits ("access::view_traits_impl< " + type + ", id_" +
+ db.string () + " >");
os << "// " << class_name (c) << endl
<< "//" << endl
diff --git a/odb/relational/source.hxx b/odb/relational/source.hxx
index b73cd01..123ac55 100644
--- a/odb/relational/source.hxx
+++ b/odb/relational/source.hxx
@@ -937,8 +937,9 @@ namespace relational
virtual void
traverse_composite (member_info& mi)
{
- os << "composite_value_traits< " << mi.fq_type () <<
- " >::bind (b + n, " << arg << "." << mi.var << "value, sk);";
+ os << "composite_value_traits< " << mi.fq_type () << ", id_" <<
+ db << " >::bind (" << endl
+ << "b + n, " << arg << "." << mi.var << "value, sk);";
}
protected:
@@ -973,8 +974,12 @@ namespace relational
os << "if (sk != statement_update)"
<< "{";
- os << (obj ? "object" : "composite_value") << "_traits< " <<
- class_fq_name (c) << " >::bind (b + n, i, sk);";
+ if (obj)
+ os << "object_traits_impl< ";
+ else
+ os << "composite_value_traits< ";
+
+ os << class_fq_name (c) << ", id_" << db << " >::bind (b + n, i, sk);";
column_count_type const& cc (column_count (c));
@@ -1067,8 +1072,15 @@ namespace relational
os << "// " << class_name (c) << " base" << endl
<< "//" << endl;
- os << "if (" << (obj ? "object" : "composite_value") << "_traits< " <<
- class_fq_name (c) << " >::grow (i, t + " << index_ << "UL))" << endl
+ os << "if (";
+
+ if (obj)
+ os << "object_traits_impl< ";
+ else
+ os << "composite_value_traits< ";
+
+ os << class_fq_name (c) << ", id_" << db << " >::grow (" << endl
+ << "i, t + " << index_ << "UL))" << endl
<< "grew = true;"
<< endl;
@@ -1232,10 +1244,11 @@ namespace relational
if (null (mi.m, key_prefix_) &&
mi.wrapper->template get<bool> ("wrapper-null-handler"))
{
- os << "if (wrapper_traits< " + wt + " >::get_null (" <<
+ os << "if (wrapper_traits< " << wt << " >::get_null (" <<
member << "))" << endl
- << "composite_value_traits< " + mi.fq_type () + " >::" <<
- "set_null (i." << mi.var << "value, sk);"
+ << "composite_value_traits< " << mi.fq_type () << ", id_" <<
+ db << " >::set_null (" << endl
+ << "i." << mi.var << "value, sk);"
<< "else"
<< "{";
}
@@ -1307,7 +1320,8 @@ namespace relational
}
if (comp)
- traits = "composite_value_traits< " + type + " >";
+ traits = "composite_value_traits< " + type + ", id_" +
+ db.string () + " >";
else
{
db_type_id = member_database_type_id_->database_type_id (mi.m);
@@ -1403,8 +1417,12 @@ namespace relational
if (generate_grow)
os << "if (";
- os << (obj ? "object" : "composite_value") << "_traits< " <<
- class_fq_name (c) << " >::init (i, o, sk)";
+ if (obj)
+ os << "object_traits_impl< ";
+ else
+ os << "composite_value_traits< ";
+
+ os << class_fq_name (c) << ", id_" << db << " >::init (i, o, sk)";
if (generate_grow)
os << ")" << endl
@@ -1571,9 +1589,10 @@ namespace relational
if (null (mi.m, key_prefix_) &&
mi.wrapper->template get<bool> ("wrapper-null-handler"))
{
- os << "if (composite_value_traits< " + mi.fq_type () + " >::" <<
- "get_null (i." << mi.var << "value))" << endl
- << "wrapper_traits< " + wt + " >::set_null (" << member + ");"
+ os << "if (composite_value_traits< " << mi.fq_type () <<
+ ", id_" << db << " >::get_null (" << endl
+ << "i." << mi.var << "value))" << endl
+ << "wrapper_traits< " << wt << " >::set_null (" << member + ");"
<< "else" << endl;
}
@@ -1595,8 +1614,9 @@ namespace relational
os << "if (";
if (comp)
- os << "composite_value_traits< " + type + " >::get_null (i." <<
- mi.var << "value)";
+ os << "composite_value_traits< " << type << ", id_" << db <<
+ " >::get_null (" << endl
+ << "i." << mi.var << "value)";
else
get_null (mi);
@@ -1618,7 +1638,8 @@ namespace relational
type = mi.fq_type ();
if (comp)
- traits = "composite_value_traits< " + type + " >";
+ traits = "composite_value_traits< " + type + ", id_" +
+ db.string () + " >";
else
{
db_type_id = member_database_type_id_->database_type_id (mi.m);
@@ -1730,9 +1751,14 @@ namespace relational
return;
os << "// " << class_name (c) << " base" << endl
- << "//" << endl
- << (obj ? "object" : "composite_value") << "_traits< " <<
- class_fq_name (c) << " >::init (o, i, db);"
+ << "//" << endl;
+
+ if (obj)
+ os << "object_traits_impl< ";
+ else
+ os << "composite_value_traits< ";
+
+ os << class_fq_name (c) << ", id_" << db << " >::init (o, i, db);"
<< endl;
}
};
@@ -1750,12 +1776,11 @@ namespace relational
false),
c_ (c)
{
- string const& type (class_fq_name (c));
+ scope_ = object (c)
+ ? "access::object_traits_impl< "
+ : "access::composite_value_traits< ";
- if (object (c))
- scope_ = "access::object_traits< " + type + " >";
- else
- scope_ = "access::composite_value_traits< " + type + " >";
+ scope_ += class_fq_name (c) + ", id_" + db.string () + " >";
}
// Unless the database system can execute several interleaving
@@ -3469,7 +3494,8 @@ namespace relational
traverse_composite (type& c)
{
string const& type (class_fq_name (c));
- string traits ("access::composite_value_traits< " + type + " >");
+ string traits ("access::composite_value_traits< " + type + ", id_" +
+ db.string () + " >");
os << "// " << class_name (c) << endl
<< "//" << endl
diff --git a/odb/relational/sqlite/common.cxx b/odb/relational/sqlite/common.cxx
index 7164ef3..601b01d 100644
--- a/odb/relational/sqlite/common.cxx
+++ b/odb/relational/sqlite/common.cxx
@@ -78,7 +78,8 @@ namespace relational
void member_image_type::
traverse_composite (member_info& mi)
{
- type_ = "composite_value_traits< " + mi.fq_type () + " >::image_type";
+ type_ = "composite_value_traits< " + mi.fq_type () +
+ ", id_sqlite >::image_type";
}
void member_image_type::
diff --git a/odb/relational/sqlite/source.cxx b/odb/relational/sqlite/source.cxx
index 7d29c1e..75e7149 100644
--- a/odb/relational/sqlite/source.cxx
+++ b/odb/relational/sqlite/source.cxx
@@ -117,7 +117,7 @@ namespace relational
traverse_composite (member_info& mi)
{
os << "if (composite_value_traits< " << mi.fq_type () <<
- " >::grow (" << endl
+ ", id_sqlite >::grow (" << endl
<< "i." << mi.var << "value, t + " << index_ << "UL))"
<< "{"
<< "grew = true;"