67fb81b5c17d0a82891ffab75733e69e2c2ece7d
[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/ResKind.h"
24 #include "zypp/Edition.h"
25 #include "zypp/Arch.h"
26 #include "zypp/Dependencies.h"
27
28 ///////////////////////////////////////////////////////////////////
29 namespace zypp
30 { /////////////////////////////////////////////////////////////////
31
32   ///////////////////////////////////////////////////////////////////
33   //
34   //    CLASS NAME : Resolvable
35   //
36   /** Interface base for resolvable objects (identification and dependencies).
37    * \todo Solve ResKind problems via traits template?
38   */
39   class Resolvable : public base::ReferenceCounted, private base::NonCopyable
40   {
41   public:
42     typedef Resolvable                      Self;
43     typedef base::intrusive_ptr<Self>       Ptr;
44     typedef base::intrusive_ptr<const Self> constPtr;
45     friend std::ostream & operator<<( std::ostream & str, const Resolvable & obj );
46
47   public:
48     /**  */
49     const ResKind & 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 ResKind & 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