summaryrefslogtreecommitdiff
path: root/odb/relational/inline.hxx
diff options
context:
space:
mode:
Diffstat (limited to 'odb/relational/inline.hxx')
-rw-r--r--odb/relational/inline.hxx186
1 files changed, 25 insertions, 161 deletions
diff --git a/odb/relational/inline.hxx b/odb/relational/inline.hxx
index 76c29f1..466e348 100644
--- a/odb/relational/inline.hxx
+++ b/odb/relational/inline.hxx
@@ -14,68 +14,6 @@ namespace relational
namespace inline_
{
//
- //
- struct callback_calls: traversal::class_, virtual context
- {
- typedef callback_calls base;
-
- callback_calls ()
- {
- *this >> inherits_ >> *this;
- }
-
- callback_calls (callback_calls const&)
- : root_context (), //@@ -Wextra
- context ()
- {
- *this >> inherits_ >> *this;
- }
-
- virtual void
- traverse (type& c, bool constant)
- {
- const_ = constant;
- traverse (c);
- }
-
- virtual void
- traverse (type& c)
- {
- bool obj (object (c));
-
- // Ignore transient bases.
- //
- if (!(obj || view (c)))
- return;
-
- if (c.count ("callback"))
- {
- string name (c.get<string> ("callback"));
-
- // In case of the const instance, we only generate the call if
- // there is a const callback.
- //
- string const& type (class_fq_name (c));
-
- if (const_)
- {
- if (c.count ("callback-const"))
- os << "static_cast< const " << type << "& > (x)." <<
- name << " (e, db);";
- }
- else
- os << "static_cast< " << type << "& > (x)." << name << " (e, db);";
- }
- else if (obj)
- inherits (c);
- }
-
- protected:
- bool const_;
- traversal::inherits inherits_;
- };
-
- //
// get/set null (composite value only)
//
@@ -121,7 +59,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 +84,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.
@@ -209,7 +149,7 @@ namespace relational
if (object (c))
traverse_object (c);
- if (view (c))
+ else if (view (c))
traverse_view (c);
else if (composite (c))
traverse_composite (c);
@@ -226,11 +166,11 @@ namespace relational
traverse_object (type& c)
{
semantics::data_member* id (id_member (c));
- bool base_id (id ? &id->scope () != &c : false); // Comes from base.
+ bool base_id (id && &id->scope () != &c); // Comes from base.
semantics::data_member* optimistic (context::optimistic (c));
- // Base class the contains the object id and version for optimistic
+ // Base class that contains the object id and version for optimistic
// concurrency.
//
type* base (
@@ -244,7 +184,8 @@ namespace relational
bool reuse_abst (abst && !poly);
string const& type (class_fq_name (c));
- string traits ("access::object_traits< " + type + " >");
+ string traits ("access::object_traits_impl< " + type + ", id_" +
+ db.string () + " >");
os << "// " << class_name (c) << endl
<< "//" << endl
@@ -252,39 +193,6 @@ namespace relational
object_extra (c);
- // id (object_type)
- //
- if (id != 0 || !reuse_abst)
- {
- os << "inline" << endl
- << traits << "::id_type" << endl
- << traits << "::" << endl
- << "id (const object_type&" << (id != 0 ? " o" : "") << ")"
- << "{";
-
- if (id != 0)
- {
- if (base_id)
- os << "return object_traits< " << class_fq_name (*base) <<
- " >::id (o);";
- else
- {
- // Get the id using the accessor expression. If this is not
- // a synthesized expression, then output its location for
- // easier error tracking.
- //
- member_access& ma (id->get<member_access> ("get"));
-
- if (!ma.synthesized)
- os << "// From " << location_string (ma.loc, true) << endl;
-
- os << "return " << ma.translate ("o") << ";";
- }
- }
-
- os << "}";
- }
-
if (id != 0 && base_id)
{
if (!poly_derived)
@@ -298,8 +206,8 @@ namespace relational
<< traits << "::" << 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);"
<< "}";
}
@@ -312,8 +220,8 @@ namespace relational
<< traits << "::" << 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);"
<< "}";
}
}
@@ -325,8 +233,8 @@ namespace relational
<< "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
@@ -334,8 +242,8 @@ namespace relational
<< "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" : "") << ");"
<< "}";
}
@@ -390,7 +298,6 @@ namespace relational
os << "}";
}
- //
// The rest does not apply to reuse-abstract objects.
//
if (reuse_abst)
@@ -410,31 +317,6 @@ namespace relational
<< "}";
}
- // callback ()
- //
- os << "inline" << endl
- << "void " << traits << "::" << endl
- << "callback (database& db, object_type& x, callback_event e)"
- << endl
- << "{"
- << "ODB_POTENTIALLY_UNUSED (db);"
- << "ODB_POTENTIALLY_UNUSED (x);"
- << "ODB_POTENTIALLY_UNUSED (e);"
- << endl;
- callback_calls_->traverse (c, false);
- os << "}";
-
- os << "inline" << endl
- << "void " << traits << "::" << endl
- << "callback (database& db, const object_type& x, callback_event e)"
- << "{"
- << "ODB_POTENTIALLY_UNUSED (db);"
- << "ODB_POTENTIALLY_UNUSED (x);"
- << "ODB_POTENTIALLY_UNUSED (e);"
- << endl;
- callback_calls_->traverse (c, true);
- os << "}";
-
// load_()
//
if (id != 0 && !(poly_derived || has_a (c, test_container)))
@@ -464,7 +346,7 @@ namespace relational
<< "{";
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;";
@@ -479,9 +361,7 @@ namespace relational
<< "{";
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 ();"
@@ -499,9 +379,7 @@ namespace relational
<< "{";
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;";
@@ -518,7 +396,7 @@ namespace relational
<< "{";
if (poly_derived)
- os << "object_traits<base_type>::free_image (i->base);";
+ os << "base_traits::free_image (i->base);";
os << "delete i;"
<< "}";
@@ -534,34 +412,22 @@ 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
<< endl;
view_extra (c);
-
- // callback ()
- //
- os << "inline" << endl
- << "void " << traits << "::" << endl
- << "callback (database& db, view_type& x, callback_event e)"
- << endl
- << "{"
- << "ODB_POTENTIALLY_UNUSED (db);"
- << "ODB_POTENTIALLY_UNUSED (x);"
- << "ODB_POTENTIALLY_UNUSED (e);"
- << endl;
- callback_calls_->traverse (c, false);
- os << "}";
}
virtual void
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
@@ -602,8 +468,6 @@ namespace relational
}
private:
- instance<callback_calls> callback_calls_;
-
instance<null_base> get_null_base_;
traversal::inherits get_null_base_inherits_;
instance<null_member> get_null_member_;