libzypp  14.48.5
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/OnMediaLocation.h"
23 #include "zypp/Repository.h"
24 #include "zypp/CpeId.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 
155  CpeId cpeId() const;
156 
178  ByteCount installSize() const;
179 
181  ByteCount downloadSize() const;
182 
185  { return sat::Solvable::repository(); }
186 
191  { return repository().info(); }
192 
197  unsigned mediaNr() const;
198 
202  Date buildtime() const;
203 
208  Date installtime() const;
209 
210  protected:
211  friend ResObject::Ptr makeResObject( const sat::Solvable & solvable_r );
213  ResObject( const sat::Solvable & solvable_r );
215  virtual ~ResObject();
217  virtual std::ostream & dumpOn( std::ostream & str ) const;
218  };
220 
237  ResObject::Ptr makeResObject( const sat::Solvable & solvable_r );
238 
252  template<class _Res>
253  inline typename ResTraits<_Res>::PtrType make( const sat::Solvable & solvable_r )
254  { return( isKind<_Res>( solvable_r ) ? new _Res( solvable_r ) : 0 ); }
256  template<>
257  inline ResObject::Ptr make<ResObject>( const sat::Solvable & solvable_r )
258  { return makeResObject( solvable_r ); }
259 
261  template<class _Res>
262  inline typename ResTraits<_Res>::PtrType asKind( const sat::Solvable & solvable_r )
263  { return make<_Res>( solvable_r ); }
264 
273  template<class _Res>
274  inline typename ResTraits<_Res>::PtrType asKind( const ResObject::Ptr & p )
275  { return dynamic_pointer_cast<_Res>(p); }
276 
277  template<class _Res>
279  { return dynamic_pointer_cast<const _Res>(p); }
280 
281  template<class _Res>
283  { return dynamic_cast<const _Res *>( this ); }
284 
285  template<class _Res>
287  { return dynamic_cast<_Res *>( this ); }
288 
290 } // namespace zypp
292 #endif // ZYPP_RESOBJECT_H
Repository repository() const
The Repository this Solvable belongs to.
Definition: Solvable.cc:121
RepoInfo info() const
Return any associated RepoInfo.
Definition: Repository.cc:273
bool needToAcceptLicense() const
Acceptance of Product License needed?
Definition: ResObject.cc:84
std::string distribution() const
The distribution string.
Definition: ResObject.cc:91
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:122
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:253
Repository repository() const
Definition: ResObject.h:184
bool supportsLocale(const Locale &locale_r) const
Whether this Solvable supports a specific Locale.
Definition: Solvable.cc:579
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:573
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:72
Common Platform Enumearation (2.3) See http://cpe.mitre.org/ for more information on the Common Platf...
Definition: CpeId.h:31
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:262
std::string licenseToConfirm(const Locale &lang_r=Locale()) const
License or agreement to accept.
Definition: ResObject.cc:72
ResTraits.
Definition: ResTraits.h:79
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:53
std::string asString() const
Conversion to std::string
Definition: IdString.h:83
ByteCount installSize() const
Installed (unpacked) size.
Definition: ResObject.cc:97
std::string description(const Locale &lang_r=Locale()) const
Long text describing the resolvable.
Definition: ResObject.cc:63
Store and operate on date (time_t).
Definition: Date.h:32
ResTraits< _Res >::constPtrType asKind() const
Convert this into a Ptr of a certain Kind.
Definition: ResObject.h:282
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:593
Provides API related macros.
std::string summary(const Locale &lang_r=Locale()) const
Short text describing the resolvable.
Definition: ResObject.cc:60
RepoInfo repoInfo() const
RepoInfo associated with the repository providing this resolvable.
Definition: ResObject.h:190
ByteCount downloadSize() const
Download size.
Definition: ResObject.cc:100
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:66
Date buildtime() const
build time of the resolvable
Definition: ResObject.cc:106
virtual ~ResObject()
Dtor.
Definition: ResObject.cc:45
IdString vendor() const
Definition: Solvable.cc:361
CpeId cpeId() const
The Common Platform Enumeration name for this product.
Definition: ResObject.cc:94
unsigned mediaNr() const
Media number where the resolvable is located 0 if no media access is required.
Definition: ResObject.cc:103
std::string delnotify(const Locale &lang_r=Locale()) const
De-Installation Notification.
Definition: ResObject.cc:69
ResObject::Ptr makeResObject(const sat::Solvable &solvable_r)
Create ResObject from sat::Solvable.
Definition: ResObject.cc:122
intrusive_ptr< _Res > PtrType
Definition: ResTraits.h:82
Date installtime() const
Installation time 0 if the resolvable is not installed.
Definition: ResObject.cc:109
bool supportsRequestedLocales() const
Definition: ResObject.h:89
ResObject(const sat::Solvable &solvable_r)
Ctor.
Definition: ResObject.cc:36
ResObject::Ptr make< ResObject >(const sat::Solvable &solvable_r)
Definition: ResObject.h:257
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:274
intrusive_ptr< const _Res > constPtrType
Definition: ResTraits.h:83