documentation, add constructor from file
authorDuncan Mac-Vicar P <dmacvicar@suse.de>
Thu, 19 Jul 2007 15:07:45 +0000 (15:07 +0000)
committerDuncan Mac-Vicar P <dmacvicar@suse.de>
Thu, 19 Jul 2007 15:07:45 +0000 (15:07 +0000)
zypp/repo/SUSEMediaVerifier.cc
zypp/repo/SUSEMediaVerifier.h

index 4f5fbd0..3b84c3f 100644 (file)
@@ -1,3 +1,11 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
 
 #include <fstream>
 #include "zypp/repo/SUSEMediaVerifier.h"
@@ -9,12 +17,32 @@ namespace zypp
 namespace repo
 {
 
-SUSEMediaVerifier::SUSEMediaVerifier(const std::string & vendor_r, const std::string & id_r, const media::MediaNr media_nr)
+SUSEMediaVerifier::SUSEMediaVerifier(const std::string & vendor_r,
+                                     const std::string & id_r,
+                                     const media::MediaNr media_nr)
    : _media_vendor(vendor_r)
     , _media_id(id_r)
     , _media_nr(media_nr)
 {}
 
+SUSEMediaVerifier::SUSEMediaVerifier( const Pathname &path_r )
+{
+  std::ifstream str(path_r.asString().c_str());
+  std::string vendor;
+  std::string id;
+  
+  if ( str )
+  {
+    getline(str, _media_vendor);
+    getline(str, _media_id);
+  }
+  else
+  {
+    ZYPP_THROW(Exception("Can't setup media verifier using file: '"
+        + path_r.asString() + "'"));
+  }
+}
+
 bool SUSEMediaVerifier::isDesiredMedia(const media::MediaAccessRef &ref)
 {
   if (_media_vendor.empty() || _media_id.empty())
index a452969..f778c68 100644 (file)
@@ -1,3 +1,11 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
 
 #ifndef ZYPP_SUSE_MEDIAVERIFIER_H
 #define ZYPP_SUSE_MEDIAVERIFIER_H
@@ -10,16 +18,42 @@ namespace zypp
   namespace repo
   {
 
+    /**
+     * \short Implementation of the traditional SUSE media verifier
+     */
     class SUSEMediaVerifier : public zypp::media::MediaVerifierBase
     {
       public:
-      /** ctor */
-      SUSEMediaVerifier(const std::string & vendor_r, const std::string & id_r, const media::MediaNr media_nr = 1);
       /**
+       * \short create a verifier from attributes
+       *
+       * Creates a verifier for the media using
+       * the attributes
+       *
+       * \param vendor_r i.e. "SUSE Linux Products GmbH"
+       * \param id_r i.e. "20070718164719"
+       * \param media_nr media number
+       */
+      SUSEMediaVerifier(const std::string & vendor_r,
+                        const std::string & id_r,
+                        const media::MediaNr media_nr = 1);
+      
+      /**
+       * \short creates a verifier from a media file
+       */
+      SUSEMediaVerifier( const Pathname &path_r );
+      
+      /**
+        * \short Check if it is the desider media
+        *
         * Check if the specified attached media contains
         * the desired media number (e.g. SLES10 CD1).
+        *
+        * Reimplementation of virtual function, will be
+        * called by the component verifying the media.
         */
       virtual bool isDesiredMedia(const media::MediaAccessRef &ref);
+      
       private:
         std::string _media_vendor;
         std::string _media_id;