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;
70 * \short Short text describing the resolvable.
71 * This attribute is usually displayed in columns.
73 std::string summary( const Locale & lang_r = Locale() ) const;
76 * \short Long text describing the resolvable.
78 std::string description( const Locale & lang_r = Locale() ) const;
81 * \short Installation Notification
83 * This text can be used to tell the user some notes
84 * When he selects the resovable for installation.
86 std::string insnotify( const Locale & lang_r = Locale() ) const;
89 * \short De-Installation Notification
91 * This text can be used to tell the user some notes
92 * When he selects the resovable for deinstall.
94 std::string delnotify( const Locale & lang_r = Locale() ) const;
97 * \short License or agreement to accept
99 * Agreement, warning or license the user should
100 * accept before installing the resolvable.
102 std::string licenseToConfirm( const Locale & lang_r = Locale() ) const;
107 * For Example "Novell Inc."
109 Vendor vendor() const
110 { return Resolvable::vendor().asString(); }
112 /** Installed size. */
113 ByteCount installsize() const;
114 /** \deprecated Use installsize which is more precise. */
115 ZYPP_DEPRECATED ByteCount size() const
116 { return installsize(); }
118 /** Size of the rpm package. */
119 ByteCount downloadSize() const;
121 /** \see \ref sat::Solvable::repository */
122 using sat::Solvable::repository;
124 /** \ref RepoInfo associated with the repository
125 * providing this resolvable.
127 RepoInfo repoInfo() const
128 { return repository().info(); }
131 * Media number where the resolvable is located
132 * 0 if no media access is required.
134 unsigned mediaNr() const;
137 * \TODO FIXME what is this?
138 * Flag in the metadata indicating this should be
139 * installed unsing '-i' (not -U).
141 bool installOnly() const;
144 * \short build time of the resolvable
146 Date buildtime() const;
149 * \short Installation time
150 * 0 if the resolvable is not installed.
152 Date installtime() const;
155 * \short Disk usage per directory
156 * A common attribute, although mostly packages require
157 * noticeable disk space. An e.g product could try to reserve
158 * a certain ammount of diskspace by providing DiskUsage data.
160 const DiskUsage & diskusage() const;
164 ResObject( const sat::Solvable & solvable_r );
166 virtual ~ResObject();
167 /** Helper for stream output */
168 virtual std::ostream & dumpOn( std::ostream & str ) const;
170 ///////////////////////////////////////////////////////////////////
172 /** Create \ref ResObject from \ref sat::Solvable.
174 * This function creates the apropriate kind of ResObject
175 * depending on the sat::Solvables kind, and returns a smart
178 * If the sat::Solvables kind is not convertible, a NULL
179 * pointer is returned.
183 * ResObject::Ptr p( makeResObject( s ) );
184 * ResObject::Ptr q( make<ResObject>( s ) );
185 * Package::Ptr pkg( make<Package>( s ) );
188 ResObject::Ptr makeResObject( const sat::Solvable & solvable_r );
190 /** Directly create a certain kind of ResObject from \ref sat::Solvable.
192 * If the sat::Solvables kind is not appropriate, a NULL
193 * pointer is returned.
196 * ResObject::Ptr p( makeResObject( s ) );
197 * ResObject::Ptr q( make<ResObject>( s ) );
198 * Package::Ptr pkg( make<Package>( s ) );
202 inline typename ResTraits<_Res>::PtrType make( const sat::Solvable & solvable_r )
203 { return( isKind<_Res>( solvable_r ) ? new _Res( solvable_r ) : 0 ); }
204 /** \overload Specialisation for ResObject autodetecting the kind of resolvable. */
206 inline ResObject::Ptr make<ResObject>( const sat::Solvable & solvable_r )
207 { return makeResObject( solvable_r ); }
209 /** Convert ResObject::Ptr into Ptr of a certain Kind.
210 * \return \c NULL iff \a p is \c NULL or points to a Resolvable
211 * not of the specified Kind.
214 * asKind<Package>(resPtr);
218 inline typename ResTraits<_Res>::PtrType asKind( const ResObject::Ptr & p )
219 { return dynamic_pointer_cast<_Res>(p); }
222 inline typename ResTraits<_Res>::constPtrType asKind( const ResObject::constPtr & p )
223 { return dynamic_pointer_cast<const _Res>(p); }
225 /////////////////////////////////////////////////////////////////
227 ///////////////////////////////////////////////////////////////////
228 #endif // ZYPP_RESOBJECT_H