summaryrefslogtreecommitdiff
path: root/odb/semantics
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2013-04-03 11:22:42 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2013-04-10 18:46:44 +0200
commitb0391e168b489811708ca7ba5f71a0eb67b46ffe (patch)
treece15fb5ce0998ec27696152054609bb5dd4f45c3 /odb/semantics
parente356a9112750e836197a8545bcf6cedad0c1ebe1 (diff)
Generate add/drop table migration statements
Diffstat (limited to 'odb/semantics')
-rw-r--r--odb/semantics/relational/changelog.hxx6
-rw-r--r--odb/semantics/relational/changeset.cxx6
-rw-r--r--odb/semantics/relational/changeset.hxx53
3 files changed, 62 insertions, 3 deletions
diff --git a/odb/semantics/relational/changelog.hxx b/odb/semantics/relational/changelog.hxx
index 93b327d..d9e220c 100644
--- a/odb/semantics/relational/changelog.hxx
+++ b/odb/semantics/relational/changelog.hxx
@@ -88,6 +88,12 @@ namespace semantics
return *contains_changeset_.back ();
}
+ contains_changeset const&
+ contains_changeset_at (contains_changeset_list::size_type i) const
+ {
+ return *contains_changeset_[i];
+ }
+
contains_changeset_iterator
contains_changeset_begin () const
{
diff --git a/odb/semantics/relational/changeset.cxx b/odb/semantics/relational/changeset.cxx
index fd5a17f..669394f 100644
--- a/odb/semantics/relational/changeset.cxx
+++ b/odb/semantics/relational/changeset.cxx
@@ -13,14 +13,16 @@ namespace semantics
changeset::
changeset (changeset const& c, qscope& b, graph& g)
: qscope (c, &b, g),
- version_ (c.version_)
+ version_ (c.version_),
+ alters_model_ (0)
{
}
changeset::
changeset (xml::parser& p, qscope& b, graph& g)
: qscope (p, &b, g),
- version_ (p.attribute<version_type> ("version"))
+ version_ (p.attribute<version_type> ("version")),
+ alters_model_ (0)
{
}
diff --git a/odb/semantics/relational/changeset.hxx b/odb/semantics/relational/changeset.hxx
index 76fd683..27c80fe 100644
--- a/odb/semantics/relational/changeset.hxx
+++ b/odb/semantics/relational/changeset.hxx
@@ -11,6 +11,43 @@ namespace semantics
{
namespace relational
{
+ class model;
+ class changeset;
+
+ class alters_model: public edge
+ {
+ public:
+ typedef relational::model model_type;
+ typedef relational::changeset changeset_type;
+
+ model_type&
+ model () const {return *model_;}
+
+ changeset_type&
+ changeset () const {return *changeset_;}
+
+ public:
+ alters_model () : model_ (0), changeset_ (0) {}
+
+ void
+ set_left_node (changeset_type& c)
+ {
+ assert (changeset_ == 0);
+ changeset_ = &c;
+ }
+
+ void
+ set_right_node (model_type& m)
+ {
+ assert (model_ == 0);
+ model_ = &m;
+ }
+
+ protected:
+ model_type* model_;
+ changeset_type* changeset_;
+ };
+
class changeset: public qscope
{
public:
@@ -19,8 +56,14 @@ namespace semantics
version_type
version () const {return version_;}
+ // Returns model to which this changeset applies (as opposed to the
+ // ultimate base model). Note that it may not be set.
+ //
+ model&
+ base_model () const {return alters_model_->model ();}
+
public:
- changeset (version_type v): version_ (v) {}
+ changeset (version_type v): version_ (v), alters_model_ (0) {}
changeset (changeset const&, qscope& base, graph&);
changeset (xml::parser&, qscope& base, graph&);
@@ -31,11 +74,19 @@ namespace semantics
serialize (xml::serializer&) const;
public:
+ virtual void
+ add_edge_left (alters_model& am)
+ {
+ assert (alters_model_ == 0);
+ alters_model_ = &am;
+ }
+
using qscope::add_edge_left;
using qscope::add_edge_right;
private:
version_type version_;
+ alters_model* alters_model_;
};
}
}