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/NeedAType.h"
19 #include "zypp/Date.h"
20 #include "zypp/ByteCount.h"
21 #include "zypp/DiskUsage.h"
22 #include "zypp/TranslatedText.h"
23 #include "zypp/OnMediaLocation.h"
24 #include "zypp/Repository.h"
26 ///////////////////////////////////////////////////////////////////
28 { /////////////////////////////////////////////////////////////////
30 ///////////////////////////////////////////////////////////////////
32 // CLASS NAME : ResObject
35 * Interface base for resolvable objects (common data).
36 * That is, all data not needed for solving, but common
37 * across all Resolvable kinds.
39 * \see \ref makeResObject for how to construct ResObjects.
41 class ResObject : public Resolvable
44 typedef ResObject Self;
45 typedef ResTraits<Self> TraitsType;
46 typedef TraitsType::PtrType Ptr;
47 typedef TraitsType::constPtrType constPtr;
50 /** \name Locale support.
51 * \see \ref sat::Solvable
54 /** \see \ref sat::Solvable::supportsLocales */
55 using sat::Solvable::supportsLocales;
56 /** \see \ref sat::Solvable::supportsLocale */
57 using sat::Solvable::supportsLocale;
58 /** \see \ref sat::Solvable::supportsRequestedLocales */
59 using sat::Solvable::supportsRequestedLocales;
60 /** \see \ref sat::Solvable::getSupportedLocales */
61 using sat::Solvable::getSupportedLocales;
67 * \short Short text describing the resolvable.
68 * This attribute is usually displayed in columns.
73 * \short Long text describing the resolvable.
75 Text description() const;
78 * \short Installation Notification
80 * This text can be used to tell the user some notes
81 * When he selects the resovable for installation.
83 Text insnotify() const;
86 * \short De-Installation Notification
88 * This text can be used to tell the user some notes
89 * When he selects the resovable for deinstall.
91 Text delnotify() const;
94 * \short License or agreement to accept
96 * Agreement, warning or license the user should
97 * accept before installing the resolvable.
99 Text licenseToConfirm() const;
104 * For Example "Novell Inc."
106 Vendor vendor() const
107 { return Resolvable::vendor().asString(); }
109 /** Installed size. */
110 ByteCount size() const;
112 /** Size of the rpm package. */
113 ByteCount downloadSize() const;
115 /** \see \ref sat::Solvable::repository */
116 using sat::Solvable::repository;
118 /** \ref RepoInfo associated with the repository
119 * providing this resolvable.
121 RepoInfo repoInfo() const
122 { return repository().info(); }
125 * Media number where the resolvable is located
126 * 0 if no media access is required.
128 unsigned mediaNr() const;
131 * \TODO FIXME what is this?
132 * Flag in the metadata indicating this should be
133 * installed unsing '-i' (not -U).
135 bool installOnly() const;
138 * \short build time of the resolvable
140 Date buildtime() const;
143 * \short Installation time
144 * 0 if the resolvable is not installed.
146 Date installtime() const;
149 * \short Disk usage per directory
150 * A common attribute, although mostly packages require
151 * noticeable disk space. An e.g product could try to reserve
152 * a certain ammount of diskspace by providing DiskUsage data.
154 const DiskUsage & diskusage() const;
158 ResObject( const sat::Solvable & solvable_r );
160 virtual ~ResObject();
161 /** Helper for stream output */
162 virtual std::ostream & dumpOn( std::ostream & str ) const;
164 ///////////////////////////////////////////////////////////////////
166 /** Create \ref ResObject from \ref sat::Solvable.
168 * This function creates the apropriate kind of ResObject
169 * depending on the sat::Solvables kind, and returns a smart
172 * If the sat::Solvables kind is not convertible, a NULL
173 * pointer is returned.
177 * ResObject::Ptr p( makeResObject( s ) );
178 * ResObject::Ptr q( make<ResObject>( s ) );
179 * Package::Ptr pkg( make<Package>( s ) );
182 ResObject::Ptr makeResObject( const sat::Solvable & solvable_r );
184 /** Directly create a certain kind of ResObject from \ref sat::Solvable.
186 * If the sat::Solvables kind is not appropriate, a NULL
187 * pointer is returned.
190 * ResObject::Ptr p( makeResObject( s ) );
191 * ResObject::Ptr q( make<ResObject>( s ) );
192 * Package::Ptr pkg( make<Package>( s ) );
196 inline typename ResTraits<_Res>::PtrType make( const sat::Solvable & solvable_r )
197 { return( isKind<_Res>( solvable_r ) ? new _Res( solvable_r ) : 0 ); }
198 /** \overload Specialisation for ResObject autodetecting the kind of resolvable. */
200 inline ResObject::Ptr make<ResObject>( const sat::Solvable & solvable_r )
201 { return makeResObject( solvable_r ); }
203 /** Convert ResObject::Ptr into Ptr of a certain Kind.
204 * \return \c NULL iff \a p is \c NULL or points to a Resolvable
205 * not of the specified Kind.
208 * asKind<Package>(resPtr);
212 inline typename ResTraits<_Res>::PtrType asKind( const ResObject::Ptr & p )
213 { return dynamic_pointer_cast<_Res>(p); }
216 inline typename ResTraits<_Res>::constPtrType asKind( const ResObject::constPtr & p )
217 { return dynamic_pointer_cast<const _Res>(p); }
219 /////////////////////////////////////////////////////////////////
221 ///////////////////////////////////////////////////////////////////
222 #endif // ZYPP_RESOBJECT_H