Moved DiskUsage class out of PackageImplIf
[platform/upstream/libzypp.git] / zypp / target / rpm / RpmHeader.h
1 /*---------------------------------------------------------------------\
2 |                          ____ _   __ __ ___                          |
3 |                         |__  / \ / / . \ . \                         |
4 |                           / / \ V /|  _/  _/                         |
5 |                          / /__ | | | | | |                           |
6 |                         /_____||_| |_| |_|                           |
7 |                                                                      |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/target/rpm/RpmHeader.h
10  *
11 */
12 #ifndef ZYPP_TARGET_RPM_RPMHEADER_H
13 #define ZYPP_TARGET_RPM_RPMHEADER_H
14
15 #include <iosfwd>
16 #include <list>
17
18 #include "zypp/target/rpm/BinHeader.h"
19
20 #include "zypp/Package.h"
21 #include "zypp/Changelog.h"
22 #include "zypp/CapSetFwd.h"
23 #include "zypp/Pathname.h"
24 #include "zypp/DiskUsage.h"
25
26 namespace zypp {
27   namespace target {
28     namespace rpm {
29
30       
31       ///////////////////////////////////////////////////////////////////
32       //
33       //        CLASS NAME : RpmHeader
34       /**
35        * @short Wrapper class for rpm header struct.
36        *
37        * <code>RpmHeader</code> provides methods to query the content
38        * of a rpm header struct retrieved from the RPM database or by reading
39        * the rpm header of a package on disk.
40        *
41        * The rpm header contains all data associated with a package. So you
42        * probabely do not want to permanently store too many of them.
43        *
44        * <B>NEVER create <code>RpmHeader</code> from a NULL <code>Header</code>! </B>
45        **/
46       class RpmHeader : public BinHeader {
47         public:
48           typedef intrusive_ptr<RpmHeader> Ptr;
49           typedef intrusive_ptr<const RpmHeader> constPtr;
50
51         private:
52       
53           CapSet PkgRelList_val( tag tag_r, bool pre, std::set<std::string> * freq_r = 0 ) const;
54       
55         public:
56       
57           /**
58            *
59            **/
60           RpmHeader( Header h_r = 0 );
61       
62           /**
63            * <B>Dangerous!<\B> This one takes the header out of rhs
64            * and leaves rhs empty.
65            **/
66           RpmHeader( BinHeader::Ptr & rhs );
67       
68           virtual ~RpmHeader();
69       
70           bool isSrc() const;
71       
72         public:
73       
74           std::string    tag_name()        const;
75           Edition tag_edition()     const;
76           Arch    tag_arch()        const;
77       
78           Date       tag_installtime() const;
79           Date       tag_buildtime()   const;
80       
81           /**
82            * If <code>freq_r</code> is not NULL, file dependencies found are inserted.
83            **/
84           CapSet tag_provides ( std::set<std::string> * freq_r = 0 ) const;
85           /**
86            * @see #tag_provides
87            **/
88           CapSet tag_requires ( std::set<std::string> * freq_r = 0 ) const;
89           /**
90            * @see #tag_provides
91            **/
92           CapSet tag_prerequires ( std::set<std::string> * freq_r = 0 ) const;
93           /**
94            * @see #tag_provides
95            **/
96           CapSet tag_conflicts( std::set<std::string> * freq_r = 0 ) const;
97           /**
98            * @see #tag_provides
99            **/
100           CapSet tag_obsoletes( std::set<std::string> * freq_r = 0 ) const;
101       
102           ByteCount tag_size()        const;
103           ByteCount tag_archivesize() const;
104       
105           std::string tag_summary()      const;
106           std::string tag_description()  const;
107           std::string tag_group()        const;
108           std::string tag_vendor()       const;
109           std::string tag_distribution() const;
110           std::string tag_license()      const;
111           std::string tag_buildhost()    const;
112           std::string tag_packager()     const;
113           std::string tag_url()          const;
114           std::string tag_os()           const;
115           std::string tag_prein()        const;
116           std::string tag_postin()       const;
117           std::string tag_preun()        const;
118           std::string tag_postun()       const;
119           std::string tag_sourcerpm()    const;
120       
121           std::list<std::string> tag_filenames() const;
122       
123           Changelog tag_changelog() const;
124      
125           /**
126            * Returns reference to arg <code>dudata_r</code>.
127            **/
128           DiskUsage & tag_du( DiskUsage & dudata_r ) const;
129       
130         public:
131       
132           virtual std::ostream & dumpOn( std::ostream & str ) const;
133       
134         public:
135       
136           /**
137            * Digest and signature verification flags
138            **/
139           enum VERIFICATION {
140             VERIFY       = 0x0000,
141             NODIGEST     = (1<<0),
142             NOSIGNATURE  = (1<<1),
143             NOVERIFY     = 0xffff
144           };
145       
146           /**
147            * Get an accessible packages data from disk.
148            * Returns NULL on any error.
149            **/
150           static RpmHeader::constPtr readPackage( const Pathname & path,
151                                           VERIFICATION verification = VERIFY );
152       };
153
154 ///////////////////////////////////////////////////////////////////
155     } // namespace rpm
156   } // namespace target
157 } // namespace zypp
158
159 #endif // ZYPP_TARGET_RPM_RPMHEADER_H
160