From 00540a7281334c4303d05cf3a78cd78f1e8c884f Mon Sep 17 00:00:00 2001 From: Michael Andres Date: Wed, 9 Jul 2014 11:11:32 +0200 Subject: [PATCH] remove superfluous base classes in RepoInfo/ServiceInfo::Impl --- zypp/CMakeLists.txt | 1 - zypp/RepoInfo.cc | 8 +-- zypp/ServiceInfo.cc | 10 ++-- zypp/repo/RepoInfoBase.cc | 120 ++++++++++++++++++------------------------- zypp/repo/RepoInfoBaseImpl.h | 72 -------------------------- 5 files changed, 58 insertions(+), 153 deletions(-) delete mode 100644 zypp/repo/RepoInfoBaseImpl.h diff --git a/zypp/CMakeLists.txt b/zypp/CMakeLists.txt index fd6dfcd..c8474fd 100644 --- a/zypp/CMakeLists.txt +++ b/zypp/CMakeLists.txt @@ -756,7 +756,6 @@ SET( zypp_repo_HEADERS repo/Downloader.h repo/RepoVariables.h repo/RepoInfoBase.h - repo/RepoInfoBaseImpl.h repo/PluginServices.h repo/ServiceRepos.h ) diff --git a/zypp/RepoInfo.cc b/zypp/RepoInfo.cc index 470da71..5d820da 100644 --- a/zypp/RepoInfo.cc +++ b/zypp/RepoInfo.cc @@ -17,7 +17,8 @@ #include "zypp/parser/xml/XmlEscape.h" #include "zypp/RepoInfo.h" -#include "zypp/repo/RepoInfoBaseImpl.h" +#include "zypp/TriBool.h" +#include "zypp/Pathname.h" #include "zypp/repo/RepoMirrorList.h" #include "zypp/ExternalProgram.h" #include "zypp/media/MediaAccess.h" @@ -34,11 +35,10 @@ namespace zypp // CLASS NAME : RepoInfo::Impl // /** RepoInfo implementation. */ - struct RepoInfo::Impl : public repo::RepoInfoBase::Impl + struct RepoInfo::Impl { Impl() - : repo::RepoInfoBase::Impl() - , gpgcheck(indeterminate) + : gpgcheck(indeterminate) , keeppackages(indeterminate) , type(repo::RepoType::NONE_e) , emptybaseurls(false) diff --git a/zypp/ServiceInfo.cc b/zypp/ServiceInfo.cc index 11220d3..470396c 100644 --- a/zypp/ServiceInfo.cc +++ b/zypp/ServiceInfo.cc @@ -16,8 +16,6 @@ #include "zypp/parser/xml/XmlEscape.h" #include "zypp/RepoInfo.h" -#include "zypp/repo/RepoInfoBaseImpl.h" - #include "zypp/ServiceInfo.h" using namespace std; @@ -31,7 +29,7 @@ namespace zypp // // CLASS NAME : ServiceInfo::Impl // - struct ServiceInfo::Impl : public repo::RepoInfoBase::Impl + struct ServiceInfo::Impl { typedef ServiceInfo::ReposToEnable ReposToEnable; typedef ServiceInfo::ReposToDisable ReposToDisable; @@ -46,13 +44,11 @@ namespace zypp public: Impl() - : repo::RepoInfoBase::Impl() - , type(repo::ServiceType::NONE_e) + : type(repo::ServiceType::NONE_e) {} Impl(const Url & url_) - : repo::RepoInfoBase::Impl() - , url(url_) + : url(url_) , type(repo::ServiceType::NONE_e) {} diff --git a/zypp/repo/RepoInfoBase.cc b/zypp/repo/RepoInfoBase.cc index d0ac421..367a836 100644 --- a/zypp/repo/RepoInfoBase.cc +++ b/zypp/repo/RepoInfoBase.cc @@ -15,44 +15,58 @@ #include "zypp/repo/RepoVariables.h" #include "zypp/repo/RepoInfoBase.h" -#include "zypp/repo/RepoInfoBaseImpl.h" +#include "zypp/TriBool.h" +#include "zypp/Pathname.h" using namespace std; /////////////////////////////////////////////////////////////////// namespace zypp -{ ///////////////////////////////////////////////////////////////// +{ /////////////////////////////////////////////////////////////////// namespace repo - { ///////////////////////////////////////////////////////////////// + { /////////////////////////////////////////////////////////////////// - // - // CLASS NAME : RepoInfoBase::Impl - // + /// \class RepoInfoBase::Impl + /// \brief RepoInfoBase data /////////////////////////////////////////////////////////////////// - - /** \relates RepoInfo::Impl Stream output */ - inline std::ostream & operator<<( std::ostream & str, const RepoInfoBase::Impl & obj ) + struct RepoInfoBase::Impl { - return str << "RepoInfo::Impl"; - } - - void RepoInfoBase::Impl::setAlias(const string & alias_) - { - this->alias = alias_; - // replace slashes with underscores - std::string fnd="/"; - std::string rep="_"; - std::string escaped_alias = alias_; - size_t pos = escaped_alias.find(fnd); - while (pos != string::npos) + Impl() + : _enabled( indeterminate ) + , _autorefresh( indeterminate ) + {} + + Impl( const std::string & alias_r ) + : _enabled( indeterminate ) + , _autorefresh( indeterminate ) + { setAlias( alias_r ); } + + public: + TriBool _enabled; + TriBool _autorefresh; + std::string _alias; + std::string _escaped_alias; + std::string _name; + Pathname _filepath; + + public: + + void setAlias( const std::string & alias_r ) { - escaped_alias.replace(pos, fnd.length(), rep); - pos = escaped_alias.find(fnd, pos+rep.length()); + _alias = _escaped_alias = alias_r; + // replace slashes with underscores + str::replaceAll( _escaped_alias, "/", "_" ); } - this->escaped_alias = escaped_alias; - } + + private: + friend Impl * rwcowClone( const Impl * rhs ); + /** clone for RWCOW_pointer */ + Impl * clone() const + { return new Impl( *this ); } + }; + /////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////// // @@ -60,80 +74,51 @@ namespace zypp // /////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////// - // - // METHOD NAME : RepoInfoBase::RepoInfoBase - // METHOD TYPE : Ctor - // RepoInfoBase::RepoInfoBase() : _pimpl( new Impl() ) {} - /////////////////////////////////////////////////////////////////// - // - // METHOD NAME : RepoInfoBase::RepoInfoBase - // METHOD TYPE : Ctor - // RepoInfoBase::RepoInfoBase(const string & alias) : _pimpl( new Impl(alias) ) {} - /////////////////////////////////////////////////////////////////// - // - // METHOD NAME : RepoInfoBase::~RepoInfoBase - // METHOD TYPE : Dtor - // RepoInfoBase::~RepoInfoBase() {} void RepoInfoBase::setEnabled( bool enabled ) - { - _pimpl->enabled = enabled; - } + { _pimpl->_enabled = enabled; } void RepoInfoBase::setAutorefresh( bool autorefresh ) - { - _pimpl->autorefresh = autorefresh; - } + { _pimpl->_autorefresh = autorefresh; } void RepoInfoBase::setAlias( const std::string &alias ) - { - _pimpl->setAlias(alias); - } + { _pimpl->setAlias(alias); } void RepoInfoBase::setName( const std::string &name ) - { - _pimpl->name = name; - } + { _pimpl->_name = name; } void RepoInfoBase::setFilepath( const Pathname &filepath ) - { - _pimpl->filepath = filepath; - } + { _pimpl->_filepath = filepath; } // true by default (if not set by setEnabled()) bool RepoInfoBase::enabled() const - { return indeterminate(_pimpl->enabled) ? true : (bool) _pimpl->enabled; } + { return indeterminate(_pimpl->_enabled) ? true : (bool) _pimpl->_enabled; } // false by default (if not set by setAutorefresh()) bool RepoInfoBase::autorefresh() const - { return indeterminate(_pimpl->autorefresh) ? false : (bool) _pimpl->autorefresh; } + { return indeterminate(_pimpl->_autorefresh) ? false : (bool) _pimpl->_autorefresh; } std::string RepoInfoBase::alias() const - { return _pimpl->alias; } + { return _pimpl->_alias; } std::string RepoInfoBase::escaped_alias() const - { return _pimpl->escaped_alias; } + { return _pimpl->_escaped_alias; } std::string RepoInfoBase::name() const { - if ( _pimpl->name.empty() ) - { + if ( _pimpl->_name.empty() ) return alias(); - } - - repo::RepoVariablesStringReplacer replacer; - return replacer(_pimpl->name); + return repo::RepoVariablesStringReplacer()( _pimpl->_name ); } std::string RepoInfoBase::label() const @@ -144,7 +129,7 @@ namespace zypp } Pathname RepoInfoBase::filepath() const - { return _pimpl->filepath; } + { return _pimpl->_filepath; } std::ostream & RepoInfoBase::dumpOn( std::ostream & str ) const @@ -178,11 +163,8 @@ namespace zypp { return obj.dumpOn(str); } - /////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////// } // namespace repo /////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////// } // namespace zypp /////////////////////////////////////////////////////////////////// diff --git a/zypp/repo/RepoInfoBaseImpl.h b/zypp/repo/RepoInfoBaseImpl.h deleted file mode 100644 index 7d0592e..0000000 --- a/zypp/repo/RepoInfoBaseImpl.h +++ /dev/null @@ -1,72 +0,0 @@ -/*---------------------------------------------------------------------\ -| ____ _ __ __ ___ | -| |__ / \ / / . \ . \ | -| / / \ V /| _/ _/ | -| / /__ | | | | | | | -| /_____||_| |_| |_| | -| | -\---------------------------------------------------------------------*/ -/** \file zypp/repo/RepoInfoBaseImpl.h - * - */ -#ifndef REPOINFOBASEIMPL_H_ -#define REPOINFOBASEIMPL_H_ - -#include - -#include "zypp/TriBool.h" -#include "zypp/Pathname.h" - -/////////////////////////////////////////////////////////////////// -namespace zypp -{ ///////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////// - namespace repo - { ///////////////////////////////////////////////////////////////// - - /////////////////////////////////////////////////////////////////// - // - // CLASS NAME : RepoInfoBase::Impl - // - struct RepoInfoBase::Impl - { - Impl() - : enabled (indeterminate) - , autorefresh (indeterminate) - {} - - Impl(const std::string & alias_) - : enabled(indeterminate) - , autorefresh(indeterminate) - { setAlias(alias_); } - - ~Impl() - {} - - public: - TriBool enabled; - TriBool autorefresh; - std::string alias; - std::string escaped_alias; - std::string name; - Pathname filepath; - public: - - void setAlias(const std::string & alias_); - - private: - friend Impl * rwcowClone( const Impl * rhs ); - /** clone for RWCOW_pointer */ - Impl * clone() const - { return new Impl( *this ); } - }; - /////////////////////////////////////////////////////////////////// - - ///////////////////////////////////////////////////////////////// - } // namespace repo - /////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////// -} // namespace zypp -/////////////////////////////////////////////////////////////////// - -#endif /*REPOINFOBASEIMPL_H_*/ -- 2.7.4