Refined Resolvables interfaces, implementatio interfaces, factory
[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
22 #include "zypp/ResKind.h"
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 depndencies).
36    * \todo Solve ResKind problems via traits template?
37   */
38   class Resolvable : public base::ReferenceCounted, private base::NonCopyable
39   {
40   public:
41     typedef Resolvable                      Self;
42     typedef base::intrusive_ptr<Self>       Ptr;
43     typedef base::intrusive_ptr<const Self> constPtr;
44     friend std::ostream & operator<<( std::ostream & str, const Resolvable & obj );
45
46   public:
47     /**  */
48     const ResKind & kind() const;
49     /**  */
50     const std::string & name() const;
51     /**  */
52     const Edition & edition() const;
53     /**  */
54     const Arch & arch() const;
55     /**  */
56     const Dependencies & deps() const;
57     /** */
58     void setDeps( const Dependencies & val_r );
59
60   protected:
61     /** Ctor */
62     Resolvable( const ResKind & kind_r,
63                 const std::string & name_r,
64                 const Edition & edition_r,
65                 const Arch & arch_r );
66     /** Dtor */
67     virtual ~Resolvable();
68     /** Helper for stream output */
69     virtual std::ostream & dumpOn( std::ostream & str ) const;
70
71   private:
72     /** Implementation */
73     struct Impl;
74     /** Pointer to implementation */
75     base::ImplPtr<Impl> _pimpl;
76   };
77   ///////////////////////////////////////////////////////////////////
78
79   /** Required by base::intrusive_ptr to add a reference. */
80   inline void intrusive_ptr_add_ref( const Resolvable * ptr_r )
81   { base::ReferenceCounted::add_ref( ptr_r ); }
82
83   /** Required by base::intrusive_ptr to release a reference. */
84   inline void intrusive_ptr_release( const Resolvable * ptr_r )
85   { base::ReferenceCounted::release( ptr_r ); }
86
87   /** \relates Resolvable Stream output via Resolvable::dumpOn */
88   inline std::ostream & operator<<( std::ostream & str, const Resolvable & obj )
89   { return obj.dumpOn( str ); }
90
91   /////////////////////////////////////////////////////////////////
92 } // namespace zypp
93 ///////////////////////////////////////////////////////////////////
94 #endif // ZYPP_RESOLVABLE_H