From b75bba9b981c951f4ce57380749eb2158334c125 Mon Sep 17 00:00:00 2001 From: Jiri Srain Date: Wed, 30 Nov 2005 13:27:52 +0000 Subject: [PATCH] added group (selection) objects --- zypp/source/yum/Makefile.am | 2 + zypp/source/yum/YUMGroupImpl.cc | 101 +++++++++++++++++++++++++++++++++++++ zypp/source/yum/YUMGroupImpl.h | 109 ++++++++++++++++++++++++++++++++++++++++ zypp/source/yum/YUMSource.cc | 23 +++++++++ zypp/source/yum/YUMSource.h | 4 ++ 5 files changed, 239 insertions(+) create mode 100644 zypp/source/yum/YUMGroupImpl.cc create mode 100644 zypp/source/yum/YUMGroupImpl.h diff --git a/zypp/source/yum/Makefile.am b/zypp/source/yum/Makefile.am index a0dbd71..84628fc 100644 --- a/zypp/source/yum/Makefile.am +++ b/zypp/source/yum/Makefile.am @@ -11,6 +11,7 @@ include_HEADERS = \ YUMMessageImpl.h \ YUMPackageImpl.h \ YUMPatchImpl.h \ + YUMGroupImpl.h \ YUMProductImpl.h @@ -24,6 +25,7 @@ lib@PACKAGE@_source_yum_la_SOURCES = \ YUMMessageImpl.cc \ YUMPackageImpl.cc \ YUMPatchImpl.cc \ + YUMGroupImpl.cc \ YUMProductImpl.cc ## ################################################## diff --git a/zypp/source/yum/YUMGroupImpl.cc b/zypp/source/yum/YUMGroupImpl.cc new file mode 100644 index 0000000..f61298b --- /dev/null +++ b/zypp/source/yum/YUMGroupImpl.cc @@ -0,0 +1,101 @@ +/*---------------------------------------------------------------------\ +| ____ _ __ __ ___ | +| |__ / \ / / . \ . \ | +| / / \ V /| _/ _/ | +| / /__ | | | | | | | +| /_____||_| |_| |_| | +| | +\---------------------------------------------------------------------*/ +/** \file zypp/source/yum/YUMGroupImpl.cc + * +*/ + +#include "zypp/source/yum/YUMGroupImpl.h" + +using namespace std; +using namespace zypp::detail; +using namespace zypp::parser::yum; + +/////////////////////////////////////////////////////////////////// +namespace zypp +{ ///////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////// + namespace source + { ///////////////////////////////////////////////////////////////// + namespace yum + { + /////////////////////////////////////////////////////////////////// + // + // CLASS NAME : YUMGroupImpl + // + /////////////////////////////////////////////////////////////////// + + /** Default ctor + */ + YUMGroupImpl::YUMGroupImpl( + const zypp::parser::yum::YUMGroupData & parsed + ) + : _user_visible(parsed.userVisible == "true") + { + for (std::list::const_iterator it + = parsed.packageList.begin(); + it != parsed.packageList.end(); + it++) + { + _pkgs_req.push_back(PkgReq(it->type, it->name, it->ver, + it->rel, it->epoch)); + } + for (std::list::const_iterator it + = parsed.grouplist.begin(); + it != parsed.grouplist.end(); + it++) + { + _groups_req.push_back(GroupReq(it->type, it->name)); + } +// to name std::string groupId; +// as _summary std::list name; +// _description + } + /** Is to be visible for user? */ + bool YUMGroupImpl::userVisible() const { + return _user_visible; + } + + std::list YUMGroupImpl::groupsReq() const + { return _groups_req; } + + std::list YUMGroupImpl::pkgsReq() const + { return _pkgs_req; } + + Label YUMGroupImpl::summary() const + { return ResObjectImplIf::summary(); } + + Text YUMGroupImpl::description() const + { return ResObjectImplIf::description(); } + + Text YUMGroupImpl::insnotify() const + { return ResObjectImplIf::insnotify(); } + + Text YUMGroupImpl::delnotify() const + { return ResObjectImplIf::delnotify(); } + + bool YUMGroupImpl::providesSources() const + { return ResObjectImplIf::providesSources(); } + + Label YUMGroupImpl::instSrcLabel() const + { return ResObjectImplIf::instSrcLabel(); } + + Vendor YUMGroupImpl::instSrcVendor() const + { return ResObjectImplIf::instSrcVendor(); } + + FSize YUMGroupImpl::size() const + { return ResObjectImplIf::size(); } + + + } // namespace yum + ///////////////////////////////////////////////////////////////// + } // namespace source + /////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////// +} // namespace zypp +/////////////////////////////////////////////////////////////////// diff --git a/zypp/source/yum/YUMGroupImpl.h b/zypp/source/yum/YUMGroupImpl.h new file mode 100644 index 0000000..8e7d8c9 --- /dev/null +++ b/zypp/source/yum/YUMGroupImpl.h @@ -0,0 +1,109 @@ +/*---------------------------------------------------------------------\ +| ____ _ __ __ ___ | +| |__ / \ / / . \ . \ | +| / / \ V /| _/ _/ | +| / /__ | | | | | | | +| /_____||_| |_| |_| | +| | +\---------------------------------------------------------------------*/ +/** \file zypp/source/yum/YUMGroupImpl.h + * +*/ +#ifndef ZYPP_SOURCE_YUM_YUMGROUPIMPL_H +#define ZYPP_SOURCE_YUM_YUMGROUPIMPL_H + +#include "zypp/detail/SelectionImplIf.h" +#include "zypp/parser/yum/YUMParserData.h" +#include "zypp/Edition.h" + +/////////////////////////////////////////////////////////////////// +namespace zypp +{ ///////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////// + namespace source + { ///////////////////////////////////////////////////////////////// + namespace yum + { ////////////////////////////////////////////////////////////// + + /////////////////////////////////////////////////////////////////// + // + // CLASS NAME : YUMGroupImpl + // + /** Class representing a message + */ + class YUMGroupImpl : public detail::SelectionImplIf + { + public: + class GroupReq + { + public: + GroupReq(const std::string & type, const std::string & name) + : _type(type) + , _name(name) + {} + std::string type() const { return _type; } + std::string name() const { return _name; } + private: + std::string _type; + std::string _name; + }; + class PkgReq + { + public: + PkgReq(const std::string & type, const std::string & name, + const std::string & ver, const std::string & rel, + const std::string & epoch) + : _type(type) + , _name(name) + , _edition(ver, rel, epoch) + {} + std::string type() const { return _type; } + std::string name() const { return _name; } + Edition edition() const { return _edition; } + private: + std::string _type; + std::string _name; + Edition _edition; + }; + /** Default ctor */ + YUMGroupImpl( const zypp::parser::yum::YUMGroupData & parsed ); + /** Is to be visible for user? */ + virtual bool userVisible() const; + /** Other requested groups */ + virtual std::list groupsReq() const; + /** Requested packages */ + virtual std::list pkgsReq() const; + /** */ + virtual Label summary() const; + /** */ + virtual Text description() const; + /** */ + virtual Text insnotify() const; + /** */ + virtual Text delnotify() const; + /** */ + virtual bool providesSources() const; + /** */ + virtual Label instSrcLabel() const; + /** */ + virtual Vendor instSrcVendor() const; + /** */ + virtual FSize size() const; + + + protected: +// _summary +// _description; + bool _user_visible; + std::list _groups_req; + std::list _pkgs_req; + }; + /////////////////////////////////////////////////////////////////// + } // namespace yum + ///////////////////////////////////////////////////////////////// + } // namespace source + /////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////// +} // namespace zypp +/////////////////////////////////////////////////////////////////// +#endif // ZYPP_SOURCE_YUM_YUMGROUPIMPL_H diff --git a/zypp/source/yum/YUMSource.cc b/zypp/source/yum/YUMSource.cc index e2118a5..4f9f946 100644 --- a/zypp/source/yum/YUMSource.cc +++ b/zypp/source/yum/YUMSource.cc @@ -16,6 +16,7 @@ #include "zypp/source/yum/YUMMessageImpl.h" #include "zypp/source/yum/YUMPatchImpl.h" #include "zypp/source/yum/YUMProductImpl.h" +#include "zypp/source/yum/YUMGroupImpl.h" #include "zypp/base/Logger.h" #include "zypp/CapFactory.h" @@ -97,6 +98,28 @@ namespace zypp } } + Selection::Ptr createGroup( + const zypp::parser::yum::YUMGroupData & parsed + ) + { + try + { + shared_ptr impl(new YUMGroupImpl(parsed)); + Selection::Ptr group = detail::makeResolvableFromImpl( + parsed.groupId, + Edition::noedition, + Arch_noarch, + impl + ); + return group; + } + catch (const Exception & excpt_r) + { + ERR << excpt_r << endl; + throw "Cannot create package group object"; + } + } + Message::Ptr YUMSource::createMessage( const zypp::parser::yum::YUMPatchMessage & parsed ) diff --git a/zypp/source/yum/YUMSource.h b/zypp/source/yum/YUMSource.h index 8993bdd..2dd2615 100644 --- a/zypp/source/yum/YUMSource.h +++ b/zypp/source/yum/YUMSource.h @@ -19,6 +19,7 @@ #include "zypp/Script.h" #include "zypp/Patch.h" #include "zypp/Product.h" +#include "zypp/Selection.h" using namespace zypp::parser::yum; @@ -51,6 +52,9 @@ namespace zypp Package::Ptr createPackage( const zypp::parser::yum::YUMPatchPackage & parsed ); + Selection::Ptr createGroup( + const zypp::parser::yum::YUMGroupData & parsed + ); Message::Ptr createMessage( const zypp::parser::yum::YUMPatchMessage & parsed ); -- 2.7.4