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