From d0f0e168cac3d117f64fddcca638a18fc4309ba1 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 22 Apr 2011 14:07:33 +0200 Subject: Initial support for non-polymorphic inheritance Every class gets a separate table. New test: common/inheritance. --- common/inheritance/test.hxx | 88 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 common/inheritance/test.hxx (limited to 'common/inheritance/test.hxx') diff --git a/common/inheritance/test.hxx b/common/inheritance/test.hxx new file mode 100644 index 0000000..e27ff7a --- /dev/null +++ b/common/inheritance/test.hxx @@ -0,0 +1,88 @@ +// file : common/inheritance/test.hxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include +#include + +#include + +#pragma db value +struct comp +{ + unsigned int num; + std::string str; + + std::vector nums; + + bool + operator== (const comp& y) const + { + return num == y.num && str == y.str && nums == y.nums; + } +}; + +#pragma db object +struct base +{ + #pragma db id auto + unsigned long id_; + + comp comp_; + + unsigned int num_; + std::string str_; + + std::vector strs_; + + bool + operator== (const base& y) const + { + return + id_ == y.id_ && + comp_ == y.comp_ && + num_ == y.num_ && + str_ == y.str_ && + strs_ == y.strs_; + } +}; + +#pragma db object +struct object1: base +{ + unsigned int num1_; + + bool + operator== (const object1& y) const + { + return static_cast (*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 (*this) == y && str_ == y.str_; + } +}; + +#pragma db object +struct reference +{ + #pragma db id auto + unsigned long id_; + + object1* o1_; +}; + +#endif // TEST_HXX -- cgit v1.1