From 485ae35a88fe2500574797d7342cfa7585e9e191 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 4 Sep 2013 13:40:31 +0200 Subject: View versioning support --- odb/pgsql/traits-calls.hxx | 81 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 76 insertions(+), 5 deletions(-) (limited to 'odb/pgsql/traits-calls.hxx') diff --git a/odb/pgsql/traits-calls.hxx b/odb/pgsql/traits-calls.hxx index ee91e62..5313596 100644 --- a/odb/pgsql/traits-calls.hxx +++ b/odb/pgsql/traits-calls.hxx @@ -20,18 +20,22 @@ namespace odb { namespace pgsql { + // + // object_traits_calls + // + template ::versioned> - struct traits_calls; + struct object_traits_calls; template - struct traits_calls + struct object_traits_calls { typedef object_traits_impl traits; typedef typename traits::image_type image_type; typedef pgsql::bind bind_type; - traits_calls (const schema_version_migration*) {} + object_traits_calls (const schema_version_migration*) {} const schema_version_migration* version () const {return 0;} @@ -80,13 +84,13 @@ namespace odb }; template - struct traits_calls + struct object_traits_calls { typedef object_traits_impl traits; typedef typename traits::image_type image_type; typedef pgsql::bind bind_type; - traits_calls (const schema_version_migration* svm): svm_ (*svm) {} + object_traits_calls (const schema_version_migration* svm): svm_ (*svm) {} const schema_version_migration* version () const {return &svm_;} @@ -136,6 +140,73 @@ namespace odb private: const schema_version_migration& svm_; }; + + // + // view_traits_calls + // + + template ::versioned> + struct view_traits_calls; + + template + struct view_traits_calls + { + typedef view_traits_impl traits; + typedef typename traits::image_type image_type; + typedef pgsql::bind bind_type; + + view_traits_calls (const schema_version_migration*) {} + + static bool + grow (image_type& i, bool* t) + { + return traits::grow (i, t); + } + + static void + bind (bind_type* b, image_type& i) + { + traits::bind (b, i); + } + + static void + init (T& o, const image_type& i, odb::database* db) + { + traits::init (o, i, db); + } + }; + + template + struct view_traits_calls + { + typedef view_traits_impl traits; + typedef typename traits::image_type image_type; + typedef pgsql::bind bind_type; + + view_traits_calls (const schema_version_migration* svm): svm_ (*svm) {} + + bool + grow (image_type& i, bool* t) const + { + return traits::grow (i, t, svm_); + } + + void + bind (bind_type* b, image_type& i) const + { + traits::bind (b, i, svm_); + } + + void + init (T& o, const image_type& i, odb::database* db) const + { + traits::init (o, i, db, svm_); + } + + private: + const schema_version_migration& svm_; + }; } } -- cgit v1.1