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/TranslatedText.h"
28 ///////////////////////////////////////////////////////////////////
30 { /////////////////////////////////////////////////////////////////
32 ///////////////////////////////////////////////////////////////////
34 // CLASS NAME : ResObject
37 * Interface base for resolvable objects (common data).
38 * That is, all data not needed for solving, but common
39 * across all Resolvable kinds.
41 * \see \ref makeResObject for how to construct ResObjects.
43 class ResObject : public Resolvable
46 typedef ResObject Self;
47 typedef ResTraits<Self> TraitsType;
48 typedef TraitsType::PtrType Ptr;
49 typedef TraitsType::constPtrType constPtr;
52 /** \name Locale support.
53 * \see \ref sat::Solvable
56 /** \see \ref sat::Solvable::supportsLocales */
57 using sat::Solvable::supportsLocales;
58 /** \see \ref sat::Solvable::supportsLocale */
59 using sat::Solvable::supportsLocale;
60 /** \see \ref sat::Solvable::supportsRequestedLocales */
61 using sat::Solvable::supportsRequestedLocales;
62 /** \see \ref sat::Solvable::getSupportedLocales */
63 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 /** Installed size. */
112 ByteCount installsize() const;
113 /** \deprecated Use installsize which is more precise. */
114 ZYPP_DEPRECATED ByteCount size() const
115 { return installsize(); }
117 /** Size of the rpm package. */
118 ByteCount downloadSize() const;
120 /** \see \ref sat::Solvable::repository */
121 using sat::Solvable::repository;
123 /** \ref RepoInfo associated with the repository
124 * providing this resolvable.
126 RepoInfo repoInfo() const
127 { return repository().info(); }
130 * Media number where the resolvable is located
131 * 0 if no media access is required.
133 unsigned mediaNr() const;
136 * \TODO FIXME what is this?
137 * Flag in the metadata indicating this should be
138 * installed unsing '-i' (not -U).
140 bool installOnly() const;
143 * \short build time of the resolvable
145 Date buildtime() const;
148 * \short Installation time
149 * 0 if the resolvable is not installed.
151 Date installtime() const;
154 * \short Disk usage per directory
155 * A common attribute, although mostly packages require
156 * noticeable disk space. An e.g product could try to reserve
157 * a certain ammount of diskspace by providing DiskUsage data.
159 const DiskUsage & diskusage() const;
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