diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2015-02-04 17:23:53 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2015-02-04 17:23:53 +0200 |
commit | f4a26457ea30754e57e6adc82dd18c19572d3937 (patch) | |
tree | 96a3a808cf805f447451be5b26623b9049ad64eb | |
parent | 5407e260ac888d0428012df757145a6f6dee34ca (diff) |
Implement object loading views
See section 10.2 in the manual for details.
-rw-r--r-- | odb/view-image.hxx | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/odb/view-image.hxx b/odb/view-image.hxx new file mode 100644 index 0000000..565a58b --- /dev/null +++ b/odb/view-image.hxx @@ -0,0 +1,37 @@ +// file : odb/view-image.hxx +// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_VIEW_IMAGE_HXX +#define ODB_VIEW_IMAGE_HXX + +#include <odb/pre.hxx> + +#include <odb/forward.hxx> +#include <odb/traits.hxx> + +namespace odb +{ + // Helper to create a complete image chain for a polymorphic + // object hierarchy. + // + template <typename D, typename R, database_id DB> + struct view_object_image: object_traits_impl<D, DB>::image_type + { + view_object_image () {this->base = &base_;} + + private: + // Data member names in the generated image_type never end with + // an underscore, so this name shouldn't clash. + // + view_object_image<typename object_traits_impl<D, DB>::base_type, R, DB> + base_; + }; + + template <typename R, database_id DB> + struct view_object_image<R, R, DB>: object_traits_impl<R, DB>::image_type {}; +} + +#include <odb/post.hxx> + +#endif // ODB_VIEW_IMAGE_HXX |