| lazy-pointer-traits.hxx | | lazy-pointer-traits.hxx | |
| | | | |
| skipping to change at line 20 | | skipping to change at line 20 | |
| | | | |
| #include <odb/pointer-traits.hxx> | | #include <odb/pointer-traits.hxx> | |
| #include <odb/lazy-ptr.hxx> | | #include <odb/lazy-ptr.hxx> | |
| | | | |
| namespace odb | | namespace odb | |
| { | | { | |
| template <typename T> | | template <typename T> | |
| class pointer_traits< lazy_ptr<T> > | | class pointer_traits< lazy_ptr<T> > | |
| { | | { | |
| public: | | public: | |
|
| static pointer_kind const kind = pk_raw; | | static const pointer_kind kind = pk_raw; | |
| static bool const lazy = true; | | static const bool lazy = true; | |
| | | | |
| typedef T element_type; | | typedef T element_type; | |
| typedef lazy_ptr<element_type> pointer_type; | | typedef lazy_ptr<element_type> pointer_type; | |
| typedef element_type* eager_pointer_type; | | typedef element_type* eager_pointer_type; | |
| | | | |
| static bool | | static bool | |
| null_ptr (const pointer_type& p) | | null_ptr (const pointer_type& p) | |
| { | | { | |
| return !p; | | return !p; | |
| } | | } | |
| | | | |
| skipping to change at line 45 | | skipping to change at line 45 | |
| object_id (const pointer_type& p) | | object_id (const pointer_type& p) | |
| { | | { | |
| return p.object_id<O> (); | | return p.object_id<O> (); | |
| } | | } | |
| }; | | }; | |
| | | | |
| template <typename T> | | template <typename T> | |
| class pointer_traits< lazy_auto_ptr<T> > | | class pointer_traits< lazy_auto_ptr<T> > | |
| { | | { | |
| public: | | public: | |
|
| static pointer_kind const kind = pk_unique; | | static const pointer_kind kind = pk_unique; | |
| static bool const lazy = true; | | static const bool lazy = true; | |
| | | | |
| typedef T element_type; | | typedef T element_type; | |
| typedef lazy_auto_ptr<element_type> pointer_type; | | typedef lazy_auto_ptr<element_type> pointer_type; | |
| typedef std::auto_ptr<element_type> eager_pointer_type; | | typedef std::auto_ptr<element_type> eager_pointer_type; | |
| | | | |
| static bool | | static bool | |
| null_ptr (const pointer_type& p) | | null_ptr (const pointer_type& p) | |
| { | | { | |
| return !p; | | return !p; | |
| } | | } | |
| | | | |
End of changes. 2 change blocks. |
| 4 lines changed or deleted | | 4 lines changed or added | |
|
| lazy-ptr-impl.hxx | | lazy-ptr-impl.hxx | |
| | | | |
| skipping to change at line 66 | | skipping to change at line 66 | |
| | | | |
| void | | void | |
| swap (lazy_ptr_base&); | | swap (lazy_ptr_base&); | |
| | | | |
| database_type* | | database_type* | |
| database () const; | | database () const; | |
| | | | |
| typedef void* lazy_ptr_base::*unspecified_bool_type; | | typedef void* lazy_ptr_base::*unspecified_bool_type; | |
| operator unspecified_bool_type () const | | operator unspecified_bool_type () const | |
| { | | { | |
|
| return id_ != 0 ? &lazy_ptr_base::id_ : 0; | | return db_ != 0 ? &lazy_ptr_base::id_ : 0; | |
| } | | } | |
| | | | |
| operator lazy_ptr_impl_ref (); | | operator lazy_ptr_impl_ref (); | |
| | | | |
| protected: | | protected: | |
| typedef void (*free_func) (void*); | | typedef void (*free_func) (void*); | |
| typedef void* (*copy_func) (const void*); | | typedef void* (*copy_func) (const void*); | |
| | | | |
| // Makes a copy of id. | | // Makes a copy of id. | |
| // | | // | |
| | | | |
End of changes. 1 change blocks. |
| 1 lines changed or deleted | | 1 lines changed or added | |
|
| lazy-ptr.hxx | | lazy-ptr.hxx | |
| | | | |
| skipping to change at line 56 | | skipping to change at line 56 | |
| operator unspecified_bool_type () const | | operator unspecified_bool_type () const | |
| { | | { | |
| return (p_ || i_) ? &lazy_ptr::p_ : 0; | | return (p_ || i_) ? &lazy_ptr::p_ : 0; | |
| } | | } | |
| | | | |
| // Lazy loading interface. | | // Lazy loading interface. | |
| // | | // | |
| public: | | public: | |
| typedef odb::database database_type; | | typedef odb::database database_type; | |
| | | | |
|
| | | // NULL loaded() | |
| | | // | |
| | | // true true NULL pointer to transient object | |
| | | // false true valid pointer to persistent object | |
| | | // true false unloaded pointer to persistent object | |
| | | // false false valid pointer to transient object | |
| | | // | |
| bool loaded () const; | | bool loaded () const; | |
|
| | | | |
| T* load () const; | | T* load () const; | |
| | | | |
| // Unload the pointer. For transient objects this function is | | // Unload the pointer. For transient objects this function is | |
| // equivalent to reset(). | | // equivalent to reset(). | |
| // | | // | |
| void unload () const; | | void unload () const; | |
| | | | |
| template <class ID> lazy_ptr (database_type&, const ID&); | | template <class ID> lazy_ptr (database_type&, const ID&); | |
| template <class Y> lazy_ptr (database_type&, Y*); | | template <class Y> lazy_ptr (database_type&, Y*); | |
| | | | |
| | | | |
| skipping to change at line 157 | | skipping to change at line 165 | |
| lazy_auto_ptr (std::auto_ptr_ref<T>); | | lazy_auto_ptr (std::auto_ptr_ref<T>); | |
| | | | |
| template <class Y> lazy_auto_ptr& operator= (std::auto_ptr<Y>&); | | template <class Y> lazy_auto_ptr& operator= (std::auto_ptr<Y>&); | |
| lazy_auto_ptr& operator= (std::auto_ptr_ref<T>); | | lazy_auto_ptr& operator= (std::auto_ptr_ref<T>); | |
| | | | |
| // Lazy loading interface. | | // Lazy loading interface. | |
| // | | // | |
| public: | | public: | |
| typedef odb::database database_type; | | typedef odb::database database_type; | |
| | | | |
|
| | | // NULL loaded() | |
| | | // | |
| | | // true true NULL pointer to transient object | |
| | | // false true valid pointer to persistent object | |
| | | // true false unloaded pointer to persistent object | |
| | | // false false valid pointer to transient object | |
| | | // | |
| bool loaded () const; | | bool loaded () const; | |
|
| | | | |
| std::auto_ptr<T>& load () const; | | std::auto_ptr<T>& load () const; | |
| | | | |
| // Unload the pointer. For transient objects this function is | | // Unload the pointer. For transient objects this function is | |
| // equivalent to reset(). | | // equivalent to reset(). | |
| // | | // | |
| void unload () const; | | void unload () const; | |
| | | | |
| template <class ID> lazy_auto_ptr (database_type&, const ID&); | | template <class ID> lazy_auto_ptr (database_type&, const ID&); | |
| lazy_auto_ptr (database_type&, T*); | | lazy_auto_ptr (database_type&, T*); | |
| template <class Y> lazy_auto_ptr (database_type&, std::auto_ptr<Y>&); | | template <class Y> lazy_auto_ptr (database_type&, std::auto_ptr<Y>&); | |
| | | | |
End of changes. 4 change blocks. |
| 0 lines changed or deleted | | 16 lines changed or added | |
|
| lazy-ptr.ixx | | lazy-ptr.ixx | |
| | | | |
| skipping to change at line 111 | | skipping to change at line 111 | |
| inline T* lazy_ptr<T>:: | | inline T* lazy_ptr<T>:: | |
| get () const | | get () const | |
| { | | { | |
| return p_; | | return p_; | |
| } | | } | |
| | | | |
| template <class T> | | template <class T> | |
| inline bool lazy_ptr<T>:: | | inline bool lazy_ptr<T>:: | |
| loaded () const | | loaded () const | |
| { | | { | |
|
| return p_ || !i_; | | bool i (i_); | |
| | | return (p_ == 0) != i; // !p_ XOR i | |
| } | | } | |
| | | | |
| template <class T> | | template <class T> | |
| inline T* lazy_ptr<T>:: | | inline T* lazy_ptr<T>:: | |
| load () const | | load () const | |
| { | | { | |
| if (!loaded ()) | | if (!loaded ()) | |
| p_ = i_.template load<T> (true); // Reset id. | | p_ = i_.template load<T> (true); // Reset id. | |
| | | | |
| return p_; | | return p_; | |
| | | | |
| skipping to change at line 364 | | skipping to change at line 365 | |
| { | | { | |
| p_ = r; | | p_ = r; | |
| i_.reset (); | | i_.reset (); | |
| return *this; | | return *this; | |
| } | | } | |
| | | | |
| template <class T> | | template <class T> | |
| inline bool lazy_auto_ptr<T>:: | | inline bool lazy_auto_ptr<T>:: | |
| loaded () const | | loaded () const | |
| { | | { | |
|
| return p_.get () != 0 || !i_; | | bool i (i_); | |
| | | return (p_.get () == 0) != i; // XOR | |
| } | | } | |
| | | | |
| template <class T> | | template <class T> | |
| inline std::auto_ptr<T>& lazy_auto_ptr<T>:: | | inline std::auto_ptr<T>& lazy_auto_ptr<T>:: | |
| load () const | | load () const | |
| { | | { | |
| if (!loaded ()) | | if (!loaded ()) | |
| { | | { | |
| std::auto_ptr<T> tmp (i_.template load<T> (true)); // Reset id. | | std::auto_ptr<T> tmp (i_.template load<T> (true)); // Reset id. | |
| p_ = tmp; | | p_ = tmp; | |
| | | | |
End of changes. 2 change blocks. |
| 2 lines changed or deleted | | 4 lines changed or added | |
|
| lazy-ptr.txx | | lazy-ptr.txx | |
| | | | |
| skipping to change at line 17 | | skipping to change at line 17 | |
| { | | { | |
| // | | // | |
| // lazy_ptr | | // lazy_ptr | |
| // | | // | |
| | | | |
| template <class T> | | template <class T> | |
| template <class Y> | | template <class Y> | |
| bool lazy_ptr<T>:: | | bool lazy_ptr<T>:: | |
| equal (const lazy_ptr<Y>& r) const | | equal (const lazy_ptr<Y>& r) const | |
| { | | { | |
|
| if (loaded () && r.loaded ()) | | bool t1 ((p_ == 0) == loaded ()); | |
| | | bool t2 ((r.p_ == 0) == r.loaded ()); | |
| | | | |
| | | // If both are transient, then compare the underlying pointers. | |
| | | // | |
| | | if (t1 && t2) | |
| return p_ == r.p_; | | return p_ == r.p_; | |
| | | | |
|
| // If one of the object is not loaded, then we compare databases and | | // If one is transient and the other is persistent, then compare | |
| // object ids. Note that NULL pointers cannot have non-NULL databases | | // the underlying pointers but only if they are non NULL. Note | |
| // and if both of them are NULL, we wouldn't have gotten here. | | // that an unloaded persistent object is always unequal to a | |
| | | // transient object. | |
| | | // | |
| | | if (t1 || t2) | |
| | | return p_ == r.p_ && p_ != 0; | |
| | | | |
| | | // If both objects are persistent, then we compare databases and | |
| | | // object ids. | |
| // | | // | |
| typedef typename object_traits<T>::object_type object_type1; | | typedef typename object_traits<T>::object_type object_type1; | |
| typedef typename object_traits<Y>::object_type object_type2; | | typedef typename object_traits<Y>::object_type object_type2; | |
| | | | |
| return i_.database () == r.i_.database () && | | return i_.database () == r.i_.database () && | |
| object_id<object_type1> () == r.object_id<object_type2> (); | | object_id<object_type1> () == r.object_id<object_type2> (); | |
| } | | } | |
| } | | } | |
| | | | |
End of changes. 2 change blocks. |
| 4 lines changed or deleted | | 16 lines changed or added | |
|
| pointer-traits.hxx | | pointer-traits.hxx | |
| | | | |
| skipping to change at line 78 | | skipping to change at line 78 | |
| void | | void | |
| reset (const P&) {} | | reset (const P&) {} | |
| }; | | }; | |
| | | | |
| // Specialization for raw pointers. | | // Specialization for raw pointers. | |
| // | | // | |
| template <typename T> | | template <typename T> | |
| class pointer_traits<T*> | | class pointer_traits<T*> | |
| { | | { | |
| public: | | public: | |
|
| static pointer_kind const kind = pk_raw; | | static const pointer_kind kind = pk_raw; | |
| static bool const lazy = false; | | static const bool lazy = false; | |
| | | | |
| typedef T element_type; | | typedef T element_type; | |
| typedef T* pointer_type; | | typedef T* pointer_type; | |
| typedef const T* const_pointer_type; | | typedef const T* const_pointer_type; | |
| typedef raw_ptr_guard<pointer_type> guard; | | typedef raw_ptr_guard<pointer_type> guard; | |
| | | | |
| // Return raw pointer to the pointed-to element, including NULL. | | // Return raw pointer to the pointed-to element, including NULL. | |
| // | | // | |
| static element_type* | | static element_type* | |
| get_ptr (pointer_type p) | | get_ptr (pointer_type p) | |
| | | | |
| skipping to change at line 139 | | skipping to change at line 139 | |
| operator delete (p); | | operator delete (p); | |
| } | | } | |
| }; | | }; | |
| | | | |
| // Specialization for std::auto_ptr. | | // Specialization for std::auto_ptr. | |
| // | | // | |
| template <typename T> | | template <typename T> | |
| class pointer_traits< std::auto_ptr<T> > | | class pointer_traits< std::auto_ptr<T> > | |
| { | | { | |
| public: | | public: | |
|
| static pointer_kind const kind = pk_unique; | | static const pointer_kind kind = pk_unique; | |
| static bool const lazy = false; | | static const bool lazy = false; | |
| | | | |
| typedef T element_type; | | typedef T element_type; | |
| typedef std::auto_ptr<element_type> pointer_type; | | typedef std::auto_ptr<element_type> pointer_type; | |
| typedef std::auto_ptr<const element_type> const_pointer_type; | | typedef std::auto_ptr<const element_type> const_pointer_type; | |
| typedef smart_ptr_guard<pointer_type> guard; | | typedef smart_ptr_guard<pointer_type> guard; | |
| | | | |
| static element_type* | | static element_type* | |
| get_ptr (const pointer_type& p) | | get_ptr (const pointer_type& p) | |
| { | | { | |
| return p.get (); | | return p.get (); | |
| | | | |
End of changes. 2 change blocks. |
| 4 lines changed or deleted | | 4 lines changed or added | |
|
| version.hxx | | version.hxx | |
| | | | |
| skipping to change at line 30 | | skipping to change at line 30 | |
| // Version AABBCCDD | | // Version AABBCCDD | |
| // 2.0.0 02000000 | | // 2.0.0 02000000 | |
| // 2.1.0 02010000 | | // 2.1.0 02010000 | |
| // 2.1.1 02010100 | | // 2.1.1 02010100 | |
| // 2.2.0.a1 02019901 | | // 2.2.0.a1 02019901 | |
| // 3.0.0.b2 02999952 | | // 3.0.0.b2 02999952 | |
| // | | // | |
| | | | |
| // ODB interface version: minor, major, and alpha/beta versions. | | // ODB interface version: minor, major, and alpha/beta versions. | |
| // | | // | |
|
| #define ODB_VERSION 10300 | | #define ODB_VERSION 10400 | |
| #define ODB_VERSION_STR "1.3" | | #define ODB_VERSION_STR "1.4" | |
| | | | |
| // libodb version: interface version plus the bugfix version. | | // libodb version: interface version plus the bugfix version. | |
| // | | // | |
|
| #define LIBODB_VERSION 1030000 | | #define LIBODB_VERSION 1040000 | |
| #define LIBODB_VERSION_STR "1.3.0" | | #define LIBODB_VERSION_STR "1.4.0" | |
| | | | |
| #include <odb/post.hxx> | | #include <odb/post.hxx> | |
| | | | |
| #endif // ODB_VERSION_HXX | | #endif // ODB_VERSION_HXX | |
| | | | |
End of changes. 2 change blocks. |
| 4 lines changed or deleted | | 4 lines changed or added | |
|