backup - creating package resolvable
[platform/upstream/libzypp.git] / zypp / detail / PackageImplIf.h
1 /*---------------------------------------------------------------------\
2 |                          ____ _   __ __ ___                          |
3 |                         |__  / \ / / . \ . \                         |
4 |                           / / \ V /|  _/  _/                         |
5 |                          / /__ | | | | | |                           |
6 |                         /_____||_| |_| |_|                           |
7 |                                                                      |
8 \---------------------------------------------------------------------*/
9 /** \file       zypp/detail/PackageImplIf.h
10  *
11 */
12 #ifndef ZYPP_DETAIL_PACKAGEIMPLIF_H
13 #define ZYPP_DETAIL_PACKAGEIMPLIF_H
14
15 #include "zypp/detail/ResObjectImplIf.h"
16 #include "zypp/Edition.h"
17 #include "zypp/Arch.h"
18
19 ///////////////////////////////////////////////////////////////////
20 namespace zypp
21 { /////////////////////////////////////////////////////////////////
22
23   class Package;
24
25   ///////////////////////////////////////////////////////////////////
26   namespace detail
27   { /////////////////////////////////////////////////////////////////
28
29     ///////////////////////////////////////////////////////////////////
30     //
31     //  CLASS NAME : PackageImplIf
32     //
33     /** Abstact Package implementation interface.
34     */
35     class PackageImplIf : public ResObjectImplIf
36     {
37     public:
38       typedef Package ResType;
39       class CheckSum
40       {
41       public:
42         CheckSum(const std::string & type, const std::string & checksum)
43         : _type(type)
44         , _checksum(checksum)
45         {}
46         std::string type() { return _type; }
47         std::string checksum() { return _checksum; }
48       private:
49         std::string _type;
50         std::string _checksum;
51       };
52       class BaseVersion
53       {
54       public:
55         BaseVersion(const Edition & edition,
56                     const CheckSum & checksum,
57                     const Date & buildtime)
58         : _edition(edition)
59         , _checksum(checksum)
60         , _buildtime(buildtime)
61         {}
62         Edition edition() const { return _edition; }
63         CheckSum checksum() const { return _checksum; }
64         Date buildtime() const { return _buildtime; }
65       private:
66         Edition _edition;
67         PackageImplIf::CheckSum _checksum;
68         Date _buildtime;
69       };
70       class DeltaRpm
71       {
72       public:
73         DeltaRpm(const Arch & arch,
74                  const std::string & filename, 
75                  const FSize & downloadsize,
76                  const CheckSum & checksum,
77                  const Date & buildtime,
78                  const BaseVersion & base_version)
79         : _arch(arch)
80         , _filename(filename)
81         , _downloadsize(downloadsize)
82         , _checksum(checksum)
83         , _buildtime(buildtime)
84         , _base_version(base_version)
85         {}
86         Arch arch() { return _arch; }
87         std::string filename() { return _filename; }
88         FSize downloadsize() { return _downloadsize; }
89         CheckSum checksum() { return _checksum; }
90         Date buildtime() { return _buildtime; }
91         BaseVersion baseVersion() { return _base_version; }
92       private:
93         Arch _arch;
94         std::string _filename;
95         FSize _downloadsize;
96         CheckSum _checksum;
97         Date _buildtime;
98         BaseVersion _base_version;
99       };
100       class PatchRpm
101       {
102       public:
103         PatchRpm(const Arch & arch,
104                  const std::string & filename, 
105                  const FSize & downloadsize,
106                  const CheckSum & checksum,
107                  const Date & buildtime,
108                  const std::list<BaseVersion> & base_versions)
109         : _arch(arch)
110         , _filename(filename)
111         , _downloadsize(downloadsize)
112         , _checksum(checksum)
113         , _buildtime(buildtime)
114         , _base_versions(base_versions)
115         {}
116         Arch arch() { return _arch; }
117         std::string filename() { return _filename; }
118         FSize downloadsize() { return _downloadsize; }
119         CheckSum checksum() { return _checksum; }
120         Date buildtime() { return _buildtime; }
121         std::list<BaseVersion> baseVersions() { return _base_versions; }
122       private:
123         Arch _arch;
124         std::string _filename;
125         FSize _downloadsize;
126         CheckSum _checksum;
127         Date _buildtime;
128         std::list<BaseVersion> _base_versions;
129       };
130
131 #if 0
132       /**
133       * @short Holds data about how much space will be needed per directory
134       **/
135       class DirSize {
136       public:
137         DirSize();
138         DirSize(const std::string& path,
139                 const std::string& size,
140                 const std::string& fileCount)
141         : path(path), sizeKByte(size), fileCount(fileCount)
142         {}
143         const std::string path;
144         const std::string sizeKByte;
145         const std::string fileCount;
146       };
147     
148       /**
149        * @short Holds Data about file and file type
150        *  (directory, plain)
151        **/
152       class FileData {
153       public:
154         std::string name;
155         std::string type;
156         FileData();
157         FileData(const std::string &name,
158                  const std::string &type)
159         : name(name), type(type)
160         {}
161       };
162 #endif
163
164     public:
165       /** \name Rpm Package Attributes. */
166       //@{
167       /** */
168       virtual Date buildtime() const PURE_VIRTUAL;
169       /** */
170       virtual std::string buildhost() const PURE_VIRTUAL;
171       /** */
172       virtual Date installtime() const PURE_VIRTUAL;
173       /** */
174       virtual std::string distribution() const PURE_VIRTUAL;
175       /** */
176       virtual Vendor vendor() const PURE_VIRTUAL;
177       /** */
178       virtual Label license() const PURE_VIRTUAL;
179       /** */
180       virtual std::string packager() const PURE_VIRTUAL;
181       /** */
182       virtual PackageGroup group() const PURE_VIRTUAL;
183       /** */
184       virtual Text changelog() const PURE_VIRTUAL;
185       /** Don't ship it as class Url, because it might be
186        * in fact anything but a legal Url. */
187       virtual std::string url() const PURE_VIRTUAL;
188       /** */
189       virtual std::string os() const PURE_VIRTUAL;
190       /** */
191       virtual Text prein() const PURE_VIRTUAL;
192       /** */
193       virtual Text postin() const PURE_VIRTUAL;
194       /** */
195       virtual Text preun() const PURE_VIRTUAL;
196       /** */
197       virtual Text postun() const PURE_VIRTUAL;
198       /** */
199       virtual FSize sourcesize() const PURE_VIRTUAL;
200       /** */
201       virtual FSize archivesize() const PURE_VIRTUAL;
202       /** */
203       virtual Text authors() const PURE_VIRTUAL;
204       /** */
205       virtual Text filenames() const PURE_VIRTUAL;
206       //@}
207
208       /** \name Additional Package Attributes.
209        * \todo review what's actually needed here. Maybe worth grouping
210        * all the package rertieval related stuff in a class. Easier to ship
211        * and handle it.
212       */
213       //@{
214       /** */
215       virtual License licenseToConfirm() const PURE_VIRTUAL;
216 #if 0
217       /** */
218       virtual std::string sourceloc() const PURE_VIRTUAL;
219       /** */
220       virtual void du( PkgDu & dudata_r ) const PURE_VIRTUAL;
221       /** */
222       virtual std::string location() const PURE_VIRTUAL;
223       /** */
224       virtual unsigned int medianr() const PURE_VIRTUAL;
225       /** */
226       virtual PackageKeywords keywords() const PURE_VIRTUAL;
227       /** */
228       virtual std::string md5sum() const PURE_VIRTUAL;
229       /** */
230       virtual std::string externalUrl() const PURE_VIRTUAL;
231       /** */
232       virtual std::list<Edition> patchRpmBaseVersions() const PURE_VIRTUAL;
233       /** */
234       virtual FSize patchRpmSize() const PURE_VIRTUAL;
235       /** */
236       virtual bool forceInstall() const PURE_VIRTUAL;
237       /** */
238       virtual std::string patchRpmMD5() const PURE_VIRTUAL;
239       /** */
240       virtual bool isRemote() const PURE_VIRTUAL;
241       /** */
242       virtual PMError providePkgToInstall( Pathname& path_r ) const PURE_VIRTUAL;
243       /** */
244       virtual PMError provideSrcPkgToInstall( Pathname& path_r ) const PURE_VIRTUAL;
245       /** */
246       virtual constInstSrcPtr source() const PURE_VIRTUAL;
247       /** */
248       virtual std::list<PMPackageDelta> deltas() const PURE_VIRTUAL;
249 #endif
250       //@}
251     };
252     ///////////////////////////////////////////////////////////////////
253
254     /////////////////////////////////////////////////////////////////
255   } // namespace detail
256   ///////////////////////////////////////////////////////////////////
257   /////////////////////////////////////////////////////////////////
258 } // namespace zypp
259 ///////////////////////////////////////////////////////////////////
260 #endif // ZYPP_DETAIL_PACKAGEIMPLIF_H