1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/base/PtrTypes.h
10 * \ingroup ZYPP_BASE_SMART_PTR
11 * \see ZYPP_BASE_SMART_PTR
13 #ifndef ZYPP_BASE_PTRTYPES_H
14 #define ZYPP_BASE_PTRTYPES_H
16 #include <boost/scoped_ptr.hpp>
17 #include <boost/shared_ptr.hpp>
18 #include <boost/weak_ptr.hpp>
19 #include <boost/intrusive_ptr.hpp>
21 ///////////////////////////////////////////////////////////////////
23 { /////////////////////////////////////////////////////////////////
24 ///////////////////////////////////////////////////////////////////
26 { /////////////////////////////////////////////////////////////////
28 /** \defgroup ZYPP_BASE_SMART_PTR ZYPP_BASE_SMART_PTR
29 * Smart pointer types.
31 * Namespace zypp::base provides 3 smart pointer types \b using the
32 * boostsmart pointer library.
34 * \li \c scoped_ptr Simple sole ownership of single objects. Noncopyable.
36 * \li \c shared_ptr Object ownership shared among multiple pointers
38 * \li \c weak_ptr Non-owning observers of an object owned by shared_ptr.
40 * \todo Intrusive Ptr class which supports constness. Used as PIMPL.
41 * Offers 'const Impl *' in const context, otherwise 'Impl *'. to
42 * prevent const classes from calling nonconst Impl methods.
47 using boost::scoped_ptr;
50 using boost::shared_ptr;
53 using boost::weak_ptr;
55 /** Use boost::intrusive_ptr as Ptr type*/
56 using boost::intrusive_ptr;
57 using boost::static_pointer_cast;
58 using boost::const_pointer_cast;
59 using boost::dynamic_pointer_cast;
63 /////////////////////////////////////////////////////////////////
65 ///////////////////////////////////////////////////////////////////
66 /////////////////////////////////////////////////////////////////
68 ///////////////////////////////////////////////////////////////////
70 /** Forward declaration of Ptr types */
71 #define DEFINE_PTR_TYPE(NAME) \
73 extern void intrusive_ptr_add_ref( const NAME * ); \
74 extern void intrusive_ptr_release( const NAME * ); \
75 typedef zypp::base::intrusive_ptr<NAME> NAME##Ptr; \
76 typedef zypp::base::intrusive_ptr<const NAME> const##NAME##Ptr;
78 ///////////////////////////////////////////////////////////////////
79 #endif // ZYPP_BASE_PTRTYPES_H