Add ResObject construction from Solvable
[platform/upstream/libzypp.git] / zypp / ResObject.cc
1 /*---------------------------------------------------------------------\
2 |                          ____ _   __ __ ___                          |
3 |                         |__  / \ / / . \ . \                         |
4 |                           / / \ V /|  _/  _/                         |
5 |                          / /__ | | | | | |                           |
6 |                         /_____||_| |_| |_|                           |
7 |                                                                      |
8 \---------------------------------------------------------------------*/
9 /** \file       zypp/ResObject.cc
10  *
11 */
12 #include "zypp/ResObject.h"
13 #include "zypp/Repository.h"
14
15 ///////////////////////////////////////////////////////////////////
16 namespace zypp
17 { /////////////////////////////////////////////////////////////////
18
19   IMPL_PTR_TYPE(ResObject);
20
21   ///////////////////////////////////////////////////////////////////
22   //
23   //    METHOD NAME : ResObject::ResObject
24   //    METHOD TYPE : Ctor
25   //
26   ResObject::ResObject( const sat::Solvable & solvable_r )
27   : Resolvable( solvable_r )
28   {}
29
30   ///////////////////////////////////////////////////////////////////
31   //
32   //    METHOD NAME : ResObject::~ResObject
33   //    METHOD TYPE : Dtor
34   //
35   ResObject::~ResObject()
36   {}
37
38   ///////////////////////////////////////////////////////////////////
39   //
40   //    METHOD NAME : ResObject::dumpOn
41   //    METHOD TYPE : std::ostream &
42   //
43   std::ostream & ResObject::dumpOn( std::ostream & str ) const
44   {
45     return Resolvable::dumpOn( str << "[S" << repository().numericId() << ":" << mediaNr() << "]" );
46   }
47
48   ///////////////////////////////////////////////////////////////////
49   //
50   //    ResObject interface forwarded to implementation
51   //
52   ///////////////////////////////////////////////////////////////////
53
54   Text ResObject::summary() const
55   { return Text(); }
56
57   Text ResObject::description() const
58   { return Text(); }
59
60   Text ResObject::insnotify() const
61   { return Text(); }
62
63   Text ResObject::delnotify() const
64   { return Text(); }
65
66   License ResObject::licenseToConfirm() const
67   { return License(); }
68
69   Vendor ResObject::vendor() const
70   { return Vendor(); }
71
72   ByteCount ResObject::size() const
73   { return ByteCount(); }
74
75   Repository ResObject::repository() const
76   { return Repository(); }
77
78   ByteCount ResObject::downloadSize() const
79   { return ByteCount(); }
80
81   unsigned ResObject::mediaNr() const
82   { return 0; }
83
84   bool ResObject::installOnly() const
85   { return false; }
86
87   Date ResObject::buildtime() const
88   { return Date(); }
89
90   Date ResObject::installtime() const
91   { return Date(); }
92
93   const DiskUsage & ResObject::diskusage() const
94   {
95     static DiskUsage _du;
96     return _du;
97   }
98
99    /////////////////////////////////////////////////////////////////
100 } // namespace zypp
101 ///////////////////////////////////////////////////////////////////
102
103 #include "zypp/ResObjects.h"
104
105 ///////////////////////////////////////////////////////////////////
106 namespace zypp
107 { /////////////////////////////////////////////////////////////////
108
109   ResObject::Ptr makeResObject( const sat::Solvable & solvable_r )
110   {
111     ResKind kind( solvable_r.kind() );
112 #define OUTS(X)  if ( kind == ResTraits<X>::kind ) return make<X>( solvable_r );
113     OUTS( Atom );
114     OUTS( Language );
115     OUTS( Message );
116     OUTS( Package );
117     OUTS( Patch );
118     OUTS( Pattern );
119     OUTS( Product );
120     OUTS( Script );
121     OUTS( Selection );
122     OUTS( SrcPackage );
123 #undef OUTS
124     return 0;
125   }
126
127   /////////////////////////////////////////////////////////////////
128 } // namespace zypp
129 ///////////////////////////////////////////////////////////////////