summaryrefslogtreecommitdiff
path: root/odb/context.hxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2011-04-25 15:02:43 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2011-04-25 15:02:43 +0200
commit1a6a0652a6ef5b319cfc8ad05a0acee6910f7560 (patch)
tree40605db91ed90c342a9074308bd7406008b4f10b /odb/context.hxx
parent9c5b2f928699a6752d7c3d1a062bac7efc247c64 (diff)
Add support for abstract object types
Diffstat (limited to 'odb/context.hxx')
-rw-r--r--odb/context.hxx26
1 files changed, 20 insertions, 6 deletions
diff --git a/odb/context.hxx b/odb/context.hxx
index a09d040..9878bcb 100644
--- a/odb/context.hxx
+++ b/odb/context.hxx
@@ -105,7 +105,10 @@ public:
static bool
abstract (semantics::class_& c)
{
- return c.count ("abstract");
+ // If a class is abstract in the C++ sense then it is also abstract in
+ // the database sense.
+ //
+ return c.abstract () || c.count ("abstract");
}
// Database names and types.
@@ -179,12 +182,12 @@ public:
static size_t
out_column_count (semantics::class_&);
- static semantics::data_member&
+ static semantics::data_member*
id_member (semantics::class_& c)
{
- // Set by the validator.
+ // Set by the validator. May not be there for abstract objects.
//
- return *c.get<semantics::data_member*> ("id-member");
+ return c.get<semantics::data_member*> ("id-member", 0);
}
// Object pointer information.
@@ -363,7 +366,14 @@ public:
bool embedded_schema;
- semantics::class_*& object; // Object currently being traversed.
+ // Outermost object currently being traversed.
+ //
+ semantics::class_*& top_object;
+
+ // Object currently being traversed. It can be the same as top_object
+ // or it can a base of top_object.
+ //
+ semantics::class_*& object;
struct db_type_type
{
@@ -416,12 +426,16 @@ protected:
{
virtual
~data () {}
- data (std::ostream& os): os_ (os.rdbuf ()), object_ (0) {}
+ data (std::ostream& os)
+ : os_ (os.rdbuf ()), top_object_ (0), object_ (0)
+ {
+ }
public:
std::ostream os_;
std::stack<std::streambuf*> os_stack_;
+ semantics::class_* top_object_;
semantics::class_* object_;
keyword_set_type keyword_set_;