Author: schubi2
Date: Fri Jun 22 15:27:34 2007
New Revision: 5829
URL: http://svn.opensuse.org/viewcvs/zypp?rev=5829&view=rev
Log:
New API calls added:
const solver::detail::ItemCapKindList isSelectedBy (const PoolItem_Ref
item);
const solver::detail::ItemCapKindList selects (const PoolItem_Ref
item);
Modified:
trunk/libzypp/zypp/ProblemSolution.h
trunk/libzypp/zypp/Resolver.cc
trunk/libzypp/zypp/Resolver.h
trunk/libzypp/zypp/ResolverProblem.h
trunk/libzypp/zypp/solver/detail/Resolver.cc
trunk/libzypp/zypp/solver/detail/Resolver.h
trunk/libzypp/zypp/solver/detail/ResolverInfoNeededBy.h
Modified: trunk/libzypp/zypp/ProblemSolution.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/ProblemSolution.h?rev=5829&r1=5828&r2=5829&view=diff
==============================================================================
--- trunk/libzypp/zypp/ProblemSolution.h (original)
+++ trunk/libzypp/zypp/ProblemSolution.h Fri Jun 22 15:27:34 2007
@@ -14,7 +14,6 @@
#include "zypp/base/ReferenceCounted.h"
#include "zypp/base/PtrTypes.h"
-#include "zypp/Resolver.h"
#include "zypp/solver/detail/Resolver.h"
#include "zypp/ResolverProblem.h"
#include "zypp/solver/detail/SolutionAction.h"
Modified: trunk/libzypp/zypp/Resolver.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/Resolver.cc?rev=5829&r1=5828&r2=5829&view=diff
==============================================================================
--- trunk/libzypp/zypp/Resolver.cc (original)
+++ trunk/libzypp/zypp/Resolver.cc Fri Jun 22 15:27:34 2007
@@ -110,7 +110,14 @@
{ return _pimpl->maxSolverPasses(); }
bool Resolver::createSolverTestcase (const std::string & dumpPath)
{ solver::detail::Testcase testcase (dumpPath);
- return testcase.createTestcase(*_pimpl);}
+ return testcase.createTestcase(*_pimpl);}
+#if 1
+ const solver::detail::ItemCapKindList Resolver::isSelectedBy (const PoolItem_Ref item)
+ { return _pimpl->isSelectedBy (item); }
+ const solver::detail::ItemCapKindList Resolver::selects (const PoolItem_Ref item)
+ { return _pimpl->selects (item); }
+#endif
+
/////////////////////////////////////////////////////////////////
} // namespace zypp
Modified: trunk/libzypp/zypp/Resolver.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/Resolver.h?rev=5829&r1=5828&r2=5829&view=diff
==============================================================================
--- trunk/libzypp/zypp/Resolver.h (original)
+++ trunk/libzypp/zypp/Resolver.h Fri Jun 22 15:27:34 2007
@@ -270,9 +270,40 @@
/**
* Generates a solver Testcase of the current state
*
- * return true if it was successful
+ * \parame dumpPath destination directory of the created directory
+ * \return true if it was successful
*/
- bool createSolverTestcase (const std::string & dumpPath = "/var/log/YaST2/solverTestcase");
+ bool createSolverTestcase (const std::string & dumpPath = "/var/log/YaST2/solverTestcase");
+
+
+ /**
+ * Gives information about WHO has selected an item for installation.
+ *
+ * \param item Evaluate additional information for this resolvable.
+ * \return A list of structures which contains:
+ * item Item which has triggered the selection of the given param item.
+ * cap Capability which has triggerd this selection
+ * capKind Kind of that capability (e.g. Dep::REQUIRES,Dep::RECOMMENDS,... )
+ *
+ * Note: Start a solver run before in order to have a result. Not matter if it is valid or invalid.
+ *
+ */
+ const solver::detail::ItemCapKindList isSelectedBy (const PoolItem_Ref item);
+
+ /**
+ * Gives information about WHICH additional items have been selected by the given item.
+ *
+ * \param item Evaluate additional information for this resolvable.
+ * \return A list of structures which contains:
+ * item Item which has BEEN triggered by the selection of the given param item.
+ * cap Capability which has BEEN triggerd by this selection
+ * capKind Kind of that capability (e.g. Dep::REQUIRES,Dep::RECOMMENDS,... )
+ *
+ * Note: Start a solver run before in order to have a result. Not matter if it is valid or invalid.
+ *
+ */
+ const solver::detail::ItemCapKindList selects (const PoolItem_Ref item);
+
protected:
Modified: trunk/libzypp/zypp/ResolverProblem.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/ResolverProblem.h?rev=5829&r1=5828&r2=5829&view=diff
==============================================================================
--- trunk/libzypp/zypp/ResolverProblem.h (original)
+++ trunk/libzypp/zypp/ResolverProblem.h Fri Jun 22 15:27:34 2007
@@ -14,7 +14,6 @@
#include "zypp/base/ReferenceCounted.h"
#include "zypp/base/PtrTypes.h"
-#include "zypp/Resolver.h"
#include "zypp/ProblemSolution.h"
/////////////////////////////////////////////////////////////////////////
Modified: trunk/libzypp/zypp/solver/detail/Resolver.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/solver/detail/Resolver.cc?rev=5829&r1=5828&r2=5829&view=diff
==============================================================================
--- trunk/libzypp/zypp/solver/detail/Resolver.cc (original)
+++ trunk/libzypp/zypp/solver/detail/Resolver.cc Fri Jun 22 15:27:34 2007
@@ -33,6 +33,7 @@
#include "zypp/CapFilters.h"
#include "zypp/ZYppFactory.h"
#include "zypp/SystemResObject.h"
+#include "zypp/solver/detail/ResolverInfoNeededBy.h"
/////////////////////////////////////////////////////////////////////////
@@ -161,12 +162,99 @@
_best_context = NULL;
_timed_out = false;
+ _isSelectedBy.clear();
+ _selects.clear();
+
if (resetValidResults)
contextPool.reset();
}
+//--------------------------------------------------------------------------------------------------
+// Get more information about the solverrun
+// Which item will be triggerd by another item or triggers an item for installation
+typedef struct {
+ ItemCapKindMap isSelectedBy;
+ ItemCapKindMap selects;
+} Collector;
+
+
+static void
+collector_cb_needed (ResolverInfo_Ptr info, void *data)
+{
+ Collector *collector = (Collector *)data;
+ if (info->type() == RESOLVER_INFO_TYPE_NEEDED_BY) {
+ ResolverInfoNeededBy_constPtr needed_by = dynamic_pointer_cast<const ResolverInfoNeededBy>(info);
+ if (needed_by->items().size() >= 1) {
+ PoolItem_Ref item = info->affected();
+ PoolItemList itemList = needed_by->items();
+
+ for (PoolItemList::const_iterator iter = itemList.begin();
+ iter != itemList.end(); iter++) {
+ ItemCapKind capKind( *iter, needed_by->capability(), needed_by->capKind() );
+ collector->isSelectedBy.insert (make_pair( item, capKind));
+
+ ItemCapKind capKindReverse( item, needed_by->capability(), needed_by->capKind() );
+ collector->selects.insert (make_pair( *iter, capKindReverse));
+ }
+
+ }
+ }
+}
+
+void
+Resolver::collectResolverInfo(void)
+{
+ ResolverContext_Ptr collectContext = context(); // best context or failed context
+ if ( collectContext != NULL
+ && _isSelectedBy.empty()
+ && _selects.empty()) {
+ Collector collector;
+ collectContext->foreachInfo (PoolItem(), RESOLVER_INFO_PRIORITY_VERBOSE, collector_cb_needed, &collector);
+ _isSelectedBy = collector.isSelectedBy;
+ _selects = collector.selects;
+ }
+}
+
+
+const ItemCapKindList Resolver::isSelectedBy (const PoolItem_Ref item) {
+ ItemCapKindList ret;
+ collectResolverInfo();
+
+ for (ItemCapKindMap::const_iterator iter = _isSelectedBy.find(item); iter != _isSelectedBy.end();) {
+ ItemCapKind info = iter->second;
+ PoolItem_Ref iterItem = iter->first;
+ if (iterItem == item) {
+ ret.push_back(info);
+ iter++;
+ } else {
+ // exit
+ iter = _isSelectedBy.end();
+ }
+ }
+ return ret;
+}
+
+const ItemCapKindList Resolver::selects (const PoolItem_Ref item) {
+ ItemCapKindList ret;
+ collectResolverInfo();
+
+ for (ItemCapKindMap::const_iterator iter = _selects.find(item); iter != _selects.end();) {
+ ItemCapKind info = iter->second;
+ PoolItem_Ref iterItem = iter->first;
+ if (iterItem == item) {
+ ret.push_back(info);
+ iter++;
+ } else {
+ // exit
+ iter = _selects.end();
+ }
+ }
+ return ret;
+}
+
+//----------------------------------------------------------------------------------------------------
ResolverContext_Ptr
Resolver::context (void) const
{
Modified: trunk/libzypp/zypp/solver/detail/Resolver.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/solver/detail/Resolver.h?rev=5829&r1=5828&r2=5829&view=diff
==============================================================================
--- trunk/libzypp/zypp/solver/detail/Resolver.h (original)
+++ trunk/libzypp/zypp/solver/detail/Resolver.h Fri Jun 22 15:27:34 2007
@@ -54,6 +54,27 @@
/////////////////////////////////////////////////////////////////////
namespace detail
{ ///////////////////////////////////////////////////////////////////
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // CLASS NAME : ItemCapKind
+ //
+ /** */
+ struct ItemCapKind
+ {
+ public:
+ Capability cap; //Capability which has triggerd this selection
+ Dep capKind; //Kind of that capability
+ PoolItem_Ref item; //Item which has triggered this selection
+
+ ItemCapKind( PoolItem i, Capability c, Dep k)
+ : cap( c )
+ , capKind( k )
+ , item( i )
+ { }
+ };
+ typedef std::multimap