aboutsummaryrefslogtreecommitdiff
path: root/odb/relational/source.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2012-10-31 07:59:18 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2012-11-21 13:13:50 +0200
commit8a637f5697fdee3e7ae2d46f64a64d40cba5954b (patch)
treec0255a90876c464803245a39f8505898ab6a3f74 /odb/relational/source.cxx
parent2b7b3e9d9e69bbf0fdd6ce1a8564765027580d10 (diff)
Add dynamic multi-database support excluding query
Diffstat (limited to 'odb/relational/source.cxx')
-rw-r--r--odb/relational/source.cxx70
1 files changed, 65 insertions, 5 deletions
diff --git a/odb/relational/source.cxx b/odb/relational/source.cxx
index 7516801..7fc3ce6 100644
--- a/odb/relational/source.cxx
+++ b/odb/relational/source.cxx
@@ -37,6 +37,7 @@ traverse_object (type& c)
bool abst (abstract (c));
bool reuse_abst (abst && !poly);
+ bool readonly (context::readonly (c));
bool grow (false);
bool grow_id (false);
@@ -223,7 +224,7 @@ traverse_object (type& c)
<< "using namespace " << db << ";"
<< endl;
- if (readonly (c))
+ if (readonly)
os << "assert (sk != statement_update);"
<< endl;
@@ -252,7 +253,7 @@ traverse_object (type& c)
{
// The id reference comes last in the update statement.
//
- if (!readonly (c))
+ if (!readonly)
os << "// " << id->name () << endl
<< "//" << endl
<< "if (sk == statement_update)"
@@ -321,7 +322,7 @@ traverse_object (type& c)
<< "using namespace " << db << ";"
<< endl;
- if (readonly (c))
+ if (readonly)
os << "assert (sk != statement_update);"
<< endl;
@@ -1061,8 +1062,6 @@ traverse_object (type& c)
// update ()
//
- bool readonly (context::readonly (c));
-
if (id != 0 && (!readonly || poly))
{
os << "void " << traits << "::" << endl
@@ -2788,8 +2787,69 @@ traverse_object (type& c)
}
}
+ // Generate embedded schema.
+ //
if (embedded_schema)
schema_->traverse (c);
+
+ // Generate function table registration for dynamic multi-database
+ // support.
+ //
+ if (options.multi_database () == multi_database::dynamic)
+ {
+ string fn (flat_name (type));
+ string dt ("access::object_traits_impl< " + type + ", id_default >");
+
+ os << "static const" << endl
+ << dt << "::" << endl
+ << "function_table_type function_table_" << fn << "_ ="
+ << "{";
+
+ // persist ()
+ //
+ os << "&" << traits << "::persist";
+
+ if (id != 0)
+ {
+ // find (id)
+ //
+ if (c.default_ctor ())
+ os << "," << endl
+ << "&" << traits << "::find";
+
+ // find (id, obj)
+ //
+ os << "," << endl
+ << "&" << traits << "::find";
+
+ // reload ()
+ //
+ os << "," << endl
+ << "&" << traits << "::reload";
+
+ // update ()
+ //
+ if (!readonly || poly)
+ os << "," << endl
+ << "&" << traits << "::update";
+
+ // erase ()
+ //
+ os << "," << endl
+ << "&" << traits << "::erase";
+
+ os << "," << endl
+ << "&" << traits << "::erase";
+ }
+
+ os << "};";
+
+ os << "static const function_table_entry< " << type << ", " <<
+ "id_" << db << " >" << endl
+ << "function_table_entry_" << fn << "_ (" << endl
+ << "&function_table_" << fn << "_);"
+ << endl;
+ }
}
void relational::source::class_::