capability 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     /*@{*/
41
42     /** */
43     using boost::scoped_ptr;
44
45     /** */
46     using boost::shared_ptr;
47
48     /** */
49     using boost::weak_ptr;
50
51     /** Use boost::intrusive_ptr as Ptr type*/
52     using boost::intrusive_ptr;
53     using boost::static_pointer_cast;
54     using boost::const_pointer_cast;
55     using boost::dynamic_pointer_cast;
56
57     /*@}*/
58
59     /////////////////////////////////////////////////////////////////
60   } // namespace base
61   ///////////////////////////////////////////////////////////////////
62   /////////////////////////////////////////////////////////////////
63 } // namespace zypp
64 ///////////////////////////////////////////////////////////////////
65
66 /** Forward declaration of Ptr types */
67 #define DEFINE_PTR_TYPE(NAME) \
68 class NAME;                                                      \
69 extern void intrusive_ptr_add_ref( const NAME * );               \
70 extern void intrusive_ptr_release( const NAME * );               \
71 typedef zypp::base::intrusive_ptr<NAME>       NAME##Ptr;         \
72 typedef zypp::base::intrusive_ptr<const NAME> const##NAME##Ptr;
73
74 ///////////////////////////////////////////////////////////////////
75 #endif // ZYPP_BASE_PTRTYPES_H