From 3b457daf6b252ef31ec0611e7375aa4badd8e63d Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 18 Mar 2013 13:10:41 +0200 Subject: Add support for copying database models --- odb/semantics/relational/elements.txx | 44 +++++++++++++++++------------------ 1 file changed, 22 insertions(+), 22 deletions(-) (limited to 'odb/semantics/relational/elements.txx') diff --git a/odb/semantics/relational/elements.txx b/odb/semantics/relational/elements.txx index 05ae06d..53946a0 100644 --- a/odb/semantics/relational/elements.txx +++ b/odb/semantics/relational/elements.txx @@ -23,6 +23,13 @@ namespace semantics template nameable:: + nameable (nameable const& n, graph&) + : id_ (n.id_), named_ (0) + { + } + + template + nameable:: nameable (xml::parser&, graph&) // : id_ (p.attribute ("id")) : named_ (0) @@ -99,6 +106,19 @@ namespace semantics template scope:: + scope (scope const& s, graph& g) + : first_key_ (names_.end ()) + { + for (names_const_iterator i (s.names_begin ()); + i != s.names_end (); ++i) + { + nameable_type& n (i->nameable ().clone (*this, g)); + g.new_edge (*this, n, i->name ()); + } + } + + template + scope:: scope (xml::parser& p, graph& g) : first_key_ (names_.end ()) { @@ -136,38 +156,18 @@ namespace semantics void scope:: add_edge_left (names_type& e) { - nameable_type& n (e.nameable ()); name_type const& name (e.name ()); typename names_map::iterator i (names_map_.find (name)); if (i == names_map_.end ()) { - typename names_list::iterator i; - - // We want the order to be columns first, then the primary key, - // and then the foreign keys. - // - if (n.is_a ()) - i = names_.insert (first_key_, &e); - else - { - if (n.is_a ()) - first_key_ = i = names_.insert (first_key_, &e); - else - { - i = names_.insert (names_.end (), &e); - - if (first_key_ == names_.end ()) - first_key_ = i; - } - } - + typename names_list::iterator i (names_.insert (names_.end (), &e)); names_map_[name] = i; iterator_map_[&e] = i; } else - throw duplicate_name (*this, (*i->second)->nameable (), n); + throw duplicate_name (*this, (*i->second)->nameable (), e.nameable ()); } } } -- cgit v1.1