dd193ea66d03cb28af9ae981d23a0586b87859ed
[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 package is read, a \ref OnMediaLocation
35    * and \ref repo::yum::ResourceType is prepared and \ref _callback
36    * is called with these two objects passed in.
37    *
38    * The \ref _callback is provided on construction.
39    *
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    /**
50     * Callback definition.
51     * First parameter is a \ref OnMediaLocation object with the resource
52     * second parameter is the resource type.
53     */
54     typedef function< bool(
55         const OnMediaLocation &,
56         const repo::yum::ResourceType &)>
57       ProcessResource;
58
59    /**
60     * CTOR. Creates also \ref xml::Reader and starts reading.
61     * 
62     * \param repomd_file is the repomd.xml file you want to read
63     * \param callback is a function.
64     *
65     * \see RepomdFileReader::ProcessResource
66     */
67     RepomdFileReader(
68       const Pathname & repomd_file, const ProcessResource & callback);
69
70     /**
71      * DTOR
72      */
73     ~RepomdFileReader();
74
75   private:
76     class Impl;
77     RW_pointer<Impl,rw_pointer::Scoped<Impl> > _pimpl;
78   };
79
80
81     } // ns yum
82   } // ns parser
83 } // ns zypp
84
85 #endif /*zypp_source_yum_RepomdFileReader_H*/
86
87 // vim: set ts=2 sts=2 sw=2 et ai: