diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2014-08-01 07:15:19 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2014-08-01 07:15:19 +0200 |
commit | 95cac11338b33db1a7999904241ef0cb018550f3 (patch) | |
tree | e8b0de818161f928afd38b3d7d0ec73e252ea1fe | |
parent | f8317dd174c60f7fdb1a535abe8a4d8d215e528e (diff) |
Add support for defining persistent objects as class template instantiations
-rw-r--r-- | odb/traits.hxx | 60 |
1 files changed, 19 insertions, 41 deletions
diff --git a/odb/traits.hxx b/odb/traits.hxx index 495d972..5dfee3a 100644 --- a/odb/traits.hxx +++ b/odb/traits.hxx @@ -12,6 +12,25 @@ namespace odb { + // Fallback dummy for non-persistent classes. It is necessary to allow + // the C++ compiler to instantiate persist(), etc., signatures in class + // database when T is a pointer (raw, smart). The overloads that use + // these dummy would never actually be selected by the compiler. + // + template <typename T> + class access::object_traits + { + // If a C++ compiler issues an error pointing to this c;ass and saying + // that it missing some declaration, then you are most likely trying to + // perform a database operation on a C++ type that is not a persistent + // object. Or you forgot to include the corresponding -odb.hxx file. + // + public: + struct id_type {}; + typedef T object_type; + typedef T* pointer_type; + }; + template <typename T, typename P> class access::object_factory { @@ -140,47 +159,6 @@ namespace odb static const bool polymorphic = access::object_traits<T>::polymorphic; }; - // Specializations for pointer types to allow the C++ compiler to - // instantiate persist(), etc., signatures in class database. The - // overloads that use these specializations would never actually - // be selected by the compiler. - // - template <typename T> - struct object_traits<T*> - { - struct id_type {}; - }; - - template <typename T> - struct object_traits<T* const> - { - struct id_type {}; - }; - - template <typename T, template <typename> class P> - struct object_traits<P<T> > - { - struct id_type {}; - }; - - template <typename T, typename A1, template <typename, typename> class P> - struct object_traits<P<T, A1> > - { - struct id_type {}; - }; - - template <typename T, template <typename> class P> - struct object_traits<const P<T> > - { - struct id_type {}; - }; - - template <typename T, typename A1, template <typename, typename> class P> - struct object_traits<const P<T, A1> > - { - struct id_type {}; - }; - // Specialization for section to allow instantiation of all the load() // signature. // |