From 3b15a4905732d71539c2814e7dede51dbb3f9bf6 Mon Sep 17 00:00:00 2001 From: Michael Andres Date: Thu, 11 Sep 2008 15:01:48 +0000 Subject: [PATCH] add catalogsToDisable to service --- devel/devel.ma/NewPool.cc | 23 +++++++++++------------ zypp/ServiceInfo.cc | 30 ++++++++++++++++++++++++++++-- zypp/ServiceInfo.h | 24 +++++++++++++++++++++++- 3 files changed, 62 insertions(+), 15 deletions(-) diff --git a/devel/devel.ma/NewPool.cc b/devel/devel.ma/NewPool.cc index b20a8d5..0cebe04 100644 --- a/devel/devel.ma/NewPool.cc +++ b/devel/devel.ma/NewPool.cc @@ -430,16 +430,6 @@ void testCMP( const L & lhs, const R & rhs ) #undef OUTS } -namespace zypp -{ - enum TestE { - TE1, TE2, TE3 - }; - - inline void fromString( const std::string & str_r, TestE & cl_r ) - { cl_r = TE1; } - -} /****************************************************************** ** @@ -454,11 +444,20 @@ try { INT << "===[START]==========================================" << endl; ZConfig::instance(); +#if 0 + ServiceInfo s( "STest", Url("dir:///somewhere") ); + DBG << s << endl; + s.addCatalogToEnable( "foo" ); + s.addCatalogToEnable( "ba a" ); + s.addCatalogToEnable( "kaa" ); + + RepoManager repoManager( makeRepoManager( sysRoot ) ); + RepoInfoList repos = repoManager.knownRepositories(); + RepoInfoList services = repoManager.knownServices(); -#if 1 - DBG << str::fromString("te1") << endl; + DBG << s << endl; /////////////////////////////////////////////////////////////////// INT << "===[END]============================================" << endl << endl; diff --git a/zypp/ServiceInfo.cc b/zypp/ServiceInfo.cc index 6438006..1d5cb47 100644 --- a/zypp/ServiceInfo.cc +++ b/zypp/ServiceInfo.cc @@ -46,10 +46,12 @@ namespace zypp struct ServiceInfo::Impl : public repo::RepoInfoBase::Impl { typedef ServiceInfo::CatalogsToEnable CatalogsToEnable; + typedef ServiceInfo::CatalogsToDisable CatalogsToDisable; public: Url url; - CatalogsToEnable catalogsToEnable; + CatalogsToEnable catalogsToEnable; + CatalogsToDisable catalogsToDisable; public: Impl() : repo::RepoInfoBase::Impl() {} @@ -110,11 +112,35 @@ namespace zypp { _pimpl->catalogsToEnable.erase( alias_r ); } + bool ServiceInfo::catalogsToDisableEmpty() const + { return _pimpl->catalogsToDisable.empty(); } + + ServiceInfo::CatalogsToDisable::size_type ServiceInfo::catalogsToDisableSize() const + { return _pimpl->catalogsToDisable.size(); } + + ServiceInfo::CatalogsToDisable::const_iterator ServiceInfo::catalogsToDisableBegin() const + { return _pimpl->catalogsToDisable.begin(); } + + ServiceInfo::CatalogsToDisable::const_iterator ServiceInfo::catalogsToDisableEnd() const + { return _pimpl->catalogsToDisable.end(); } + + bool ServiceInfo::catalogToDisableFind( const std::string & alias_r ) const + { return( _pimpl->catalogsToDisable.find( alias_r ) != _pimpl->catalogsToDisable.end() ); } + + void ServiceInfo::addCatalogToDisable( const std::string & alias_r ) + { _pimpl->catalogsToDisable.insert( alias_r ); } + + void ServiceInfo::delCatalogToDisable( const std::string & alias_r ) + { _pimpl->catalogsToDisable.erase( alias_r ); } + + std::ostream & ServiceInfo::dumpAsIniOn( std::ostream & str ) const { RepoInfoBase::dumpAsIniOn(str) << "url = " << url() << endl; if ( ! catalogsToEnableEmpty() ) str << "catalogstoenable = " << str::joinEscaped( catalogsToEnableBegin(), catalogsToEnableEnd() ) << endl; + if ( ! catalogsToDisableEmpty() ) + str << "catalogstodisable = " << str::joinEscaped( catalogsToDisableBegin(), catalogsToDisableEnd() ) << endl; return str; } @@ -130,7 +156,7 @@ namespace zypp << " enabled=\"" << enabled() << "\"" << " autorefresh=\"" << autorefresh() << "\"" << " url=\"" << escape(url().asString()) << "\""; - + if (content.empty()) str << "/>" << endl; else diff --git a/zypp/ServiceInfo.h b/zypp/ServiceInfo.h index e4a27ff..ba40818 100644 --- a/zypp/ServiceInfo.h +++ b/zypp/ServiceInfo.h @@ -94,6 +94,28 @@ namespace zypp void delCatalogToEnable( const std::string & alias_r ); //@} + /** \name Set of catalogs (repository aliases) to disable on next refresh. + * + * Repositories mentioned here will be disabled on the next refresh, in case they + * still exist. Afterwards they get removed from the list. + */ + //@{ + /** Container of catalogs. */ + typedef std::set CatalogsToDisable; + bool catalogsToDisableEmpty() const; + CatalogsToDisable::size_type catalogsToDisableSize() const; + CatalogsToDisable::const_iterator catalogsToDisableBegin() const; + CatalogsToDisable::const_iterator catalogsToDisableEnd() const; + + /** Wheter \c alias_r is mentioned in CatalogsToDisable. */ + bool catalogToDisableFind( const std::string & alias_r ) const; + + /** Add \c alias_r to the set of CatalogsToDisable. */ + void addCatalogToDisable( const std::string & alias_r ); + /** Remove \c alias_r to the set of CatalogsToDisable. */ + void delCatalogToDisable( const std::string & alias_r ); + //@} + public: /** * Writes ServiceInfo to stream in ".service" format @@ -109,7 +131,7 @@ namespace zypp /** * Write an XML representation of this ServiceInfo object. - * + * * \param str * \param content if not empty, produces content * otherwise -- 2.7.4