From 978e600ed4de75d946d95dfb0c1e2bbbec99cb98 Mon Sep 17 00:00:00 2001 From: Duncan Mac-Vicar P Date: Thu, 31 May 2007 16:00:01 +0000 Subject: [PATCH] clean more class names move data not belonging to RepoInfo to RepoStatus, like the checksum or timestamp. --- zypp2/CMakeLists.txt | 16 +++--- zypp2/RepoInfo.cc | 43 ++++------------ zypp2/RepoInfo.h | 60 +++++----------------- zypp2/RepoManager.cc | 11 +++- zypp2/RepoStatus.cc | 23 +++++++++ zypp2/RepoStatus.h | 40 ++++++++++++++- .../memory/{DPackageImpl.cc => PackageImpl.cc} | 2 +- .../repo/memory/{DPackageImpl.h => PackageImpl.h} | 0 .../memory/{DPatternImpl.cc => PatternImpl.cc} | 2 +- .../repo/memory/{DPatternImpl.h => PatternImpl.h} | 0 .../memory/{DProductImpl.cc => ProductImpl.cc} | 2 +- .../repo/memory/{DProductImpl.h => ProductImpl.h} | 0 .../{DSrcPackageImpl.cc => SrcPackageImpl.cc} | 2 +- .../memory/{DSrcPackageImpl.h => SrcPackageImpl.h} | 0 14 files changed, 106 insertions(+), 95 deletions(-) rename zypp2/repo/memory/{DPackageImpl.cc => PackageImpl.cc} (99%) rename zypp2/repo/memory/{DPackageImpl.h => PackageImpl.h} (100%) rename zypp2/repo/memory/{DPatternImpl.cc => PatternImpl.cc} (97%) rename zypp2/repo/memory/{DPatternImpl.h => PatternImpl.h} (100%) rename zypp2/repo/memory/{DProductImpl.cc => ProductImpl.cc} (98%) rename zypp2/repo/memory/{DProductImpl.h => ProductImpl.h} (100%) rename zypp2/repo/memory/{DSrcPackageImpl.cc => SrcPackageImpl.cc} (97%) rename zypp2/repo/memory/{DSrcPackageImpl.h => SrcPackageImpl.h} (100%) diff --git a/zypp2/CMakeLists.txt b/zypp2/CMakeLists.txt index 9caa7e8..c343a85 100644 --- a/zypp2/CMakeLists.txt +++ b/zypp2/CMakeLists.txt @@ -94,17 +94,17 @@ SET( zypp2_repository_cached_HEADERS ) SET( zypp2_repository_data_SRCS - repo/memory/DPackageImpl.cc - repo/memory/DPatternImpl.cc - repo/memory/DProductImpl.cc - repo/memory/DSrcPackageImpl.cc + repo/memory/PackageImpl.cc + repo/memory/PatternImpl.cc + repo/memory/ProductImpl.cc + repo/memory/SrcPackageImpl.cc ) SET( zypp2_repository_data_HEADERS - repo/memory/DPackageImpl.h - repo/memory/DPatternImpl.h - repo/memory/DProductImpl.h - repo/memory/DSrcPackageImpl.h + repo/memory/PackageImpl.h + repo/memory/PatternImpl.h + repo/memory/ProductImpl.h + repo/memory/SrcPackageImpl.h ) SET( zypp2_parser_susetags_SRCS diff --git a/zypp2/RepoInfo.cc b/zypp2/RepoInfo.cc index 1838d65..bc9f1c9 100644 --- a/zypp2/RepoInfo.cc +++ b/zypp2/RepoInfo.cc @@ -37,13 +37,10 @@ namespace zypp boost::tribool enabled; boost::tribool autorefresh; std::string type; - Url baseurl; + Url mirrorlist_url; std::set urls; - Pathname path; std::string alias; std::string name; - CheckSum checksum; - Date timestamp; public: /** Offer default Impl. */ @@ -104,15 +101,15 @@ namespace zypp return *this; } - RepoInfo & RepoInfo::setBaseUrl( const Url &url ) + RepoInfo & RepoInfo::setMirrorListUrl( const Url &url ) { - _pimpl->baseurl = url; + _pimpl->mirrorlist_url = url; return *this; } - RepoInfo & RepoInfo::setPath( const Pathname &p ) + RepoInfo & RepoInfo::addBaseUrl( const Url &url ) { - _pimpl->path = p; + _pimpl->urls.insert(url); return *this; } @@ -134,45 +131,23 @@ namespace zypp return *this; } - RepoInfo & RepoInfo::setChecksum( const CheckSum &checksum ) - { - _pimpl->checksum = checksum; - return *this; - } - - RepoInfo & RepoInfo::setTimestamp( const Date ×tamp ) - { - _pimpl->timestamp = timestamp; - return *this; - } - tribool RepoInfo::enabled() const { return _pimpl->enabled; } tribool RepoInfo::autorefresh() const { return _pimpl->autorefresh; } - - Pathname RepoInfo::path() const - { return _pimpl->path; } - std::string RepoInfo::alias() const { return _pimpl->alias; } std::string RepoInfo::name() const { return _pimpl->name; } - CheckSum RepoInfo::checksum() const - { return _pimpl->checksum; } - - Date RepoInfo::timestamp() const - { return _pimpl->timestamp; } - std::string RepoInfo::type() const { return _pimpl->type; } - Url RepoInfo::baseUrl() const - { return _pimpl->baseurl; } + Url RepoInfo::mirrorListUrl() const + { return _pimpl->mirrorlist_url; } std::set RepoInfo::urls() const { return _pimpl->urls; } @@ -187,11 +162,11 @@ namespace zypp { str << "--------------------------------------" << std::endl; str << "- alias : " << alias() << std::endl; - str << "- url : " << baseUrl() << std::endl; + //str << "- url : " << baseUrl() << std::endl; str << "- type : " << type() << std::endl; str << "- enabled : " << enabled() << std::endl; str << "- autorefresh : " << autorefresh() << std::endl; - str << "- path : " << path() << std::endl; + //str << "- path : " << path() << std::endl; return str; } diff --git a/zypp2/RepoInfo.h b/zypp2/RepoInfo.h index a05eb31..0238c7c 100644 --- a/zypp2/RepoInfo.h +++ b/zypp2/RepoInfo.h @@ -20,8 +20,6 @@ #include #include "zypp/Pathname.h" #include "zypp/Url.h" -#include "zypp/CheckSum.h" -#include "zypp/Date.h" /////////////////////////////////////////////////////////////////// namespace zypp @@ -87,15 +85,16 @@ namespace zypp * the base url is http://updates.novell.com/10.2 * * This can't be empty in order the repository to be valid + * unless the download of the mirror list succeeds and it + * contains a valid url. */ - Url baseUrl() const; + std::set urls() const; /** - * Urls is a list of Urls where this repository - * is located. + * Url of a file which contains a list of Urls * If empty, the base url will be used. */ - std::set urls() const; + Url mirrorListUrl() const; typedef std::set::const_iterator urls_const_iterator; @@ -110,12 +109,6 @@ namespace zypp urls_const_iterator urlsEnd() const; /** - * Path on the url where the repository root - * is located. - */ - Pathname path() const; - - /** * If enabled is false, then this repository must be ignored as if does * not exists, except when checking for duplicate alias. */ @@ -141,27 +134,18 @@ namespace zypp * ie: "SUSE Linux 10.2 updates" */ std::string name() const; - - /** - * Checksum of the repository. - * Usually the checksum of the index, but any - * checksum that changes when the repository changes - * in any way is sufficient. - */ - CheckSum checksum() const; - + /** - * timestamp of the repository. If the repository - * changes, it has to be updated as well with the - * new timestamp. + * Add a base url. \see baseUrl + * \param url The base url for the repository. */ - Date timestamp() const; + RepoInfo & addBaseUrl( const Url &url ); /** - * Set the base url. \see baseUrl - * \param url The base url for the repository. + * Set mirror list url. \see mirrorListUrl + * \param url The base url for the list */ - RepoInfo & setBaseUrl( const Url &url ); + RepoInfo & setMirrorListUrl( const Url &url ); /** * enable or disable the repository \see enabled @@ -176,12 +160,6 @@ namespace zypp RepoInfo & setAutorefresh( boost::tribool autorefresh ); /** - * set the repository path \see path - * \param p - */ - RepoInfo & setPath( const Pathname &p ); - - /** * set the repository alias \see alias * \param alias */ @@ -198,19 +176,7 @@ namespace zypp * \param name */ RepoInfo & setName( const std::string &name ); - - /** - * set the repository checksum \see checksum - * \param checksum - */ - RepoInfo & setChecksum( const CheckSum &checksum ); - - /** - * set the repository timestamp \see timestamp - * \param timestamp - */ - RepoInfo & setTimestamp( const Date ×tamp ); - + std::ostream & dumpOn( std::ostream & str ) const; class Impl; diff --git a/zypp2/RepoManager.cc b/zypp2/RepoManager.cc index 40d2645..ea8e657 100644 --- a/zypp2/RepoManager.cc +++ b/zypp2/RepoManager.cc @@ -37,14 +37,23 @@ static std::list repositories_in_file( const Pathname &file ) MIL << (*its) << endl; RepoInfo info; - + info.setAlias(*its); + for ( IniDict::entry_const_iterator it = dict.entriesBegin(*its); it != dict.entriesEnd(*its); ++it ) { MIL << (*it).first << endl; + if (it->first == "name" ) + info.setName(it-> second); + else if ( it->first == "enabled" ) + info.setEnabled( it->second == "1" ); + else if ( it->first == "baseurl" ) + info.addBaseUrl( Url(it->second) ); } + + // add it to the list. } // dictionary *d = iniparser_new(file.c_str()); diff --git a/zypp2/RepoStatus.cc b/zypp2/RepoStatus.cc index e0d16aa..a0ddc50 100644 --- a/zypp2/RepoStatus.cc +++ b/zypp2/RepoStatus.cc @@ -13,6 +13,7 @@ //#include "zypp/base/Logger.h" #include "zypp2/RepoStatus.h" + using std::endl; /////////////////////////////////////////////////////////////////// @@ -28,6 +29,10 @@ namespace zypp { public: + + CheckSum checksum; + Date timestamp; + /** Offer default Impl. */ static shared_ptr nullimpl() { @@ -72,6 +77,24 @@ namespace zypp RepoStatus::~RepoStatus() {} + RepoStatus & RepoStatus::setChecksum( const CheckSum &checksum ) + { + _pimpl->checksum = checksum; + return *this; + } + + RepoStatus & RepoStatus::setTimestamp( const Date ×tamp ) + { + _pimpl->timestamp = timestamp; + return *this; + } + + CheckSum RepoStatus::checksum() const + { return _pimpl->checksum; } + + Date RepoStatus::timestamp() const + { return _pimpl->timestamp; } + /****************************************************************** ** ** FUNCTION NAME : operator<< diff --git a/zypp2/RepoStatus.h b/zypp2/RepoStatus.h index d3b8598..a6221c3 100644 --- a/zypp2/RepoStatus.h +++ b/zypp2/RepoStatus.h @@ -14,6 +14,8 @@ #include #include "zypp/base/PtrTypes.h" +#include "zypp/CheckSum.h" +#include "zypp/Date.h" /////////////////////////////////////////////////////////////////// namespace zypp @@ -23,12 +25,48 @@ namespace zypp // // CLASS NAME : RepoStatus // - /** */ + /** + * \short Local facts about a repository + * This class represents the status of a + * repository on the system. + * + * Anything that is not provided on the metadata + * files, like the timestamp of the downloaded + * metadata, and its checksum. + */ class RepoStatus { friend std::ostream & operator<<( std::ostream & str, const RepoStatus & obj ); public: + + /** + * Checksum of the repository. + * Usually the checksum of the index, but any + * checksum that changes when the repository changes + * in any way is sufficient. + */ + CheckSum checksum() const; + + /** + * timestamp of the repository. If the repository + * changes, it has to be updated as well with the + * new timestamp. + */ + Date timestamp() const; + + /** + * set the repository checksum \see checksum + * \param checksum + */ + RepoStatus & setChecksum( const CheckSum &checksum ); + + /** + * set the repository timestamp \see timestamp + * \param timestamp + */ + RepoStatus & setTimestamp( const Date ×tamp ); + /** Implementation */ class Impl; diff --git a/zypp2/repo/memory/DPackageImpl.cc b/zypp2/repo/memory/PackageImpl.cc similarity index 99% rename from zypp2/repo/memory/DPackageImpl.cc rename to zypp2/repo/memory/PackageImpl.cc index 98cb87d..4375f73 100644 --- a/zypp2/repo/memory/DPackageImpl.cc +++ b/zypp2/repo/memory/PackageImpl.cc @@ -10,7 +10,7 @@ * */ -#include "zypp2/repo/memory/DPackageImpl.h" +#include "zypp2/repo/memory/PackageImpl.h" using namespace std; diff --git a/zypp2/repo/memory/DPackageImpl.h b/zypp2/repo/memory/PackageImpl.h similarity index 100% rename from zypp2/repo/memory/DPackageImpl.h rename to zypp2/repo/memory/PackageImpl.h diff --git a/zypp2/repo/memory/DPatternImpl.cc b/zypp2/repo/memory/PatternImpl.cc similarity index 97% rename from zypp2/repo/memory/DPatternImpl.cc rename to zypp2/repo/memory/PatternImpl.cc index c686ec4..ce4cd54 100644 --- a/zypp2/repo/memory/DPatternImpl.cc +++ b/zypp2/repo/memory/PatternImpl.cc @@ -9,7 +9,7 @@ /** \file zypp2/repository/memory/PatternImpl.cc * */ -#include "zypp2/repo/memory/DPatternImpl.h" +#include "zypp2/repo/memory/PatternImpl.h" using namespace std; diff --git a/zypp2/repo/memory/DPatternImpl.h b/zypp2/repo/memory/PatternImpl.h similarity index 100% rename from zypp2/repo/memory/DPatternImpl.h rename to zypp2/repo/memory/PatternImpl.h diff --git a/zypp2/repo/memory/DProductImpl.cc b/zypp2/repo/memory/ProductImpl.cc similarity index 98% rename from zypp2/repo/memory/DProductImpl.cc rename to zypp2/repo/memory/ProductImpl.cc index 395ef06..d59849f 100644 --- a/zypp2/repo/memory/DProductImpl.cc +++ b/zypp2/repo/memory/ProductImpl.cc @@ -9,7 +9,7 @@ /** \file zypp2/repo/memory/ProductImpl.cc * */ -#include "zypp2/repo/memory/DProductImpl.h" +#include "zypp2/repo/memory/ProductImpl.h" using namespace std; diff --git a/zypp2/repo/memory/DProductImpl.h b/zypp2/repo/memory/ProductImpl.h similarity index 100% rename from zypp2/repo/memory/DProductImpl.h rename to zypp2/repo/memory/ProductImpl.h diff --git a/zypp2/repo/memory/DSrcPackageImpl.cc b/zypp2/repo/memory/SrcPackageImpl.cc similarity index 97% rename from zypp2/repo/memory/DSrcPackageImpl.cc rename to zypp2/repo/memory/SrcPackageImpl.cc index afbbb04..8d90d8b 100644 --- a/zypp2/repo/memory/DSrcPackageImpl.cc +++ b/zypp2/repo/memory/SrcPackageImpl.cc @@ -9,7 +9,7 @@ /** \file zypp2/repo/memory/SrcPackageImpl.cc * */ -#include "zypp2/repo/memory/DSrcPackageImpl.h" +#include "zypp2/repo/memory/SrcPackageImpl.h" using namespace std; diff --git a/zypp2/repo/memory/DSrcPackageImpl.h b/zypp2/repo/memory/SrcPackageImpl.h similarity index 100% rename from zypp2/repo/memory/DSrcPackageImpl.h rename to zypp2/repo/memory/SrcPackageImpl.h -- 2.7.4