- Adapt to new product handling. Products are no longer pseudo
[platform/upstream/libzypp.git] / zypp / ResObject.cc
1 /*---------------------------------------------------------------------\
2 |                          ____ _   __ __ ___                          |
3 |                         |__  / \ / / . \ . \                         |
4 |                           / / \ V /|  _/  _/                         |
5 |                          / /__ | | | | | |                           |
6 |                         /_____||_| |_| |_|                           |
7 |                                                                      |
8 \---------------------------------------------------------------------*/
9 /** \file       zypp/ResObject.cc
10  *
11 */
12
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
23 ///////////////////////////////////////////////////////////////////
24 namespace zypp
25 { /////////////////////////////////////////////////////////////////
26
27   IMPL_PTR_TYPE(ResObject);
28
29   ///////////////////////////////////////////////////////////////////
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
38   ///////////////////////////////////////////////////////////////////
39   //
40   //    METHOD NAME : ResObject::~ResObject
41   //    METHOD TYPE : Dtor
42   //
43   ResObject::~ResObject()
44   {}
45
46   ///////////////////////////////////////////////////////////////////
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
56   ///////////////////////////////////////////////////////////////////
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   { return lookupStrAttribute( sat::SolvAttr::eula, lang_r ); }
72
73   ByteCount ResObject::installSize() const
74   { return ByteCount( lookupNumAttribute( sat::SolvAttr::installsize ), ByteCount::K ); }
75
76   ByteCount ResObject::downloadSize() const
77   { return ByteCount( lookupNumAttribute( sat::SolvAttr::downloadsize ), ByteCount::K ); }
78
79   unsigned ResObject::mediaNr() const
80   { return lookupNumAttribute( sat::SolvAttr::medianr ); }
81
82   Date ResObject::buildtime() const
83   { return Date( lookupNumAttribute( sat::SolvAttr::buildtime ) ); }
84
85   Date ResObject::installtime() const
86   { return Date( lookupNumAttribute( sat::SolvAttr::installtime ) ); }
87
88 #warning DUMMY diskusage
89   const DiskUsage & ResObject::diskusage() const
90   {
91     static DiskUsage _du;
92     return _du;
93   }
94
95    /////////////////////////////////////////////////////////////////
96 } // namespace zypp
97 ///////////////////////////////////////////////////////////////////
98
99 #include "zypp/ResObjects.h"
100
101 ///////////////////////////////////////////////////////////////////
102 namespace zypp
103 { /////////////////////////////////////////////////////////////////
104
105   ResObject::Ptr makeResObject( const sat::Solvable & solvable_r )
106   {
107     if ( ! solvable_r )
108       return 0;
109
110     ResKind kind( solvable_r.kind() );
111 #define OUTS(X)  if ( kind == ResTraits<X>::kind ) return make<X>( solvable_r );
112     OUTS( Package );
113     OUTS( Patch );
114     OUTS( Pattern );
115     OUTS( Product );
116     OUTS( SrcPackage );
117 #undef OUTS
118     // unknow => return a plain ResObject
119     return new ResObject( solvable_r );
120   }
121
122   /////////////////////////////////////////////////////////////////
123 } // namespace zypp
124 ///////////////////////////////////////////////////////////////////