diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2012-10-08 14:47:57 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2012-10-08 14:47:57 +0200 |
commit | 6b76715e63d2c265a4c51c73f9019bc578f874cb (patch) | |
tree | c0b5f6a944abf6fe015742bbc08e5a393249cf6d /common/inheritance/test.hxx | |
parent | dcee8530bb5c58710a22f50bb92ac7c3b19ddf84 (diff) |
Fix bug in transient inheritance handling
Also test that we can handle it for objects, composite values, and views.
Diffstat (limited to 'common/inheritance/test.hxx')
-rw-r--r-- | common/inheritance/test.hxx | 158 |
1 files changed, 0 insertions, 158 deletions
diff --git a/common/inheritance/test.hxx b/common/inheritance/test.hxx deleted file mode 100644 index 6059337..0000000 --- a/common/inheritance/test.hxx +++ /dev/null @@ -1,158 +0,0 @@ -// file : common/inheritance/test.hxx -// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include <string> -#include <vector> - -#include <odb/core.hxx> - -#pragma db value -struct comp_base -{ - std::vector<unsigned char> bools; - - bool - operator== (const comp_base& y) const - { - return bools == y.bools; - } -}; - -#pragma db value -struct comp: comp_base -{ - unsigned int num; - std::string str; - - std::vector<unsigned int> nums; - - bool - operator== (const comp& y) const - { - return - static_cast<const comp_base&> (*this) == y && - num == y.num && - str == y.str && - nums == y.nums; - } -}; - -#pragma db object abstract -struct abstract_base -{ - comp comp_; - - unsigned int num_; - std::string str_; - - std::vector<std::string> strs_; - - bool - operator== (const abstract_base& y) const - { - return - comp_ == y.comp_ && - num_ == y.num_ && - str_ == y.str_ && - strs_ == y.strs_; - } -}; - -#pragma db object -struct base: abstract_base -{ - #pragma db id auto - unsigned long id_; - - bool - operator== (const base& y) const - { - return id_ == y.id_ && static_cast<const abstract_base&> (*this) == y; - } -}; - -#pragma db object -struct object1: base -{ - unsigned int num1_; - - bool - operator== (const object1& y) const - { - return static_cast<const base&> (*this) == y && num1_ == y.num1_; - } -}; - -#pragma db object -struct object2: base -{ - #pragma db column("derived_str") - std::string str_; - - bool - operator== (const object2& y) const - { - return static_cast<const base&> (*this) == y && str_ == y.str_; - } -}; - -// Reference to derived object. -// -#pragma db object -struct reference -{ - #pragma db id auto - unsigned long id_; - - object1* o1_; -}; - -// Multiple inheritance. -// -#pragma db object abstract -struct id_base -{ - #pragma db id auto - unsigned long id_; - - bool - operator== (const id_base& y) const - { - return id_ == y.id_; - } -}; - -#pragma db object -struct object3: abstract_base, id_base -{ - bool - operator== (const object3& y) const - { - return - static_cast<const abstract_base&> (*this) == y && - static_cast<const id_base&> (*this) == y; - } -}; - -// Empty derived object. -// -#pragma db object -struct empty: base -{ -}; - -// View based on the derived object. -// -#pragma db view object(object2) -struct object2_view -{ - unsigned int num; // from abstract_base - unsigned long id; // from base - std::string str; // from object2, hides one from abstract_base -}; - -#endif // TEST_HXX |