6 #include "zypp/base/ReferenceCounted.h"
7 #include "zypp/base/NonCopyable.h"
8 #include <zypp/base/PtrTypes.h>
12 ///////////////////////////////////////////////////////////////////
14 class Resolvable : public zypp::base::ReferenceCounted, private zypp::base::NonCopyable
16 friend std::ostream & operator<<( std::ostream & str, const Resolvable & res );
21 typedef Resolvable Self;
22 typedef zypp::base::intrusive_ptr<Self> Ptr;
23 typedef zypp::base::intrusive_ptr<const Self> constPtr;
25 Resolvable( const string kind_r /*NVRA*/ );
26 virtual ~Resolvable();
27 virtual std::ostream & dumpOn( std::ostream & str ) const;
30 zypp::base::ImplPtr<Impl> _impl;
33 inline void intrusive_ptr_add_ref( const Resolvable * ptr_r )
34 { zypp::base::ReferenceCounted::add_ref( ptr_r ); }
35 inline void intrusive_ptr_release( const Resolvable * ptr_r )
36 { zypp::base::ReferenceCounted::release( ptr_r ); }
38 inline std::ostream & operator<<( std::ostream & str, const Resolvable & res )
39 { return res.dumpOn( str ); }
41 ///////////////////////////////////////////////////////////////////
43 // connect resolvables interface and implementation.
45 struct ResImplConnect : public _Res
48 typedef ResImplConnect Self;
49 typedef typename _Res::Impl Impl;
50 typedef zypp::base::shared_ptr<Impl> ImplPtr;
51 typedef zypp::base::intrusive_ptr<Self> Ptr;
52 typedef zypp::base::intrusive_ptr<const Self> constPtr;
54 ResImplConnect( /*NVRA*/ ImplPtr impl_r )
55 : _impl( impl_r ? impl_r : ImplPtr(new Impl /*NVRA*/) )
56 { _impl->_backRef = this; }
57 virtual ~ResImplConnect() {}
60 virtual Impl & impl() { return *_impl; }
61 virtual const Impl & impl() const { return *_impl; }
66 typename _Impl::ResType::Ptr
67 makeResolvable( /*NVRA*/ zypp::base::shared_ptr<_Impl> & impl_r )
69 impl_r.reset( new _Impl );
70 return new ResImplConnect<typename _Impl::ResType>( /*NVRA*/ impl_r );
73 ///////////////////////////////////////////////////////////////////
79 const Resolvable * self() const { return _backRef; }
80 Resolvable * self() { return _backRef; }
82 virtual string summary() const { return string(); }
83 virtual list<string> description() const { return list<string>(); }
84 //virtual FSize size() const { return 0; }
85 //virtual bool providesSources() const { return false; }
90 virtual ~ObjectImpl() {};
95 Resolvable * _backRef;
98 class Object : public Resolvable
101 string summary() const;
102 list<string> description() const;
103 //FSize size() const;
104 //bool providesSources() const;
107 typedef ObjectImpl Impl;
108 typedef zypp::base::intrusive_ptr<Self> Ptr;
109 typedef zypp::base::intrusive_ptr<const Self> constPtr;
111 Object( const string kind_r /*NVRA*/ );
114 virtual Impl & impl() = 0;
115 virtual const Impl & impl() const = 0;
118 ///////////////////////////////////////////////////////////////////
120 struct PackageImpl : public ObjectImpl
122 typedef Package ResType;
123 virtual string packagedata() const { return string(); }
126 class Package : public Object
129 string packagedata() const;
131 typedef Package Self;
132 typedef PackageImpl Impl;
133 typedef zypp::base::intrusive_ptr<Self> Ptr;
134 typedef zypp::base::intrusive_ptr<const Self> constPtr;
139 virtual Impl & impl() = 0;
140 virtual const Impl & impl() const = 0;
143 ///////////////////////////////////////////////////////////////////
146 struct SelectionImpl : public ObjectImpl
148 typedef Selection ResType;
149 virtual string selectiondata() const { return string(); }
152 class Selection : public Object
155 string selectiondata() const;
157 typedef Selection Self;
158 typedef SelectionImpl Impl;
159 typedef zypp::base::intrusive_ptr<Self> Ptr;
160 typedef zypp::base::intrusive_ptr<const Self> constPtr;
162 Selection( /*NVRA*/ );
163 virtual ~Selection();
165 virtual Impl & impl() = 0;
166 virtual const Impl & impl() const = 0;
169 ///////////////////////////////////////////////////////////////////