diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2014-08-01 07:15:19 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2014-08-01 11:06:23 +0200 |
commit | 06c7e4520615c9d9d7882fb13be5632a709ad5ac (patch) | |
tree | b40d71ac58585bd7092058a7cacb97968b846d2b /common/object/test.hxx | |
parent | 43e329f4cf9c175960154e395556eca23c170a75 (diff) |
Add support for defining persistent objects as class template instantiations
Diffstat (limited to 'common/object/test.hxx')
-rw-r--r-- | common/object/test.hxx | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/common/object/test.hxx b/common/object/test.hxx new file mode 100644 index 0000000..aec17c6 --- /dev/null +++ b/common/object/test.hxx @@ -0,0 +1,45 @@ +// file : common/object/test.hxx +// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include <string> +#include <utility> // std::pair + +#include <odb/core.hxx> + +// Test persistent class template instantiation. +// +#pragma db namespace table("t1_") +namespace test1 +{ + typedef std::pair<unsigned long, std::string> pair_object; + #pragma db object(pair_object) + #pragma db member(pair_object::first) id auto + + #pragma db object abstract + struct base_data + { + #pragma db id auto + unsigned long id; + }; + + template <typename T> + struct base: base_data + { + T x; + }; + + typedef base<std::string> base_derived; + #pragma db object(base_derived) abstract + + #pragma db object + struct derived: base_derived + { + int n; + }; +} + +#endif // TEST_HXX |