#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"
{ 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
/**
* 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:
#include "zypp/base/ReferenceCounted.h"
#include "zypp/base/PtrTypes.h"
-#include "zypp/Resolver.h"
#include "zypp/ProblemSolution.h"
/////////////////////////////////////////////////////////////////////////
#include "zypp/CapFilters.h"
#include "zypp/ZYppFactory.h"
#include "zypp/SystemResObject.h"
+#include "zypp/solver/detail/ResolverInfoNeededBy.h"
/////////////////////////////////////////////////////////////////////////
_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
{
/////////////////////////////////////////////////////////////////////
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<PoolItem_Ref,ItemCapKind> ItemCapKindMap;
+ typedef std::list<ItemCapKind> ItemCapKindList;
///////////////////////////////////////////////////////////////////
//
// list of problematic items after doUpgrade()
PoolItemList _update_items;
-
+ // Additional information about the solverrun
+ ItemCapKindMap _isSelectedBy;
+ ItemCapKindMap _selects;
+
CapSet _extra_caps;
CapSet _extra_conflicts;
bool doesObsoleteCapability (PoolItem_Ref candidate, const Capability & cap);
bool doesObsoleteItem (PoolItem_Ref candidate, PoolItem_Ref installed);
+ void collectResolverInfo (void);
+
+
public:
Resolver (const ResPool & pool);
// reset all SOLVER transaction in pool
void undo(void);
+ // Get more information about the solverrun
+ // Which item will be triggerd by another item or triggers an item for
+ // installation
+ const ItemCapKindList isSelectedBy (const PoolItem_Ref item);
+ const ItemCapKindList selects (const PoolItem_Ref item);
+
// only for testsuite
void reset (const bool resetValidResults = false);
virtual std::string message (void) const;
virtual ResolverInfo_Ptr copy (void) const;
void setCapability (const Capability & cap, const Dep & capKind) { _cap = cap; _capKind = capKind; }
-;
+ Dep capKind() const {return _capKind;}
+ Capability capability() const {return _cap;};
};
///////////////////////////////////////////////////////////////////