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"
28 #include "zypp/TranslatedText.h"
30 ///////////////////////////////////////////////////////////////////
32 { /////////////////////////////////////////////////////////////////
34 ///////////////////////////////////////////////////////////////////
36 // CLASS NAME : ResObject
39 * Interface base for resolvable objects (common data).
40 * That is, all data not needed for solving, but common
41 * across all Resolvable kinds.
43 * \see \ref makeResObject for how to construct ResObjects.
45 class ResObject : public Resolvable
48 typedef ResObject Self;
49 typedef ResTraits<Self> TraitsType;
50 typedef TraitsType::PtrType Ptr;
51 typedef TraitsType::constPtrType constPtr;
54 /** \name Locale support.
55 * \see \ref sat::Solvable
58 /** \see \ref sat::Solvable::supportsLocales */
59 using sat::Solvable::supportsLocales;
60 /** \see \ref sat::Solvable::supportsLocale */
61 using sat::Solvable::supportsLocale;
62 /** \see \ref sat::Solvable::supportsRequestedLocales */
63 using sat::Solvable::supportsRequestedLocales;
64 /** \see \ref sat::Solvable::getSupportedLocales */
65 using sat::Solvable::getSupportedLocales;
71 * \short Short text describing the resolvable.
72 * This attribute is usually displayed in columns.
74 std::string summary( const Locale & lang_r = Locale() ) const;
77 * \short Long text describing the resolvable.
79 std::string description( const Locale & lang_r = Locale() ) const;
82 * \short Installation Notification
84 * This text can be used to tell the user some notes
85 * When he selects the resovable for installation.
87 std::string insnotify( const Locale & lang_r = Locale() ) const;
90 * \short De-Installation Notification
92 * This text can be used to tell the user some notes
93 * When he selects the resovable for deinstall.
95 std::string delnotify( const Locale & lang_r = Locale() ) const;
98 * \short License or agreement to accept
100 * Agreement, warning or license the user should
101 * accept before installing the resolvable.
103 std::string licenseToConfirm( const Locale & lang_r = Locale() ) const;
108 * For Example "Novell Inc."
110 Vendor vendor() const
111 { return Resolvable::vendor().asString(); }
113 /** Installed size. */
114 ByteCount installsize() const;
115 /** \deprecated Use installsize which is more precise. */
116 ZYPP_DEPRECATED ByteCount size() const
117 { return installsize(); }
119 /** Size of the rpm package. */
120 ByteCount downloadSize() const;
122 /** \see \ref sat::Solvable::repository */
123 using sat::Solvable::repository;
125 /** \ref RepoInfo associated with the repository
126 * providing this resolvable.
128 RepoInfo repoInfo() const
129 { return repository().info(); }
132 * Media number where the resolvable is located
133 * 0 if no media access is required.
135 unsigned mediaNr() const;
138 * \TODO FIXME what is this?
139 * Flag in the metadata indicating this should be
140 * installed unsing '-i' (not -U).
142 bool installOnly() const;
145 * \short build time of the resolvable
147 Date buildtime() const;
150 * \short Installation time
151 * 0 if the resolvable is not installed.
153 Date installtime() const;
156 * \short Disk usage per directory
157 * A common attribute, although mostly packages require
158 * noticeable disk space. An e.g product could try to reserve
159 * a certain ammount of diskspace by providing DiskUsage data.
161 const DiskUsage & diskusage() const;
165 ResObject( const sat::Solvable & solvable_r );
167 virtual ~ResObject();
168 /** Helper for stream output */
169 virtual std::ostream & dumpOn( std::ostream & str ) const;
171 ///////////////////////////////////////////////////////////////////
173 /** Create \ref ResObject from \ref sat::Solvable.
175 * This function creates the apropriate kind of ResObject
176 * depending on the sat::Solvables kind, and returns a smart
179 * If the sat::Solvables kind is not convertible, a NULL
180 * pointer is returned.
184 * ResObject::Ptr p( makeResObject( s ) );
185 * ResObject::Ptr q( make<ResObject>( s ) );
186 * Package::Ptr pkg( make<Package>( s ) );
189 ResObject::Ptr makeResObject( const sat::Solvable & solvable_r );
191 /** Directly create a certain kind of ResObject from \ref sat::Solvable.
193 * If the sat::Solvables kind is not appropriate, a NULL
194 * pointer is returned.
197 * ResObject::Ptr p( makeResObject( s ) );
198 * ResObject::Ptr q( make<ResObject>( s ) );
199 * Package::Ptr pkg( make<Package>( s ) );
203 inline typename ResTraits<_Res>::PtrType make( const sat::Solvable & solvable_r )
204 { return( isKind<_Res>( solvable_r ) ? new _Res( solvable_r ) : 0 ); }
205 /** \overload Specialisation for ResObject autodetecting the kind of resolvable. */
207 inline ResObject::Ptr make<ResObject>( const sat::Solvable & solvable_r )
208 { return makeResObject( solvable_r ); }
210 /** Convert ResObject::Ptr into Ptr of a certain Kind.
211 * \return \c NULL iff \a p is \c NULL or points to a Resolvable
212 * not of the specified Kind.
215 * asKind<Package>(resPtr);
219 inline typename ResTraits<_Res>::PtrType asKind( const ResObject::Ptr & p )
220 { return dynamic_pointer_cast<_Res>(p); }
223 inline typename ResTraits<_Res>::constPtrType asKind( const ResObject::constPtr & p )
224 { return dynamic_pointer_cast<const _Res>(p); }
226 /////////////////////////////////////////////////////////////////
228 ///////////////////////////////////////////////////////////////////
229 #endif // ZYPP_RESOBJECT_H