1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/ResObject.cc
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"
23 ///////////////////////////////////////////////////////////////////
25 { /////////////////////////////////////////////////////////////////
27 IMPL_PTR_TYPE(ResObject);
29 ///////////////////////////////////////////////////////////////////
31 // METHOD NAME : ResObject::ResObject
34 ResObject::ResObject( const sat::Solvable & solvable_r )
35 : Resolvable( solvable_r )
38 ///////////////////////////////////////////////////////////////////
40 // METHOD NAME : ResObject::~ResObject
43 ResObject::~ResObject()
46 ///////////////////////////////////////////////////////////////////
48 // METHOD NAME : ResObject::dumpOn
49 // METHOD TYPE : std::ostream &
51 std::ostream & ResObject::dumpOn( std::ostream & str ) const
53 return Resolvable::dumpOn( str );
56 ///////////////////////////////////////////////////////////////////
58 std::string ResObject::summary( const Locale & lang_r ) const
59 { return lookupStrAttribute( sat::SolvAttr::summary, lang_r ); }
61 std::string ResObject::description( const Locale & lang_r ) const
62 { return lookupStrAttribute( sat::SolvAttr::description, lang_r ); }
64 std::string ResObject::insnotify( const Locale & lang_r ) const
65 { return lookupStrAttribute( sat::SolvAttr::insnotify, lang_r ); }
67 std::string ResObject::delnotify( const Locale & lang_r ) const
68 { return lookupStrAttribute( sat::SolvAttr::delnotify, lang_r ); }
70 std::string ResObject::licenseToConfirm( const Locale & lang_r ) const
72 std::string ret = lookupStrAttribute( sat::SolvAttr::eula, lang_r );
73 if ( ret.empty() && isKind<Product>() )
74 return repoInfo().getLicense( lang_r );
78 bool ResObject::needToAcceptLicense() const
80 if ( isKind<Product>() )
81 return repoInfo().needToAcceptLicense( );
85 std::string ResObject::distribution() const
86 { return lookupStrAttribute( sat::SolvAttr::distribution ); }
88 std::string ResObject::cpeId() const
89 { return lookupStrAttribute( sat::SolvAttr::cpeid ); }
91 ByteCount ResObject::installSize() const
92 { return ByteCount( lookupNumAttribute( sat::SolvAttr::installsize ) ); }
94 ByteCount ResObject::downloadSize() const
95 { return ByteCount( lookupNumAttribute( sat::SolvAttr::downloadsize ) ); }
97 unsigned ResObject::mediaNr() const
98 { return lookupNumAttribute( sat::SolvAttr::medianr ); }
100 Date ResObject::buildtime() const
101 { return Date( lookupNumAttribute( sat::SolvAttr::buildtime ) ); }
103 Date ResObject::installtime() const
104 { return Date( lookupNumAttribute( sat::SolvAttr::installtime ) ); }
106 /////////////////////////////////////////////////////////////////
108 ///////////////////////////////////////////////////////////////////
110 #include "zypp/ResObjects.h"
112 ///////////////////////////////////////////////////////////////////
114 { /////////////////////////////////////////////////////////////////
116 ResObject::Ptr makeResObject( const sat::Solvable & solvable_r )
121 ResKind kind( solvable_r.kind() );
122 #define OUTS(X) if ( kind == ResTraits<X>::kind ) return make<X>( solvable_r );
130 // unknow => return a plain ResObject
131 return new ResObject( solvable_r );
134 /////////////////////////////////////////////////////////////////
136 ///////////////////////////////////////////////////////////////////