libzypp  10.5.0
ResObject.cc
Go to the documentation of this file.
00001 /*---------------------------------------------------------------------\
00002 |                          ____ _   __ __ ___                          |
00003 |                         |__  / \ / / . \ . \                         |
00004 |                           / / \ V /|  _/  _/                         |
00005 |                          / /__ | | | | | |                           |
00006 |                         /_____||_| |_| |_|                           |
00007 |                                                                      |
00008 \---------------------------------------------------------------------*/
00013 #include "zypp/ResObject.h"
00014 #include "zypp/sat/SolvAttr.h"
00015 #include "zypp/sat/Solvable.h"
00016 #include "zypp/Repository.h"
00017 #include "zypp/RepoInfo.h"
00018 #include "zypp/IdString.h"
00019 
00020 using namespace zypp;
00021 using namespace std;
00022 
00024 namespace zypp
00025 { 
00026 
00027   IMPL_PTR_TYPE(ResObject);
00028 
00030   //
00031   //    METHOD NAME : ResObject::ResObject
00032   //    METHOD TYPE : Ctor
00033   //
00034   ResObject::ResObject( const sat::Solvable & solvable_r )
00035   : Resolvable( solvable_r )
00036   {}
00037 
00039   //
00040   //    METHOD NAME : ResObject::~ResObject
00041   //    METHOD TYPE : Dtor
00042   //
00043   ResObject::~ResObject()
00044   {}
00045 
00047   //
00048   //    METHOD NAME : ResObject::dumpOn
00049   //    METHOD TYPE : std::ostream &
00050   //
00051   std::ostream & ResObject::dumpOn( std::ostream & str ) const
00052   {
00053     return Resolvable::dumpOn( str );
00054   }
00055 
00057 
00058   std::string ResObject::summary( const Locale & lang_r ) const
00059   { return lookupStrAttribute( sat::SolvAttr::summary, lang_r ); }
00060 
00061   std::string ResObject::description( const Locale & lang_r ) const
00062   { return lookupStrAttribute( sat::SolvAttr::description, lang_r ); }
00063 
00064   std::string ResObject::insnotify( const Locale & lang_r ) const
00065   { return lookupStrAttribute( sat::SolvAttr::insnotify, lang_r ); }
00066 
00067   std::string ResObject::delnotify( const Locale & lang_r ) const
00068   { return lookupStrAttribute( sat::SolvAttr::delnotify, lang_r ); }
00069 
00070   std::string ResObject::licenseToConfirm( const Locale & lang_r ) const
00071   {
00072     std::string ret = lookupStrAttribute( sat::SolvAttr::eula, lang_r );
00073     if ( ret.empty() && isKind<Product>() )
00074       return repoInfo().getLicense( lang_r );
00075     return ret;
00076   }
00077 
00078   std::string ResObject::distribution() const
00079   { return lookupStrAttribute( sat::SolvAttr::distribution ); }
00080 
00081   std::string ResObject::cpeId() const
00082   { return lookupStrAttribute( sat::SolvAttr::cpeid ); }
00083 
00084   ByteCount ResObject::installSize() const
00085   { return ByteCount( lookupNumAttribute( sat::SolvAttr::installsize ), ByteCount::K ); }
00086 
00087   ByteCount ResObject::downloadSize() const
00088   { return ByteCount( lookupNumAttribute( sat::SolvAttr::downloadsize ), ByteCount::K ); }
00089 
00090   unsigned ResObject::mediaNr() const
00091   { return lookupNumAttribute( sat::SolvAttr::medianr ); }
00092 
00093   Date ResObject::buildtime() const
00094   { return Date( lookupNumAttribute( sat::SolvAttr::buildtime ) ); }
00095 
00096   Date ResObject::installtime() const
00097   { return Date( lookupNumAttribute( sat::SolvAttr::installtime ) ); }
00098 
00099 #warning DUMMY diskusage
00100   const DiskUsage & ResObject::diskusage() const
00101   {
00102     static DiskUsage _du;
00103     return _du;
00104   }
00105 
00107 } // namespace zypp
00109 
00110 #include "zypp/ResObjects.h"
00111 
00113 namespace zypp
00114 { 
00115 
00116   ResObject::Ptr makeResObject( const sat::Solvable & solvable_r )
00117   {
00118     if ( ! solvable_r )
00119       return 0;
00120 
00121     ResKind kind( solvable_r.kind() );
00122 #define OUTS(X)  if ( kind == ResTraits<X>::kind ) return make<X>( solvable_r );
00123     OUTS( Package );
00124     OUTS( Patch );
00125     OUTS( Pattern );
00126     OUTS( Product );
00127     OUTS( SrcPackage );
00128 #undef OUTS
00129     // unknow => return a plain ResObject
00130     return new ResObject( solvable_r );
00131   }
00132 
00134 } // namespace zypp