backup
[platform/upstream/libzypp.git] / zypp / base / PtrTypes.h
1 /*---------------------------------------------------------------------\
2 |                          ____ _   __ __ ___                          |
3 |                         |__  / \ / / . \ . \                         |
4 |                           / / \ V /|  _/  _/                         |
5 |                          / /__ | | | | | |                           |
6 |                         /_____||_| |_| |_|                           |
7 |                                                                      |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/base/PtrTypes.h
10  *  \ingroup ZYPP_BASE_SMART_PTR
11  *  \see ZYPP_BASE_SMART_PTR
12 */
13 #ifndef ZYPP_BASE_PTRTYPES_H
14 #define ZYPP_BASE_PTRTYPES_H
15
16 #include <boost/scoped_ptr.hpp>
17 #include <boost/shared_ptr.hpp>
18 #include <boost/weak_ptr.hpp>
19 #include <boost/intrusive_ptr.hpp>
20
21 ///////////////////////////////////////////////////////////////////
22 namespace zypp
23 { /////////////////////////////////////////////////////////////////
24   ///////////////////////////////////////////////////////////////////
25   namespace base
26   { /////////////////////////////////////////////////////////////////
27
28     /** \defgroup ZYPP_BASE_SMART_PTR ZYPP_BASE_SMART_PTR
29      *  Smart pointer types.
30      *
31      * Namespace zypp::base provides 3 smart pointer types \b using the
32      * boostsmart pointer library.
33      *
34      * \li \c scoped_ptr Simple sole ownership of single objects. Noncopyable.
35      *
36      * \li \c shared_ptr Object ownership shared among multiple pointers
37      *
38      * \li \c weak_ptr Non-owning observers of an object owned by shared_ptr.
39      *
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.
43     */
44     /*@{*/
45
46     /** */
47     using boost::scoped_ptr;
48
49     /** */
50     using boost::shared_ptr;
51
52     /** */
53     using boost::weak_ptr;
54
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;
60
61     /*@}*/
62
63     /////////////////////////////////////////////////////////////////
64   } // namespace base
65   ///////////////////////////////////////////////////////////////////
66   /////////////////////////////////////////////////////////////////
67 } // namespace zypp
68 ///////////////////////////////////////////////////////////////////
69
70 /** Forward declaration of Ptr types */
71 #define DEFINE_PTR_TYPE(NAME) \
72 class 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;
77
78 ///////////////////////////////////////////////////////////////////
79 #endif // ZYPP_BASE_PTRTYPES_H