1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/ResObject.h
12 #ifndef ZYPP_RESOBJECT_H
13 #define ZYPP_RESOBJECT_H
15 #include "zypp/base/Deprecated.h"
17 #include "zypp/Resolvable.h"
18 #include "zypp/Date.h"
19 #include "zypp/Locale.h"
20 #include "zypp/Vendor.h"
21 #include "zypp/ByteCount.h"
22 #include "zypp/DiskUsage.h"
23 #include "zypp/OnMediaLocation.h"
24 #include "zypp/Repository.h"
26 #include "zypp/sat/LookupAttr.h"
27 #include "zypp/sat/SolvableSet.h"
29 ///////////////////////////////////////////////////////////////////
31 { /////////////////////////////////////////////////////////////////
33 ///////////////////////////////////////////////////////////////////
35 // CLASS NAME : ResObject
38 * Interface base for resolvable objects (common data).
39 * That is, all data not needed for solving, but common
40 * across all Resolvable kinds.
42 * \see \ref makeResObject for how to construct ResObjects.
44 class ResObject : public Resolvable
47 typedef ResObject Self;
48 typedef ResTraits<Self> TraitsType;
49 typedef TraitsType::PtrType Ptr;
50 typedef TraitsType::constPtrType constPtr;
53 /** \name Locale support.
54 * \see \ref sat::Solvable
57 /** \see \ref sat::Solvable::supportsLocales */
58 using sat::Solvable::supportsLocales;
59 /** \see \ref sat::Solvable::supportsLocale */
60 using sat::Solvable::supportsLocale;
61 /** \see \ref sat::Solvable::supportsRequestedLocales */
62 using sat::Solvable::supportsRequestedLocales;
63 /** \see \ref sat::Solvable::getSupportedLocales */
64 using sat::Solvable::getSupportedLocales;
69 * \short Short text describing the resolvable.
70 * This attribute is usually displayed in columns.
72 std::string summary( const Locale & lang_r = Locale() ) const;
75 * \short Long text describing the resolvable.
77 std::string description( const Locale & lang_r = Locale() ) const;
80 * \short Installation Notification
82 * This text can be used to tell the user some notes
83 * When he selects the resovable for installation.
85 std::string insnotify( const Locale & lang_r = Locale() ) const;
88 * \short De-Installation Notification
90 * This text can be used to tell the user some notes
91 * When he selects the resovable for deinstall.
93 std::string delnotify( const Locale & lang_r = Locale() ) const;
96 * \short License or agreement to accept
98 * Agreement, warning or license the user should
99 * accept before installing the resolvable.
101 std::string licenseToConfirm( const Locale & lang_r = Locale() ) const;
106 * For example "Novell Inc."
108 Vendor vendor() const
109 { return Resolvable::vendor().asString(); }
111 /** The distribution string.
114 std::string distribution() const;
116 /** Installed size. */
117 ByteCount installSize() const;
118 /** \deprecated Use installSize which is more precise.*/
119 ZYPP_DEPRECATED ByteCount installsize() const { return installSize(); }
120 /** \deprecated Use installSize which is more precise. */
121 ZYPP_DEPRECATED ByteCount size() const { return installSize(); }
123 /** Size of the rpm package. */
124 ByteCount downloadSize() const;
126 /** \see \ref sat::Solvable::repository */
127 using sat::Solvable::repository;
129 /** \ref RepoInfo associated with the repository
130 * providing this resolvable.
132 RepoInfo repoInfo() const
133 { return repository().info(); }
136 * Media number where the resolvable is located
137 * 0 if no media access is required.
139 unsigned mediaNr() const;
142 * \short build time of the resolvable
144 Date buildtime() const;
147 * \short Installation time
148 * 0 if the resolvable is not installed.
150 Date installtime() const;
153 * \short Disk usage per directory
154 * A common attribute, although mostly packages require
155 * noticeable disk space. An e.g product could try to reserve
156 * a certain ammount of diskspace by providing DiskUsage data.
158 const DiskUsage & diskusage() const;
161 friend ResObject::Ptr makeResObject( const sat::Solvable & solvable_r );
163 ResObject( const sat::Solvable & solvable_r );
165 virtual ~ResObject();
166 /** Helper for stream output */
167 virtual std::ostream & dumpOn( std::ostream & str ) const;
169 ///////////////////////////////////////////////////////////////////
171 /** Create \ref ResObject from \ref sat::Solvable.
173 * This function creates the apropriate kind of ResObject
174 * depending on the sat::Solvables kind, and returns a smart
177 * If the sat::Solvables kind is not convertible, a NULL
178 * pointer is returned.
182 * ResObject::Ptr p( makeResObject( s ) );
183 * ResObject::Ptr q( make<ResObject>( s ) );
184 * Package::Ptr pkg( make<Package>( s ) );
187 ResObject::Ptr makeResObject( const sat::Solvable & solvable_r );
189 /** Directly create a certain kind of ResObject from \ref sat::Solvable.
191 * If the sat::Solvables kind is not appropriate, a NULL
192 * pointer is returned.
195 * ResObject::Ptr p( makeResObject( s ) );
196 * ResObject::Ptr q( make<ResObject>( s ) );
197 * Package::Ptr pkg( make<Package>( s ) );
201 inline typename ResTraits<_Res>::PtrType make( const sat::Solvable & solvable_r )
202 { return( isKind<_Res>( solvable_r ) ? new _Res( solvable_r ) : 0 ); }
203 /** \overload Specialisation for ResObject autodetecting the kind of resolvable. */
205 inline ResObject::Ptr make<ResObject>( const sat::Solvable & solvable_r )
206 { return makeResObject( solvable_r ); }
208 /** Convert ResObject::Ptr into Ptr of a certain Kind.
209 * \return \c NULL iff \a p is \c NULL or points to a Resolvable
210 * not of the specified Kind.
213 * asKind<Package>(resPtr);
217 inline typename ResTraits<_Res>::PtrType asKind( const ResObject::Ptr & p )
218 { return dynamic_pointer_cast<_Res>(p); }
221 inline typename ResTraits<_Res>::constPtrType asKind( const ResObject::constPtr & p )
222 { return dynamic_pointer_cast<const _Res>(p); }
224 /////////////////////////////////////////////////////////////////
226 ///////////////////////////////////////////////////////////////////
227 #endif // ZYPP_RESOBJECT_H