libzypp  13.10.6
ResObject.h
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
12 #ifndef ZYPP_RESOBJECT_H
13 #define ZYPP_RESOBJECT_H
14 
15 #include "zypp/APIConfig.h"
16 
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"
25 
26 #include "zypp/sat/LookupAttr.h"
27 #include "zypp/sat/SolvableSet.h"
28 
30 namespace zypp
31 {
32 
34  //
35  // CLASS NAME : ResObject
36  //
44  class ResObject : public Resolvable
45  {
46  public:
47  typedef ResObject Self;
51 
52  public:
53 
66  template<class _Res>
67  inline typename ResTraits<_Res>::constPtrType asKind() const;
68 
69  template<class _Res>
70  inline typename ResTraits<_Res>::PtrType asKind();
71 
72  public:
78  bool supportsLocales() const
79  { return sat::Solvable::supportsLocales(); }
80 
82  bool supportsLocale( const Locale & locale_r ) const
83  { return sat::Solvable::supportsLocale( locale_r ); }
84 
85  bool supportsLocale( const LocaleSet & locales_r ) const
86  { return sat::Solvable::supportsLocale( locales_r ); }
87 
91 
96 
97  public:
102  std::string summary( const Locale & lang_r = Locale() ) const;
103 
107  std::string description( const Locale & lang_r = Locale() ) const;
108 
115  std::string insnotify( const Locale & lang_r = Locale() ) const;
116 
123  std::string delnotify( const Locale & lang_r = Locale() ) const;
124 
131  std::string licenseToConfirm( const Locale & lang_r = Locale() ) const;
132 
139  bool needToAcceptLicense() const;
140 
146  Vendor vendor() const
147  { return Resolvable::vendor().asString(); }
148 
152  std::string distribution() const;
153 
160  std::string cpeId() const;
161 
163  ByteCount installSize() const;
164 
166  ByteCount downloadSize() const;
167 
170  { return sat::Solvable::repository(); }
171 
176  { return repository().info(); }
177 
182  unsigned mediaNr() const;
183 
187  Date buildtime() const;
188 
193  Date installtime() const;
194 
201  const DiskUsage & diskusage() const;
202 
203  protected:
204  friend ResObject::Ptr makeResObject( const sat::Solvable & solvable_r );
206  ResObject( const sat::Solvable & solvable_r );
208  virtual ~ResObject();
210  virtual std::ostream & dumpOn( std::ostream & str ) const;
211  };
213 
230  ResObject::Ptr makeResObject( const sat::Solvable & solvable_r );
231 
245  template<class _Res>
246  inline typename ResTraits<_Res>::PtrType make( const sat::Solvable & solvable_r )
247  { return( isKind<_Res>( solvable_r ) ? new _Res( solvable_r ) : 0 ); }
249  template<>
250  inline ResObject::Ptr make<ResObject>( const sat::Solvable & solvable_r )
251  { return makeResObject( solvable_r ); }
252 
254  template<class _Res>
255  inline typename ResTraits<_Res>::PtrType asKind( const sat::Solvable & solvable_r )
256  { return make<_Res>( solvable_r ); }
257 
266  template<class _Res>
267  inline typename ResTraits<_Res>::PtrType asKind( const ResObject::Ptr & p )
268  { return dynamic_pointer_cast<_Res>(p); }
269 
270  template<class _Res>
272  { return dynamic_pointer_cast<const _Res>(p); }
273 
274  template<class _Res>
276  { return dynamic_cast<const _Res *>( this ); }
277 
278  template<class _Res>
280  { return dynamic_cast<_Res *>( this ); }
281 
283 } // namespace zypp
285 #endif // ZYPP_RESOBJECT_H
Repository repository() const
The Repository this Solvable belongs to.
Definition: Solvable.cc:148
RepoInfo info() const
Return any associated RepoInfo.
Definition: Repository.cc:201
bool needToAcceptLicense() const
Acceptance of Product License needed?
Definition: ResObject.cc:78
std::string distribution() const
The distribution string.
Definition: ResObject.cc:85
A Solvable object within the sat Pool.
Definition: Solvable.h:55
friend ResObject::Ptr makeResObject(const sat::Solvable &solvable_r)
Create ResObject from sat::Solvable.
Definition: ResObject.cc:123
ResTraits< Self > TraitsType
Definition: ResObject.h:48
ResTraits< _Res >::PtrType make(const sat::Solvable &solvable_r)
Directly create a certain kind of ResObject from sat::Solvable.
Definition: ResObject.h:246
Repository repository() const
Definition: ResObject.h:169
bool supportsLocale(const Locale &locale_r) const
Whether this Solvable supports a specific Locale.
Definition: Solvable.cc:615
Store and operate with byte count.
Definition: ByteCount.h:30
LocaleSet getSupportedLocales() const
Definition: ResObject.h:93
TraitsType::PtrType Ptr
Definition: ResObject.h:49
bool supportsLocales() const
Whether this Solvable claims to support locales.
Definition: Solvable.cc:609
bool supportsLocale(const Locale &locale_r) const
Definition: ResObject.h:82
std::string Vendor
Definition: Vendor.h:22
What is known about a repository.
Definition: RepoInfo.h:66
std::string cpeId() const
The Common Platform Enumeration name for this product.
Definition: ResObject.cc:88
Interface base for resolvable objects (identification and dependencies).
Definition: Resolvable.h:39
ResTraits< _Res >::PtrType asKind(const sat::Solvable &solvable_r)
Directly create a certain kind of ResObject from sat::Solvable.
Definition: ResObject.h:255
std::string licenseToConfirm(const Locale &lang_r=Locale()) const
License or agreement to accept.
Definition: ResObject.cc:70
ResTraits.
Definition: ResTraits.h:77
TraitsType::constPtrType constPtr
Definition: ResObject.h:50
ResObject Self
Definition: ResObject.h:47
virtual std::ostream & dumpOn(std::ostream &str) const
Helper for stream output.
Definition: ResObject.cc:51
std::string asString() const
Conversion to std::string
Definition: IdString.h:83
ByteCount installSize() const
Installed size.
Definition: ResObject.cc:91
std::string description(const Locale &lang_r=Locale()) const
Long text describing the resolvable.
Definition: ResObject.cc:61
Store and operate on date (time_t).
Definition: Date.h:31
ResTraits< _Res >::constPtrType asKind() const
Convert this into a Ptr of a certain Kind.
Definition: ResObject.h:275
bool supportsLocale(const LocaleSet &locales_r) const
Definition: ResObject.h:85
bool supportsRequestedLocales() const
Whether this Solvable supports at least one requested locale.
Definition: Solvable.cc:629
Provides API related macros.
std::string summary(const Locale &lang_r=Locale()) const
Short text describing the resolvable.
Definition: ResObject.cc:58
RepoInfo repoInfo() const
RepoInfo associated with the repository providing this resolvable.
Definition: ResObject.h:175
ByteCount downloadSize() const
Size of the rpm package.
Definition: ResObject.cc:94
LocaleSet getSupportedLocales() const
Definition: Solvable.h:249
Interface base for resolvable objects (common data).
Definition: ResObject.h:44
std::tr1::unordered_set< Locale > LocaleSet
Definition: Locale.h:28
bool supportsLocales() const
Definition: ResObject.h:78
std::string insnotify(const Locale &lang_r=Locale()) const
Installation Notification.
Definition: ResObject.cc:64
Date buildtime() const
build time of the resolvable
Definition: ResObject.cc:100
virtual ~ResObject()
Dtor.
Definition: ResObject.cc:43
IdString vendor() const
Definition: Solvable.cc:397
const DiskUsage & diskusage() const
Disk usage per directory A common attribute, although mostly packages require noticeable disk space...
Definition: ResObject.cc:107
unsigned mediaNr() const
Media number where the resolvable is located 0 if no media access is required.
Definition: ResObject.cc:97
std::string delnotify(const Locale &lang_r=Locale()) const
De-Installation Notification.
Definition: ResObject.cc:67
ResObject::Ptr makeResObject(const sat::Solvable &solvable_r)
Create ResObject from sat::Solvable.
Definition: ResObject.cc:123
intrusive_ptr< _Res > PtrType
Definition: ResTraits.h:80
Date installtime() const
Installation time 0 if the resolvable is not installed.
Definition: ResObject.cc:103
bool supportsRequestedLocales() const
Definition: ResObject.h:89
ResObject(const sat::Solvable &solvable_r)
Ctor.
Definition: ResObject.cc:34
ResObject::Ptr make< ResObject >(const sat::Solvable &solvable_r)
Definition: ResObject.h:250
Vendor vendor() const
Vendor.
Definition: ResObject.h:146
ResTraits< _Res >::PtrType asKind(const ResObject::Ptr &p)
Convert ResObject::Ptr into Ptr of a certain Kind.
Definition: ResObject.h:267
intrusive_ptr< const _Res > constPtrType
Definition: ResTraits.h:81