- remove "suggests()" and "recommends()" from Selection, these UI helpers are not...
authorKlaus Kaempf <kkaempf@suse.de>
Tue, 14 Feb 2006 12:34:36 +0000 (12:34 +0000)
committerKlaus Kaempf <kkaempf@suse.de>
Tue, 14 Feb 2006 12:34:36 +0000 (12:34 +0000)
  adapt target/store/serialize.cc accordingly

- implement "install_packages()" for Selection and Pattern

zypp/Pattern.cc
zypp/Pattern.h
zypp/Selection.cc
zypp/Selection.h
zypp/detail/PatternImplIf.cc
zypp/detail/PatternImplIf.h
zypp/detail/SelectionImplIf.cc
zypp/detail/SelectionImplIf.h
zypp/target/store/serialize.cc

index 25f093e..646e03d 100644 (file)
@@ -59,6 +59,10 @@ namespace zypp
   Pathname Pattern::script() const
   { return pimpl().script(); }
 
+  std::set<std::string> Pattern::install_packages( const Locale & lang ) const
+  {
+     return pimpl().install_packages();
+  }
 
   /////////////////////////////////////////////////////////////////
 } // namespace zypp
index bd151a7..2a5fd0f 100644 (file)
@@ -49,7 +49,8 @@ namespace zypp
     /** */
     Pathname script() const;
     /** */
-    // data here:
+
+    std::set<std::string> install_packages( const Locale & lang = Locale("") ) const;
 
   protected:
     /** Ctor */
index ba284eb..9b5abd6 100644 (file)
@@ -75,17 +75,7 @@ namespace zypp
        return pimpl().order();    
     }
 
-    std::set<std::string> Selection::suggests() const
-    {
-      return pimpl().suggests();
-    }
-
-    std::set<std::string> Selection::recommends() const
-    {
-      return pimpl().recommends();
-    }
-
-    std::set<std::string> Selection::install_packages( const Locale & lang) const
+    std::set<std::string> Selection::install_packages( const Locale & lang ) const
     {
       return pimpl().install_packages();
     }
index c154d66..2842208 100644 (file)
@@ -56,8 +56,6 @@ namespace zypp
     /** selection presentation order */
     Label order() const;
 
-    std::set<std::string> suggests() const;
-    std::set<std::string> recommends() const;
     std::set<std::string> install_packages( const Locale & lang = Locale("") ) const;
 
   protected:
index 4469db7..996ff06 100644 (file)
@@ -35,6 +35,27 @@ namespace zypp
     Pathname PatternImplIf::script() const
     { return Pathname(); }
 
+    static void copycaps( std::set<std::string> & out, const CapSet & in)
+    {
+       for (CapSet::const_iterator it = in.begin(); it != in.end(); ++it) {
+           if (isKind<capability::NamedCap>( *it )
+               && it->refers() == ResTraits<zypp::Package>::kind )
+           {
+               out.insert( it->index() );
+           }
+       }
+    }
+
+    std::set<std::string> PatternImplIf::install_packages( const Locale & lang) const
+    {
+       std::set<std::string> result;
+
+       copycaps( result, self()->dep( Dep::REQUIRES ) );
+       copycaps( result, self()->dep( Dep::RECOMMENDS) );
+
+       return result;
+    }
+
     /////////////////////////////////////////////////////////////////
   } // namespace detail
   ///////////////////////////////////////////////////////////////////
index fddfe58..1e2f433 100644 (file)
@@ -47,6 +47,9 @@ namespace zypp
       virtual Pathname icon() const PURE_VIRTUAL;
 
       virtual Pathname script() const PURE_VIRTUAL;
+
+      /** ui helper */
+      virtual std::set<std::string> install_packages( const Locale & lang = Locale("") ) const;
     };
     ///////////////////////////////////////////////////////////////////
 
index d806e7f..a7de885 100644 (file)
@@ -10,6 +10,7 @@
  *
 */
 #include "zypp/detail/SelectionImplIf.h"
+#include "zypp/ResTraits.h"
 #include <iostream>
 
 using namespace std;
@@ -41,14 +42,26 @@ namespace zypp
     Label SelectionImplIf::order() const
     { return Label(); }
 
-    std::set<std::string> SelectionImplIf::suggests() const
-    { return std::set<std::string>(); }
-
-    std::set<std::string> SelectionImplIf::recommends() const
-    { return std::set<std::string>(); }
+    static void copycaps( std::set<std::string> & out, const CapSet & in)
+    {
+       for (CapSet::const_iterator it = in.begin(); it != in.end(); ++it) {
+           if (isKind<capability::NamedCap>( *it )
+               && it->refers() == ResTraits<zypp::Package>::kind )
+           {
+               out.insert( it->index() );
+           }
+       }
+    }
 
     std::set<std::string> SelectionImplIf::install_packages( const Locale & lang) const
-    { return std::set<std::string>(); }
+    {
+       std::set<std::string> result;
+#warning does not honor language packs
+       copycaps( result, self()->dep( Dep::REQUIRES ) );
+       copycaps( result, self()->dep( Dep::RECOMMENDS) );
+
+       return result;
+    }
 
     /////////////////////////////////////////////////////////////////
   } // namespace detail
index ffa3adb..253f2fa 100644 (file)
@@ -53,9 +53,8 @@ namespace zypp
         /** */
        virtual Label order() const PURE_VIRTUAL;
 
-  virtual std::set<std::string> suggests() const PURE_VIRTUAL;
-  virtual std::set<std::string> recommends() const PURE_VIRTUAL;
-  virtual std::set<std::string> install_packages( const Locale & lang = Locale("") ) const;
+        /** ui helper */
+        virtual std::set<std::string> install_packages( const Locale & lang = Locale("") ) const;
       
 #if 0
         // NOTE LangCode id zypp:Locale
index f2ca23f..d941ff9 100644 (file)
@@ -212,29 +212,6 @@ std::string toXML( const Selection::constPtr &obj )
   
   out << "    <description>"<< (obj->description()) << "</description>" << std::endl;
   
-  out << "    <grouplist>" << std::endl;
-  //recommended selections
-  std::set<std::string> rec_sel = obj->recommends();
-  std::set<std::string>::const_iterator it;
-  for (it = rec_sel.begin(); it != rec_sel.end(); ++it)
-    out << "       <metapkg type=\"optional\">" << *it << "</metapkg>" << std::endl;
-
-  std::set<std::string> sug_sel = obj->suggests();
-  it = sug_sel.begin();
-  for (; it != sug_sel.end(); ++it)
-    out << "       <metapkg type=\"optional\">" << *it << "</metapkg>" << std::endl;
-
-  out << "    </grouplist>" << std::endl;
-
-  out << "    <packagelist>" << std::endl;
-
-  std::set<std::string> ins_pkg = obj->install_packages();
-  it = ins_pkg.begin();
-  for (; it != ins_pkg.end(); ++it)
-  {
-    out << "       <packagereq type=\"optional\">" << *it << "</packagereq>" << std::endl;
-  }
-  out << "    </packagelist>" << std::endl;
   out << "  </group>" << std::endl;
   out << "</groups>" << std::endl;
   return out.str();