Imported Upstream version 14.45.0
[platform/upstream/libzypp.git] / zypp / parser / RepoindexFileReader.h
1 /*---------------------------------------------------------------------\
2 |                          ____ _   __ __ ___                          |
3 |                         |__  / \ / / . \ . \                         |
4 |                           / / \ V /|  _/  _/                         |
5 |                          / /__ | | | | | |                           |
6 |                         /_____||_| |_| |_|                           |
7 |                                                                      |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/parser/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 #include "zypp/base/InputStream.h"
19 #include "zypp/Pathname.h"
20
21 namespace zypp
22 {
23   class RepoInfo;
24
25   namespace parser
26   {
27
28   /**
29    * Reads through a repoindex.xml file and collects repositories.
30    *
31    * After each repository is read, a \ref RepoInfo
32    * is prepared and \ref _callback
33    * is called with this object passed in.
34    *
35    * The \ref _callback is provided on construction.
36    *
37    *
38    * \code
39    * RepoindexFileReader reader(repoindex_file,
40    *                  bind( &SomeClass::callbackfunc, &SomeClassInstance, _1) );
41    * \endcode
42    */
43   class RepoindexFileReader : private base::NonCopyable
44   {
45   public:
46    /**
47     * Callback definition.
48     * First parameter is a \ref RepoInfo object with the resource
49     * FIXME return value is ignored
50     */
51     typedef function< bool(
52         const RepoInfo & )>
53       ProcessResource;
54
55    /**
56     * CTOR. Creates also \ref xml::Reader and starts reading.
57     *
58     * \param repoindexFile is the repoindex.xml file you want to read
59     * \param callback is a function.
60     *
61     * \see RepoindexFileReader::ProcessResource
62     */
63     RepoindexFileReader( const zypp::Pathname & repoindexFile,
64                          const ProcessResource & callback);
65
66     /**
67      * \short Constructor. Creates the reader and start reading.
68      *
69      * \param is a valid input stream
70      * \param callback Callback that will be called for each repository.
71      *
72      * \see RepoindexFileReader::ProcessResource
73      */
74      RepoindexFileReader( const InputStream &is,
75                           const ProcessResource & callback );
76
77     /**
78      * DTOR
79      */
80     ~RepoindexFileReader();
81
82   private:
83     class Impl;
84     RW_pointer<Impl,rw_pointer::Scoped<Impl> > _pimpl;
85   };
86
87
88   } // ns parser
89 } // ns zypp
90
91 #endif /*zypp_source_yum_RepoindexFileReader_H*/
92
93 // vim: set ts=2 sts=2 sw=2 et ai: