add transactResKind()
authorKlaus Kaempf <kkaempf@suse.de>
Thu, 30 Mar 2006 17:02:45 +0000 (17:02 +0000)
committerKlaus Kaempf <kkaempf@suse.de>
Thu, 30 Mar 2006 17:02:45 +0000 (17:02 +0000)
zypp/solver/detail/Resolver.cc
zypp/solver/detail/Resolver.h

index f26a1f1805ba135ca12c6fe4d96fe98ba2daf816..6fb56d75afd2c47f7b66b52e656c049ad218d816 100644 (file)
@@ -915,6 +915,51 @@ Resolver::transactResObject( ResObject::constPtr robj, bool install)
     return transactCaps( _pool, robj->dep( Dep::REQUIRES ), install, false );
 }
 
+//
+// transact all objects of a specific kind
+// -> look through the pool and run transactResObject() accordingly
+
+struct TransactKind : public resfilter::PoolItemFilterFunctor
+{
+    Resolver & resolver;
+    bool result;
+
+    TransactKind( Resolver & r )
+       : resolver( r )
+       , result( true )
+    { }
+
+    bool operator()( PoolItem_Ref item )
+    {
+       if (item.status().isToBeInstalled())
+           result = resolver.transactResObject( item.resolvable(), true );
+       else if (item.status().isToBeUninstalled())
+           result = resolver.transactResObject( item.resolvable(), false );
+       return false;
+    }
+};
+
+
+bool
+Resolver::transactResKind( Resolvable::Kind kind )
+{
+    TransactKind callback (*this);
+
+    DBG << "transactResKind(" << kind << ")" << endl;
+
+    invokeOnEach( pool().byKindBegin( kind ),
+                 pool().byKindEnd( kind ),
+                 functor::chain( resfilter::ByTransact(), resfilter::ByInstalled ()),
+                 functor::functorRef<bool,PoolItem>( callback ) );
+
+    invokeOnEach( pool().byKindBegin( kind ),
+                 pool().byKindEnd( kind ),
+                 functor::chain( resfilter::ByTransact(), resfilter::ByUninstalled ()),
+                 functor::functorRef<bool,PoolItem>( callback ) );
+
+    return callback.result;
+}
+
 ///////////////////////////////////////////////////////////////////
     };// namespace detail
     /////////////////////////////////////////////////////////////////////
index d5fd4c7a6f921615d7f93f403fe63d2a50589686..f01db2f16b7abd5380ea4a7a3bcaf03c1eb5a222 100644 (file)
@@ -186,6 +186,7 @@ class Resolver : public base::ReferenceCounted, private base::NonCopyable {
     bool resolvePool (void);
 
     bool transactResObject( ResObject::constPtr robj, bool install = true);
+    bool transactResKind( Resolvable::Kind kind );
 
     void doUpgrade( zypp::UpgradeStatistics & opt_stats_r );