Convenience constructor for PoolItem from Solvable and ResObject
[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/base/Logger.h>
14 #include "zypp/ResObject.h"
15 #include "zypp/sat/SolvAttr.h"
16 #include "zypp/sat/Solvable.h"
17 #include "zypp/Repository.h"
18 #include "zypp/RepoInfo.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   //    ResObject interface forwarded to implementation
59   //
60   ///////////////////////////////////////////////////////////////////
61
62   Text ResObject::summary() const
63   { return lookupStrAttribute( sat::SolvAttr::summary ); }
64
65   Text ResObject::description() const
66   { return lookupStrAttribute( sat::SolvAttr::description ); }
67
68   Text ResObject::insnotify() const
69   { return lookupStrAttribute( sat::SolvAttr::insnotify ); }
70
71   Text ResObject::delnotify() const
72   { return lookupStrAttribute( sat::SolvAttr::delnotify ); }
73
74   License ResObject::licenseToConfirm() const
75   { return lookupStrAttribute( sat::SolvAttr::eula ); }
76
77   ByteCount ResObject::size() const
78   { return ByteCount( lookupNumAttribute( sat::SolvAttr::size ), ByteCount::K ); }
79
80   ByteCount ResObject::downloadSize() const
81   { return ByteCount( lookupNumAttribute( sat::SolvAttr::downloadsize ), ByteCount::K ); }
82
83   unsigned ResObject::mediaNr() const
84   { return lookupNumAttribute( sat::SolvAttr::medianr ); }
85
86 #warning DUMMY installOnly
87   bool ResObject::installOnly() const
88   { return false; }
89
90 #warning DUMMY
91   Date ResObject::buildtime() const
92   { return Date(); }
93
94 #warning DUMMY installtime
95   Date ResObject::installtime() const
96   { return Date(); }
97
98 #warning DUMMY diskusage
99   const DiskUsage & ResObject::diskusage() const
100   {
101     static DiskUsage _du;
102     return _du;
103   }
104
105    /////////////////////////////////////////////////////////////////
106 } // namespace zypp
107 ///////////////////////////////////////////////////////////////////
108
109 #include "zypp/ResObjects.h"
110
111 ///////////////////////////////////////////////////////////////////
112 namespace zypp
113 { /////////////////////////////////////////////////////////////////
114
115   ResObject::Ptr makeResObject( const sat::Solvable & solvable_r )
116   {
117     ResKind kind( solvable_r.kind() );
118 #define OUTS(X)  if ( kind == ResTraits<X>::kind ) return make<X>( solvable_r );
119     OUTS( Atom );
120     OUTS( Message );
121     OUTS( Package );
122     OUTS( Patch );
123     OUTS( Pattern );
124     OUTS( Product );
125     OUTS( Script );
126     OUTS( SrcPackage );
127 #undef OUTS
128     return 0;
129   }
130
131   /////////////////////////////////////////////////////////////////
132 } // namespace zypp
133 ///////////////////////////////////////////////////////////////////