diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2011-04-25 15:02:43 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2011-04-25 15:02:43 +0200 |
commit | 804603f33868af0450f179f66e2ddb16b84bdb80 (patch) | |
tree | cd5665bb838b6e7df1cd9ab7d08ce11d10144f4c /common/inheritance/test.hxx | |
parent | 5f821d47f0ee08a3a08962d0dc641326618dbf50 (diff) |
Add support for abstract object types
Diffstat (limited to 'common/inheritance/test.hxx')
-rw-r--r-- | common/inheritance/test.hxx | 59 |
1 files changed, 52 insertions, 7 deletions
diff --git a/common/inheritance/test.hxx b/common/inheritance/test.hxx index 31ef9c1..5ef2ea4 100644 --- a/common/inheritance/test.hxx +++ b/common/inheritance/test.hxx @@ -42,12 +42,9 @@ struct comp: comp_base } }; -#pragma db object -struct base +#pragma db object abstract +struct abstract_base { - #pragma db id auto - unsigned long id_; - comp comp_; unsigned int num_; @@ -56,10 +53,9 @@ struct base std::vector<std::string> strs_; bool - operator== (const base& y) const + operator== (const abstract_base& y) const { return - id_ == y.id_ && comp_ == y.comp_ && num_ == y.num_ && str_ == y.str_ && @@ -68,6 +64,19 @@ struct base }; #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_; @@ -92,6 +101,8 @@ struct object2: base } }; +// Reference to derived object. +// #pragma db object struct reference { @@ -101,4 +112,38 @@ struct reference 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 +{ +}; + #endif // TEST_HXX |