initial Service implementation. Also little refactor of RepoManager.
[platform/upstream/libzypp.git] / zypp / parser / RepoindexFileReader.h
1 /*---------------------------------------------------------------------\
2 |                          ____ _   __ __ ___                          |
3 |                         |__  / \ / / . \ . \                         |
4 |                           / / \ V /|  _/  _/                         |
5 |                          / /__ | | | | | |                           |
6 |                         /_____||_| |_| |_|                           |
7 |                                                                      |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/parser/yum/RepoindexFileReader.h
10  * Interface of repoindex.xml file reader.
11  */
12 #ifndef zypp_source_yum_RepoindexFileReader_H
13 #define zypp_source_yum_RepoindexFileReader_H
14
15 #include "zypp/base/PtrTypes.h"
16 #include "zypp/base/NonCopyable.h"
17 #include "zypp/base/Function.h"
18
19 #include "zypp/RepoInfo.h"
20
21 namespace zypp
22 {
23   namespace parser
24   {
25
26   /**
27    * Reads through a repoindex.xml file and collects repositories.
28    *
29    * After each repository is read, a \ref RepoInfo
30    * is prepared and \ref _callback
31    * is called with these two objects passed in.
32    *
33    * The \ref _callback is provided on construction.
34    *
35    *
36    * \code
37    * RepoindexFileReader reader(repoindex_file, 
38    *                  bind( &SomeClass::callbackfunc, &SomeClassInstance, _1) );
39    * \endcode
40    */
41   class RepoindexFileReader : private base::NonCopyable
42   {
43   public:
44    /**
45     * Callback definition.
46     * First parameter is a \ref RepoInfo object with the resource
47     * second parameter is the resource type.
48     */
49     typedef function< bool(
50         const RepoInfo & )>
51       ProcessResource;
52
53    /**
54     * CTOR. Creates also \ref xml::Reader and starts reading.
55     * 
56     * \param repoindex_file is the repoindex.xml file you want to read
57     * \param callback is a function.
58     *
59     * \see RepoindexFileReader::ProcessResource
60     */
61     RepoindexFileReader(
62       const Pathname & repoindex_file, const ProcessResource & callback);
63
64     /**
65      * DTOR
66      */
67     ~RepoindexFileReader();
68
69   private:
70     class Impl;
71     RW_pointer<Impl,rw_pointer::Scoped<Impl> > _pimpl;
72   };
73
74
75   } // ns parser
76 } // ns zypp
77
78 #endif /*zypp_source_yum_RepoindexFileReader_H*/
79
80 // vim: set ts=2 sts=2 sw=2 et ai: