Imported Upstream version 17.22.0
[platform/upstream/libzypp.git] / zypp / parser / yum / RepomdFileReader.h
index f5a49a7..fdebdea 100644 (file)
@@ -6,19 +6,17 @@
 |                         /_____||_| |_| |_|                           |
 |                                                                      |
 \---------------------------------------------------------------------*/
-
+/** \file zypp/parser/yum/RepomdFileReader.h
+ * Interface of repomd.xml file reader.
+ */
 #ifndef zypp_source_yum_RepomdFileReader_H
 #define zypp_source_yum_RepomdFileReader_H
 
-#include "zypp/Date.h"
-#include "zypp/CheckSum.h"
-#include "zypp/OnMediaLocation.h"
+#include "zypp/base/PtrTypes.h"
+#include "zypp/base/NonCopyable.h"
 #include "zypp/base/Function.h"
-#include "zypp/parser/xml/Reader.h"
-#include "zypp/source/yum/YUMResourceType.h"
 
-using namespace std;
-using namespace zypp::xml;
+#include "zypp/OnMediaLocation.h"
 
 namespace zypp
 {
@@ -26,68 +24,42 @@ namespace zypp
   {
     namespace yum
     {
-    
-     /**
-      * Iterates through a repomd.xml file giving on each iteration
-      * a \ref OnMediaLocation object with the resource and its
-      * type ( primary, patches, filelists, etc ).
-      * The iteration is done via a callback provided on
-      * construction.
-      *
-      * \code
-      * RepomdFileReader reader(repomd_file, 
-      *                  bind( &SomeClass::callbackfunc, &object, _1, _2 ) );
-      * \endcode
-      */
-      class RepomdFileReader
-      {
-      public:
-       /**
-        * Callback definition
-        * first parameter is a \ref OnMediaLocation object with the resource
-        * second parameter is the resource type
-        */
-        typedef function< bool(
-            const OnMediaLocation &,
-            const source::yum::YUMResourceType & )>
-          ProcessResource;
 
-        enum Tag
-        {
-          tag_NONE,
-          tag_Repomd,
-          tag_Data,
-          tag_Location,
-          tag_CheckSum,
-          tag_Timestamp,
-          tag_OpenCheckSum
-        };
-        
-       /**
-        * Constructor
-        * \param repomd_file is the repomd.xml file you want to read
-        * \param callback is a function. \see RepomdFileReader::ProcessResource
-        */
-        RepomdFileReader( const Pathname &repomd_file, ProcessResource callback );
-        
-        /**
-        * Callback provided to the XML parser. Don't use it.
-        */
-        bool consumeNode( Reader & reader_r );
-        
-        private:
-          OnMediaLocation _location;
-          Tag _tag;
-          source::yum::YUMResourceType _type;
-          ProcessResource _callback;
-          CheckSum _checksum;
-          std::string _checksum_type;
-          Date _timestamp;
-      };
-    }
-  }
-}
 
-#endif
+  /**
+   * Reads through a repomd.xml file and collects type, location, checksum and
+   * other data about metadata files to be processed.
+   *
+   * After each file entry is read, an \ref OnMediaLocation and the resource type
+   * string are prepared and passed to the \ref _callback.
+   */
+  class RepomdFileReader : private base::NonCopyable
+  {
+  public:
+    /** Callback taking \ref OnMediaLocation and the resource type string */
+    typedef function< bool( OnMediaLocation &&, const std::string & )> ProcessResource;
+
+   /**
+    * CTOR. Creates also \ref xml::Reader and starts reading.
+    * 
+    * \param repomd_file is the repomd.xml file you want to read
+    * \param callback is a function.
+    *
+    * \see RepomdFileReader::ProcessResource
+    */
+    RepomdFileReader( const Pathname & repomd_file, const ProcessResource & callback );
+
+    /** DTOR */
+    ~RepomdFileReader();
+
+  private:
+    class Impl;
+    RW_pointer<Impl,rw_pointer::Scoped<Impl> > _pimpl;
+  };
+
 
+    } // namespace yum
+  } // namespace parser
+} // namespace zypp
 
+#endif // zypp_source_yum_RepomdFileReader_H