- Added template class base::KindOf<Type>
[platform/upstream/libzypp.git] / zypp / Resolvable.h
1 /*---------------------------------------------------------------------\
2 |                          ____ _   __ __ ___                          |
3 |                         |__  / \ / / . \ . \                         |
4 |                           / / \ V /|  _/  _/                         |
5 |                          / /__ | | | | | |                           |
6 |                         /_____||_| |_| |_|                           |
7 |                                                                      |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/Resolvable.h
10  *
11 */
12 #ifndef ZYPP_RESOLVABLE_H
13 #define ZYPP_RESOLVABLE_H
14
15 #include <iosfwd>
16 #include <string>
17
18 #include "zypp/base/ReferenceCounted.h"
19 #include "zypp/base/NonCopyable.h"
20 #include "zypp/base/PtrTypes.h"
21 #include "zypp/ResTraits.h"
22
23 #include "zypp/Edition.h"
24 #include "zypp/Arch.h"
25 #include "zypp/Dependencies.h"
26
27 ///////////////////////////////////////////////////////////////////
28 namespace zypp
29 { /////////////////////////////////////////////////////////////////
30
31   ///////////////////////////////////////////////////////////////////
32   //
33   //    CLASS NAME : Resolvable
34   //
35   /** Interface base for resolvable objects (identification and dependencies).
36   */
37   class Resolvable : public base::ReferenceCounted, private base::NonCopyable
38   {
39   public:
40     typedef Resolvable               Self;
41     typedef ResTraits<Self>          TraitsType;
42     typedef TraitsType::KindType     Kind;
43     typedef TraitsType::PtrType      Ptr;
44     typedef TraitsType::constPtrType constPtr;
45     friend std::ostream & operator<<( std::ostream & str, const Resolvable & obj );
46
47   public:
48     /**  */
49     const Kind & kind() const;
50     /**  */
51     const std::string & name() const;
52     /**  */
53     const Edition & edition() const;
54     /**  */
55     const Arch & arch() const;
56     /**  */
57     const Dependencies & deps() const;
58     /** */
59     void setDeps( const Dependencies & val_r );
60
61   protected:
62     /** Ctor */
63     Resolvable( const Kind & kind_r,
64                 const std::string & name_r,
65                 const Edition & edition_r,
66                 const Arch & arch_r );
67     /** Dtor */
68     virtual ~Resolvable();
69     /** Helper for stream output */
70     virtual std::ostream & dumpOn( std::ostream & str ) const;
71
72   private:
73     /** Implementation */
74     struct Impl;
75     /** Pointer to implementation */
76     base::ImplPtr<Impl> _pimpl;
77   };
78   ///////////////////////////////////////////////////////////////////
79
80
81
82
83   ///////////////////////////////////////////////////////////////////
84
85   /** Required by base::intrusive_ptr to add a reference. */
86   inline void intrusive_ptr_add_ref( const Resolvable * ptr_r )
87   { base::ReferenceCounted::add_ref( ptr_r ); }
88
89   /** Required by base::intrusive_ptr to release a reference. */
90   inline void intrusive_ptr_release( const Resolvable * ptr_r )
91   { base::ReferenceCounted::release( ptr_r ); }
92
93   /** \relates Resolvable Stream output via Resolvable::dumpOn */
94   inline std::ostream & operator<<( std::ostream & str, const Resolvable & obj )
95   { return obj.dumpOn( str ); }
96
97   /////////////////////////////////////////////////////////////////
98 } // namespace zypp
99 ///////////////////////////////////////////////////////////////////
100 #endif // ZYPP_RESOLVABLE_H