added group (selection) objects
authorJiri Srain <jsrain@suse.cz>
Wed, 30 Nov 2005 13:27:52 +0000 (13:27 +0000)
committerJiri Srain <jsrain@suse.cz>
Wed, 30 Nov 2005 13:27:52 +0000 (13:27 +0000)
zypp/source/yum/Makefile.am
zypp/source/yum/YUMGroupImpl.cc [new file with mode: 0644]
zypp/source/yum/YUMGroupImpl.h [new file with mode: 0644]
zypp/source/yum/YUMSource.cc
zypp/source/yum/YUMSource.h

index a0dbd71..84628fc 100644 (file)
@@ -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 (file)
index 0000000..f61298b
--- /dev/null
@@ -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<PackageReq>::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<MetaPkg>::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<multilang> name;
+// _description
+      }
+      /** Is to be visible for user? */
+      bool YUMGroupImpl::userVisible() const {
+       return _user_visible;
+      }
+
+      std::list<YUMGroupImpl::GroupReq> YUMGroupImpl::groupsReq() const
+      { return _groups_req; }
+
+      std::list<YUMGroupImpl::PkgReq> 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 (file)
index 0000000..8e7d8c9
--- /dev/null
@@ -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<GroupReq> groupsReq() const;
+       /** Requested packages */
+       virtual std::list<PkgReq> 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<GroupReq> _groups_req;
+       std::list<PkgReq> _pkgs_req;
+      };
+      ///////////////////////////////////////////////////////////////////
+    } // namespace yum
+    /////////////////////////////////////////////////////////////////
+  } // namespace source
+  ///////////////////////////////////////////////////////////////////
+  /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP_SOURCE_YUM_YUMGROUPIMPL_H
index e2118a5..4f9f946 100644 (file)
@@ -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<YUMGroupImpl> 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
        )
index 8993bdd..2dd2615 100644 (file)
@@ -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
        );