Imported Upstream version 16.3.2
[platform/upstream/libzypp.git] / zypp / parser / yum / RepomdFileReader.h
1 /*---------------------------------------------------------------------\
2 |                          ____ _   __ __ ___                          |
3 |                         |__  / \ / / . \ . \                         |
4 |                           / / \ V /|  _/  _/                         |
5 |                          / /__ | | | | | |                           |
6 |                         /_____||_| |_| |_|                           |
7 |                                                                      |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/parser/yum/RepomdFileReader.h
10  * Interface of repomd.xml file reader.
11  */
12 #ifndef zypp_source_yum_RepomdFileReader_H
13 #define zypp_source_yum_RepomdFileReader_H
14
15 #include "zypp/base/PtrTypes.h"
16 #include "zypp/base/NonCopyable.h"
17 #include "zypp/base/Function.h"
18
19 #include "zypp/OnMediaLocation.h"
20 #include "zypp/repo/yum/ResourceType.h"
21
22 namespace zypp
23 {
24   namespace parser
25   {
26     namespace yum
27     {
28
29
30   /**
31    * Reads through a repomd.xml file and collects type, location, checksum and
32    * other data about metadata files to be processed.
33    *
34    * After each file entry is read, a \ref OnMediaLocation
35    * and \ref repo::yum::ResourceType are prepared and passed to the \ref _callback.
36    *
37    * Depending on the \ref _callback type provided on construction, ResourceType may
38    * additionally be passed as a plain string. This form allows handling custom
39    * resource types (e.g. ones with embedded locale tag).
40    *
41    * \code
42    * RepomdFileReader reader(repomd_file, 
43    *                  bind( &SomeClass::callbackfunc, &SomeClassInstance, _1, _2 ) );
44    * \endcode
45    */
46   class RepomdFileReader : private base::NonCopyable
47   {
48   public:
49    /** Callbacl taking \ref OnMediaLocation and \ref repo::yum::ResourceType */
50     typedef function< bool( const OnMediaLocation &, const repo::yum::ResourceType & )> ProcessResource;
51
52     /** Alternate callback also receiving the ResourceType as string. */
53     typedef function< bool( const OnMediaLocation &, const repo::yum::ResourceType &, const std::string & )> ProcessResource2;
54
55    /**
56     * CTOR. Creates also \ref xml::Reader and starts reading.
57     * 
58     * \param repomd_file is the repomd.xml file you want to read
59     * \param callback is a function.
60     *
61     * \see RepomdFileReader::ProcessResource
62     */
63     RepomdFileReader( const Pathname & repomd_file, const ProcessResource & callback );
64     /** \overload taking ProcessResource2 callback */
65     RepomdFileReader( const Pathname & repomd_file, const ProcessResource2 & callback );
66
67     /** DTOR */
68     ~RepomdFileReader();
69
70   private:
71     class Impl;
72     RW_pointer<Impl,rw_pointer::Scoped<Impl> > _pimpl;
73   };
74
75
76     } // namespace yum
77   } // namespace parser
78 } // namespace zypp
79
80 #endif // zypp_source_yum_RepomdFileReader_H