From 2fe7a723c0b98d23531a76d9c1a451e3a57bf0c5 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 17 Nov 2010 18:05:06 +0200 Subject: Add support for unidirectional object relationships New test: common/relationship. --- odb/context.hxx | 59 +++++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 47 insertions(+), 12 deletions(-) (limited to 'odb/context.hxx') diff --git a/odb/context.hxx b/odb/context.hxx index 3fad543..2703380 100644 --- a/odb/context.hxx +++ b/odb/context.hxx @@ -74,6 +74,16 @@ public: return t.count ("container-kind"); } + static semantics::class_* + object_pointer (semantics::data_member& m, string const& key_prefix) + { + using semantics::class_; + + return key_prefix.empty () + ? m.get ("object-pointer", 0) + : m.get (key_prefix + "-object-pointer", 0); + } + // Database names and types. // public: @@ -103,17 +113,6 @@ public: column_type (semantics::data_member&, string const& key_prefix = string ()) const; - // Return empty string if there is no mapping. The second argument - // is the custom type or empty string if it is not specified. - // - string - column_type_impl (semantics::type& t, - string const& type, - semantics::context* ctx) const - { - return data_->column_type_impl (t, type, ctx); - } - // Cleaned-up member name that can be used for database names. // string @@ -171,6 +170,26 @@ public: return *c.get ("tree-key-type"); } + // The 'is a' and 'has a' tests. The has_a test currently does not + // cross the container boundaries. + // + static unsigned short const eager_pointer = 0x01; + + static bool + is_a (semantics::data_member& m, unsigned short flags) + { + return is_a (m, flags, m.type (), ""); + } + + static bool + is_a (semantics::data_member&, + unsigned short flags, + semantics::type&, + string const& key_prefix); + + static bool + has_a (semantics::type&, unsigned short flags); + protected: struct data; typedef cutl::shared_ptr data_ptr; @@ -199,6 +218,18 @@ public: typedef std::map type_map_type; protected: + typedef unsigned short column_type_flags; + + static column_type_flags const ctf_none = 0; + + // Default type should be NULL-able. + // + static column_type_flags const ctf_default_null = 0x01; + + // Get object id reference instead of object id. + // + static column_type_flags const ctf_object_id_ref = 0x02; + struct data { virtual ~data () {} @@ -206,10 +237,14 @@ protected: // Per-database customizable functionality. // public: + // Return empty string if there is no mapping. The second argument + // is the custom type or empty string if it is not specified. + // virtual string column_type_impl (semantics::type&, string const& type, - semantics::context*) const; + semantics::context&, + column_type_flags) const; keyword_set_type keyword_set_; type_map_type type_map_; -- cgit v1.1