From 95cac11338b33db1a7999904241ef0cb018550f3 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 1 Aug 2014 07:15:19 +0200 Subject: Add support for defining persistent objects as class template instantiations --- odb/traits.hxx | 60 +++++++++++++++++++--------------------------------------- 1 file 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 + 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 class access::object_factory { @@ -140,47 +159,6 @@ namespace odb static const bool polymorphic = access::object_traits::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 - struct object_traits - { - struct id_type {}; - }; - - template - struct object_traits - { - struct id_type {}; - }; - - template class P> - struct object_traits > - { - struct id_type {}; - }; - - template class P> - struct object_traits > - { - struct id_type {}; - }; - - template class P> - struct object_traits > - { - struct id_type {}; - }; - - template class P> - struct object_traits > - { - struct id_type {}; - }; - // Specialization for section to allow instantiation of all the load() // signature. // -- cgit v1.1