From: Duncan Mac-Vicar P Date: Thu, 19 Jul 2007 15:07:45 +0000 (+0000) Subject: documentation, add constructor from file X-Git-Tag: BASE-SuSE-Linux-10_3-Branch~521 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c488b16a279cef77d5f2645e28df17edee4d0292;p=platform%2Fupstream%2Flibzypp.git documentation, add constructor from file --- diff --git a/zypp/repo/SUSEMediaVerifier.cc b/zypp/repo/SUSEMediaVerifier.cc index 4f5fbd0..3b84c3f 100644 --- a/zypp/repo/SUSEMediaVerifier.cc +++ b/zypp/repo/SUSEMediaVerifier.cc @@ -1,3 +1,11 @@ +/*---------------------------------------------------------------------\ +| ____ _ __ __ ___ | +| |__ / \ / / . \ . \ | +| / / \ V /| _/ _/ | +| / /__ | | | | | | | +| /_____||_| |_| |_| | +| | +\---------------------------------------------------------------------*/ #include #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()) diff --git a/zypp/repo/SUSEMediaVerifier.h b/zypp/repo/SUSEMediaVerifier.h index a452969..f778c68 100644 --- a/zypp/repo/SUSEMediaVerifier.h +++ b/zypp/repo/SUSEMediaVerifier.h @@ -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;