libzypp  13.10.6
ResObject.cc
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
13 #include "zypp/ResObject.h"
14 #include "zypp/sat/SolvAttr.h"
15 #include "zypp/sat/Solvable.h"
16 #include "zypp/Repository.h"
17 #include "zypp/RepoInfo.h"
18 #include "zypp/IdString.h"
19 
20 using namespace zypp;
21 using namespace std;
22 
24 namespace zypp
25 {
26 
28 
30  //
31  // METHOD NAME : ResObject::ResObject
32  // METHOD TYPE : Ctor
33  //
34  ResObject::ResObject( const sat::Solvable & solvable_r )
35  : Resolvable( solvable_r )
36  {}
37 
39  //
40  // METHOD NAME : ResObject::~ResObject
41  // METHOD TYPE : Dtor
42  //
44  {}
45 
47  //
48  // METHOD NAME : ResObject::dumpOn
49  // METHOD TYPE : std::ostream &
50  //
51  std::ostream & ResObject::dumpOn( std::ostream & str ) const
52  {
53  return Resolvable::dumpOn( str );
54  }
55 
57 
58  std::string ResObject::summary( const Locale & lang_r ) const
59  { return lookupStrAttribute( sat::SolvAttr::summary, lang_r ); }
60 
61  std::string ResObject::description( const Locale & lang_r ) const
62  { return lookupStrAttribute( sat::SolvAttr::description, lang_r ); }
63 
64  std::string ResObject::insnotify( const Locale & lang_r ) const
65  { return lookupStrAttribute( sat::SolvAttr::insnotify, lang_r ); }
66 
67  std::string ResObject::delnotify( const Locale & lang_r ) const
68  { return lookupStrAttribute( sat::SolvAttr::delnotify, lang_r ); }
69 
70  std::string ResObject::licenseToConfirm( const Locale & lang_r ) const
71  {
72  std::string ret = lookupStrAttribute( sat::SolvAttr::eula, lang_r );
73  if ( ret.empty() && isKind<Product>() )
74  return repoInfo().getLicense( lang_r );
75  return ret;
76  }
77 
79  {
80  if ( isKind<Product>() )
81  return repoInfo().needToAcceptLicense( );
82  return true;
83  }
84 
85  std::string ResObject::distribution() const
87 
88  std::string ResObject::cpeId() const
90 
93 
96 
97  unsigned ResObject::mediaNr() const
99 
102 
105 
106 #warning DUMMY diskusage
108  {
109  static DiskUsage _du;
110  return _du;
111  }
112 
114 } // namespace zypp
116 
117 #include "zypp/ResObjects.h"
118 
120 namespace zypp
121 {
122 
124  {
125  if ( ! solvable_r )
126  return 0;
127 
128  ResKind kind( solvable_r.kind() );
129 #define OUTS(X) if ( kind == ResTraits<X>::kind ) return make<X>( solvable_r );
130  OUTS( Package );
131  OUTS( Patch );
132  OUTS( Pattern );
133  OUTS( Product );
134  OUTS( SrcPackage );
135 #undef OUTS
136  // unknow => return a plain ResObject
137  return new ResObject( solvable_r );
138  }
139 
141 } // namespace zypp
Product interface.
Definition: Product.h:32
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
Store and operate with byte count.
Definition: ByteCount.h:30
static const SolvAttr installtime
Definition: SolvAttr.h:76
std::string getLicense(const Locale &lang_r=Locale())
Return the best license for the current (or a specified) locale.
Definition: RepoInfo.cc:314
TraitsType::PtrType Ptr
Definition: ResObject.h:49
std::string lookupStrAttribute(const SolvAttr &attr) const
returns the string attribute value for attr or an empty string if it does not exists.
Definition: Solvable.cc:171
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
std::string licenseToConfirm(const Locale &lang_r=Locale()) const
License or agreement to accept.
Definition: ResObject.cc:70
Class representing a patch.
Definition: Patch.h:36
static const SolvAttr insnotify
Definition: SolvAttr.h:73
virtual std::ostream & dumpOn(std::ostream &str) const
Helper for stream output.
Definition: ResObject.cc:51
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
bool needToAcceptLicense() const
Whether the repo license has to be accepted, e.g.
Definition: RepoInfo.cc:286
Pattern interface.
Definition: Pattern.h:30
Package interface.
Definition: Package.h:32
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
unsigned long long lookupNumAttribute(const SolvAttr &attr) const
returns the numeric attribute value for attr or 0 if it does not exists.
Definition: Solvable.cc:197
virtual std::ostream & dumpOn(std::ostream &str) const
Helper for stream output.
Definition: Resolvable.cc:52
Interface base for resolvable objects (common data).
Definition: ResObject.h:44
#define OUTS(X)
static const SolvAttr downloadsize
Definition: SolvAttr.h:79
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
static const SolvAttr delnotify
Definition: SolvAttr.h:74
virtual ~ResObject()
Dtor.
Definition: ResObject.cc:43
static const SolvAttr installsize
Definition: SolvAttr.h:78
ResKind kind() const
Definition: Solvable.cc:298
SrcPackage interface.
Definition: SrcPackage.h:29
static const SolvAttr buildtime
Definition: SolvAttr.h:77
const DiskUsage & diskusage() const
Disk usage per directory A common attribute, although mostly packages require noticeable disk space...
Definition: ResObject.cc:107
static const SolvAttr cpeid
Definition: SolvAttr.h:81
unsigned mediaNr() const
Media number where the resolvable is located 0 if no media access is required.
Definition: ResObject.cc:97
static const SolvAttr description
Definition: SolvAttr.h:72
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
Date installtime() const
Installation time 0 if the resolvable is not installed.
Definition: ResObject.cc:103
static const SolvAttr eula
Definition: SolvAttr.h:75
static const SolvAttr summary
Definition: SolvAttr.h:71
IMPL_PTR_TYPE(KeyRing)
static const SolvAttr distribution
Definition: SolvAttr.h:92
ResObject(const sat::Solvable &solvable_r)
Ctor.
Definition: ResObject.cc:34
Resolvable kinds.
Definition: ResKind.h:35
static const SolvAttr medianr
Definition: SolvAttr.h:88