os << item._label;
}
os << endl << "\t";
- os << item._possible_items << endl << "\t";
+ os << item._possible_qitems << endl << "\t";
os << "]";
return os;
}
assert (static_cast<QueueItem*>(this) != subitem);
#if 0
// We want to keep the list of possible items sorted for easy comparison later.
- for (QueueItemList::iterator pos = _possible_items.begin(); pos != _possible_items.end(); pos++) {
+ for (QueueItemList::iterator pos = _possible_qitems.begin(); pos != _possible_qitems.end(); pos++) {
if ((*pos)->cmp(subitem) >= 0) { // found a larger one
- _possible_items.insert (pos, subitem); // insert before
+ _possible_qitems.insert (pos, subitem); // insert before
return;
}
}
#endif
- _possible_items.push_back (subitem); // no larger found, subitem must be largest
+ _possible_qitems.push_back (subitem); // no larger found, subitem must be largest
return;
}
return false;
}
- if (_possible_items.size() < branch->_possible_items.size()) {
+ if (_possible_qitems.size() < branch->_possible_qitems.size()) {
return false;
}
- QueueItemList::iterator iter = _possible_items.begin();
- QueueItemList::iterator iter_sub = branch->_possible_items.begin();
+ QueueItemList::iterator iter = _possible_qitems.begin();
+ QueueItemList::iterator iter_sub = branch->_possible_qitems.begin();
/* For every item inside the possible sub-branch, look for a matching item
in the branch. If we can't find a match, fail. (We can do this in one
- pass since the possible_items lists are sorted)
+ pass since the possible_qitems lists are sorted)
*/
- while (iter_sub != branch->_possible_items.end()) {
+ while (iter_sub != branch->_possible_qitems.end()) {
- while (iter != _possible_items.end()
+ while (iter != _possible_qitems.end()
&& (*iter)->cmp (*iter_sub)) {
iter++;
}
- if (iter == _possible_items.end())
+ if (iter == _possible_qitems.end())
return false;
iter++;
unsigned int branch_count;
bool did_something = true;
- for (QueueItemList::const_iterator iter = _possible_items.begin(); iter != _possible_items.end(); iter++) {
+ for (QueueItemList::const_iterator iter = _possible_qitems.begin(); iter != _possible_qitems.end(); iter++) {
QueueItem_Ptr item = *iter;
item, since our call to rc_queue_item_process is now
responsible for freeing it. */
- for (QueueItemList::iterator iter = _possible_items.begin(); iter != _possible_items.end(); iter++) {
+ for (QueueItemList::iterator iter = _possible_qitems.begin(); iter != _possible_qitems.end(); iter++) {
if (*iter == item) {
- _possible_items.erase (iter);
+ _possible_qitems.erase (iter);
break;
}
}
- } else if (branch_count == _possible_items.size()) {
+ } else if (branch_count == _possible_qitems.size()) {
/* Nothing was eliminated, so just pass the branch through (and set it to
NULL so that it won't get freed when we exit. */
QueueItemBranch_constPtr branch = dynamic_pointer_cast<const QueueItemBranch>(item);
/* First, sort by # of possible items. */
- cmp = CMP(_possible_items.size(), branch->_possible_items.size());
+ cmp = CMP(_possible_qitems.size(), branch->_possible_qitems.size());
if (cmp != 0)
return cmp;
/* We can do a by-item cmp since the possible items are kept in sorted order. */
- QueueItemList::const_iterator ia = _possible_items.begin();
- QueueItemList::const_iterator ib = branch->_possible_items.begin();
+ QueueItemList::const_iterator ia = _possible_qitems.begin();
+ QueueItemList::const_iterator ib = branch->_possible_qitems.begin();
- while (ia != _possible_items.end() && ib != branch->_possible_items.end()) {
+ while (ia != _possible_qitems.end() && ib != branch->_possible_qitems.end()) {
if (*ia && *ib) {
cmp = (*ia)->cmp (*ib);
if (cmp != 0) {
}
/* Both lists should end at the same time, since we initially sorted on length. */
- assert (ia == _possible_items.end() && ib == branch->_possible_items.end());
+ assert (ia == _possible_qitems.end() && ib == branch->_possible_qitems.end());
return 0;
}
{
QueueItemBranch_Ptr new_branch = new QueueItemBranch (pool());
new_branch->QueueItem::copy(this);
- for (QueueItemList::const_iterator iter = _possible_items.begin(); iter != _possible_items.end(); iter++) {
+ for (QueueItemList::const_iterator iter = _possible_qitems.begin(); iter != _possible_qitems.end(); iter++) {
QueueItem_Ptr cpy = (*iter)->copy();
- new_branch->_possible_items.push_front (cpy);
+ new_branch->_possible_qitems.push_front (cpy);
}
return new_branch;
private:
std::string _label;
- QueueItemList _possible_items;
+ QueueItemList _possible_qitems;
public:
friend std::ostream& operator<<(std::ostream&, const QueueItemBranch & item);
// ---------------------------------- accessors
- QueueItemList possibleItems (void) const { return _possible_items; }
+ QueueItemList possibleQItems (void) const { return _possible_qitems; }
const std::string & label (void) const { return _label; }
void setLabel (const std::string & label) { _label = label; }
- bool isEmpty (void) const { return _possible_items.empty(); }
+ bool isEmpty (void) const { return _possible_qitems.empty(); }
// ---------------------------------- methods
private:
const Capability & _capability; // the conflicting capability
- PoolItem_Ref _conflicting_item; // the item which issued the conflict
+ PoolItem_Ref _conflicting_item; // the item which issued the conflict, can be 'empty' for 'extraConflicts'
bool _actually_an_obsolete;
#include "zypp/base/Logger.h"
#include "zypp/base/String.h"
#include "zypp/base/Gettext.h"
-
#include "zypp/base/String.h"
+#include "zypp/base/Algorithm.h"
+#include "zypp/ResPool.h"
+#include "zypp/ResFilters.h"
+#include "zypp/CapFilters.h"
+
+
#include "zypp/solver/detail/Types.h"
#include "zypp/solver/detail/Helper.h"
#include "zypp/solver/detail/ResolverContext.h"
// (2) An info item is about an important-item is important.
static void
-mark_important_info (InfoList & il)
+mark_important_info (ResolverInfoList & il)
{
- // set of all items mentioned in the InfoList
+ // set of all items mentioned in the ResolverInfoList
PoolItemSet error_set;
bool did_something;
/* First of all, store all error-items in a set. */
- for (InfoList::iterator info_iter = il.begin(); info_iter != il.end(); ++info_iter) {
+ for (ResolverInfoList::iterator info_iter = il.begin(); info_iter != il.end(); ++info_iter) {
ResolverInfo_Ptr info = (*info_iter);
if (info != NULL // list items might be NULL
&& info->error ()) { // only look at error infos
- PoolItem_Ref item = info->affected(); // get item from InfoList
- if (item != NULL) {
+ PoolItem_Ref item = info->affected(); // get item from ResolverInfoList
+ if (item) {
error_set.insert (item);
}
for (PoolItemList::iterator res_iter = containerItems.begin(); res_iter != containerItems.end(); res_iter++) {
PoolItem_Ref item = (*res_iter);
- if (item != NULL) {
+ if (item) {
error_set.insert (item);
}
}
did_something = false;
- for (InfoList::iterator info_iter = il.begin(); info_iter != il.end(); ++info_iter) {
+ for (ResolverInfoList::iterator info_iter = il.begin(); info_iter != il.end(); ++info_iter) {
ResolverInfo_Ptr info = (*info_iter);
if (info != NULL // list items might be set to NULL
&& info->important ()) { // only look at important ones
}
-
void
ResolverContext::foreachInfo (PoolItem_Ref item, int priority, ResolverInfoFn fn, void *data) const
{
- InfoList info_list;
+ ResolverInfoList info_list;
ResolverContext_constPtr context = this;
// Assemble a list of copies of all of the info objects
while (context != NULL) {
- for (InfoList::iterator iter = context->_log.begin(); iter != context->_log.end(); iter++) {
+ for (ResolverInfoList::const_iterator iter = context->_log.begin(); iter != context->_log.end(); iter++) {
if ((item || (*iter)->affected() == item)
&& (*iter)->priority() >= priority) {
info_list.push_back ((*iter)->copy());
}
#if 0
// Merge info objects
- for (InfoList::iterator iter = info_list.begin(); iter != info_list.end(); iter++) {
+ for (ResolverInfoList::iterator iter = info_list.begin(); iter != info_list.end(); iter++) {
ResolverInfo_Ptr info1 = (*iter);
- InfoList::iterator subiter = iter;
+ ResolverInfoList::iterator subiter = iter;
if (info1 != NULL) {
for (subiter++; subiter != info_list.end(); subiter++) {
ResolverInfo_Ptr info2 = *subiter;
// Walk across the list of info objects and invoke our callback
- for (InfoList::iterator iter = info_list.begin(); iter != info_list.end(); iter++) {
+ for (ResolverInfoList::iterator iter = info_list.begin(); iter != info_list.end(); iter++) {
if (*iter != NULL) {
fn (*iter, data);
}
static void
get_info_foreach_cb (ResolverInfo_Ptr info, void *data)
{
- InfoList *il = (InfoList *)data;
+ ResolverInfoList *il = (ResolverInfoList *)data;
if (info->important ()) {
il->push_back (info);
-InfoList
+ResolverInfoList
ResolverContext::getInfo (void) const
{
- InfoList il;
- foreachInfo (NULL, -1, get_info_foreach_cb, (void *)&il);
+ ResolverInfoList il;
+ foreachInfo (PoolItem_Ref(), -1, get_info_foreach_cb, (void *)&il);
return il;
}
// spew
static void
-spew_pkg_cb (PoolItem_Ref item, ResStatus status, void *unused)
+spew_pkg_cb (PoolItem_Ref item, void *unused)
{
- cout << " " << item << " (" << status << ")" << endl;
+ MIL << " " << item << " (" << item.status() << ")" << endl;
}
void
-spew_pkg2_cb (PoolItem_Ref item1, ResStatus status1, PoolItem_Ref item2, ResStatus status2, void *unused)
+spew_pkg2_cb (PoolItem_Ref item1, PoolItem_Ref item2, void *unused)
{
- const char *s1, *s2;
-
- s1 = item1->asString().c_str();
- s2 = item2->asString().c_str();
-
- cout << " " << item2 << " (" << status2 << ") => (" << item1 << " (" << status1 << ")" << endl;
+ MIL << " " << item2 << " (" << item2.status() << ") => (" << item1 << " (" << item1.status() << ")" << endl;
}
void
ResolverContext::spew (void) const
{
- cout << "TO INSTALL:" << endl;
+ MIL << "TO INSTALL:" << endl;
foreachInstall (spew_pkg_cb, NULL);
- cout << endl;
+ MIL << endl;
- cout << "TO REMOVE:" << endl;
+ MIL << "TO REMOVE:" << endl;
foreachUninstall (spew_pkg_cb, NULL);
- cout << endl;
+ MIL << endl;
- cout << "TO UPGRADE:" << endl;
+ MIL << "TO UPGRADE:" << endl;
foreachUpgrade (spew_pkg2_cb, NULL);
- cout << endl;
+ MIL << endl;
}
static void
spew_info_cb (ResolverInfo_Ptr info, void *unused)
{
- if (info->error ()) cout << "[ERROR] ");
- else if (info->important()) cout << "[>>>>>] ");
- cout << info << endl;
+ if (info->error ()) MIL << "[ERROR] )";
+ else if (info->important()) MIL << "[>>>>>] )";
+ MIL << info << endl;
}
ResolverContext::spewInfo (void) const
{
DBG << "ResolverContext[" << this << "]::spewInfo" << endl;
- foreachInfo (NULL, -1, spew_info_cb, NULL);
+ foreachInfo (PoolItem_Ref(), -1, spew_info_cb, NULL);
}
//---------------------------------------------------------------------------
// requirements
-typedef struct {
+struct RequirementMet : public resfilter::OnCapMatchCallbackFunctor
+{
ResolverContext_constPtr context;
- const Capability *dep;
+ const Capability & capability;
bool flag;
-} RequirementMetInfo;
+ RequirementMet (ResolverContext_constPtr ctx, const Capability & c)
+ : context (ctx)
+ , capability (c)
+ , flag (false)
+ { }
-static bool
-requirement_met_cb (PoolItem_Ref item, const Capability & cap, void *data)
-{
- RequirementMetInfo *info = (RequirementMetInfo *)data;
- // info->dep is set for item set children. If it is set, query the
- // exact version only.
- if ((info->dep == NULL
- || *(info->dep) == cap)
- && info->context->itemIsPresent (item))
+ bool operator()( PoolItem_Ref provider, const Capability & match )
{
- info->flag = true;
- }
+ // capability is set for item set children. If it is set, query the
+ // exact version only.
+ if ((capability == Capability::noCap
+ || capability == match)
+ && context->isPresent (provider))
+ {
+ flag = true;
+ }
-//ERR << "requirement_met_cb(" << item << ", " << cap << ") [info->dep " <<
-// (info->dep != NULL ? info->dep->asString().c_str() : "(none)") << "] -> " << (info->flag ? "true" : "false") << endl;
- return ! info->flag;
-}
+// ERR << "RequirementMet(" << item << ", " << cap << ") [capability " <<
+// capability << "] -> " << (flag ? "true" : "false") << endl;
+
+ return ! flag;
+ }
+};
bool
ResolverContext::requirementIsMet (const Capability & dependency, bool is_child) const
{
- RequirementMetInfo info;
+ RequirementMet info (this, is_child ? dependency : Capability::noCap);
- info.context = this;
- info.dep = is_child ? &dependency : NULL;
- info.flag = false;
+ // world()->foreachProviding (dependency, requirement_met_cb, (void *)&info);
- world()->foreachProviding (dependency, requirement_met_cb, (void *)&info);
+ Dep dep( Dep::PROVIDES );
+
+ // world->foreachProvidingResItem (dependency, require_process_cb, &info);
+
+ invokeOnEach( pool()->byCapabilityIndexBegin( dependency.index(), dep ),
+ pool()->byCapabilityIndexEnd( dependency.index(), dep ),
+ resfilter::callOnCapMatchIn( dep, dependency, functor::functorRef<bool,PoolItem,Capability>(info) ) );
return info.flag;
}
//---------------------------------------------------------------------------
-static bool
-requirement_possible_cb (PoolItem_Ref item, const Capability & cap, void *data)
+struct RequirementPossible : public resfilter::OnCapMatchCallbackFunctor
{
- RequirementMetInfo *info = (RequirementMetInfo *)data;
+ bool flag;
- ResStatus status = info->context->getStatus (item);
+ RequirementPossible ()
+ : flag (false)
+ { }
- if (! item_status_is_to_be_uninstalled (status)
- || status == RESOLVABLE_STATUS_TO_BE_UNINSTALLED_DUE_TO_UNLINK) {
- info->flag = true;
- }
+ bool operator()( PoolItem_Ref provider, const Capability & match )
+ {
+ ResStatus status = provider.status();
- return ! info->flag;
-}
+ if (! status.isToBeUninstalled ()
+ || status.isToBeUninstalledDueToUnlink())
+ {
+ flag = true;
+ }
+
+ return ! flag;
+ }
+};
bool
-ResolverContext::requirementIsPossible (const Capability & dep) const
+ResolverContext::requirementIsPossible (const Capability & dependency) const
{
- RequirementMetInfo info;
+ RequirementPossible info;
- info.context = this;
- info.flag = false;
+ // world()->foreachProviding (dep, requirement_possible_cb, (void *)&info);
+
+ Dep dep( Dep::PROVIDES );
- world()->foreachProviding (dep, requirement_possible_cb, (void *)&info);
+ // world->foreachProvidingResItem (dependency, require_process_cb, &info);
+
+ invokeOnEach( pool()->byCapabilityIndexBegin( dependency.index(), dep ),
+ pool()->byCapabilityIndexEnd( dependency.index(), dep ),
+ resfilter::callOnCapMatchIn( dep, dependency, functor::functorRef<bool,PoolItem,Capability>(info) ) );
return info.flag;
}
{
CapSet requires = item->dep (Dep::REQUIRES);
for (CapSet::iterator iter = requires.begin(); iter != requires.end(); iter++) {
- if (! requirementIsPossible (*iter)) {
- return false;
- }
+ if (! requirementIsPossible (*iter)) {
+ return false;
}
+ }
return true;
}
if (! info->flag
&& item.status().isToBeInstalled ()
&& info->other->name() == item->name()
- && !compareByNVR (item, info->other))
+ && !compareByNVR (item.resolvable(), info->other.resolvable()))
{
info->flag = true;
}
// Context compare to identify equal branches
- int partialCompare (ResolverContext_Ptr context) const;
- int compare (ResolverContext_Ptr context) const;
+ int partialCompare (ResolverContext_constPtr context) const;
+ int compare (ResolverContext_constPtr context) const;
// debug
void spew (void) const;
//---------------------------------------------------------------------------
-string
-ResolverQueue::asString ( void ) const
-{
- return toString (*this);
-}
-
-
-string
-ResolverQueue::toString ( const ResolverQueue & resolverqueue )
-{
- string res;
-
- res += str::form ("Context [%p]", (const void *)resolverqueue._context.get());
- res += ", Items:\n\t";
- res += QueueItem::toString (resolverqueue._items, ",\n\t");
-
- return res;
-}
-
-
-ostream &
-ResolverQueue::dumpOn( ostream & str ) const
-{
- str << asString();
- return str;
-}
-
-
ostream&
operator<<( ostream& os, const ResolverQueue & resolverqueue)
{
- return os << resolverqueue.asString();
+ os << str::form ("Context [%p]", (const void *)resolverqueue._context.get());
+ os << ", Items:" << endl << "\t";
+ os << resolverqueue._qitems;
+ return os;
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
void
-ResolverQueue::addResItemToInstall (ResItem_constPtr resItem)
+ResolverQueue::addPoolItemToInstall (PoolItem_Ref poolItem)
{
- QueueItemInstall_Ptr item;
+ QueueItemInstall_Ptr qitem;
- if (_context->resItemIsPresent (resItem)
- && (!resItem_status_is_satisfied(_context->getStatus (resItem)))
- && (!resItem_status_is_unneeded(_context->getStatus (resItem)))) {
- WAR << resItem->asString() << " is already installed" << endl;
+ if (_context->isPresent (poolItem)
+ && (!poolItem.status().isSatisfied())
+ && (!poolItem.status().isUnneeded())) {
+ WAR << poolItem << " is already installed" << endl;
return;
}
- item = new QueueItemInstall (_context->pool(), resItem);
- item->setExplicitlyRequested ();
+ qitem = new QueueItemInstall (_context->pool(), poolItem);
+ qitem->setExplicitlyRequested ();
- addItem (item);
+ addItem (qitem);
}
void
-ResolverQueue::addResItemToEstablish (ResItem_constPtr resItem)
+ResolverQueue::addPoolItemToEstablish (PoolItem_Ref poolItem)
{
- QueueItemEstablish_Ptr item;
+ QueueItemEstablish_Ptr qitem;
- item = new QueueItemEstablish (_context->pool(), resItem);
- item->setExplicitlyRequested ();
+ qitem = new QueueItemEstablish (_context->pool(), poolItem);
+ qitem->setExplicitlyRequested ();
- addItem (item);
+ addItem (qitem);
}
void
-ResolverQueue::addResItemToRemove (ResItem_constPtr resItem, bool remove_only_mode)
+ResolverQueue::addPoolItemToRemove (PoolItem_Ref poolItem, bool remove_only_mode)
{
- QueueItemUninstall_Ptr item;
+ QueueItemUninstall_Ptr qitem;
- if (_context->resItemIsAbsent (resItem))
+ if (_context->isAbsent (poolItem))
return;
- item = new QueueItemUninstall (_context->pool(), resItem, QueueItemUninstall::EXPLICIT);
+ qitem = new QueueItemUninstall (_context->pool(), poolItem, QueueItemUninstall::EXPLICIT);
if (remove_only_mode)
- item->setRemoveOnly ();
+ qitem->setRemoveOnly ();
- item->setExplicitlyRequested ();
+ qitem->setExplicitlyRequested ();
- addItem (item);
+ addItem (qitem);
}
void
-ResolverQueue::addResItemToVerify (ResItem_constPtr resItem)
+ResolverQueue::addPoolItemToVerify (PoolItem_Ref poolItem)
{
- CapSet requires = resItem->requires();
- for (CapSet::const_iterator iter = requires.begin(); iter != requires.end(); iter++) {
- QueueItemRequire_Ptr item = new QueueItemRequire (_context->pool(), *iter);
- item->addResItem (resItem);
- addItem (item);
+ CapSet requires = poolItem->dep (Dep::REQUIRES);
+ for (CapSet::const_iterator iter = requires.begin(); iter != requires.end(); ++iter) {
+ QueueItemRequire_Ptr qitem = new QueueItemRequire (_context->pool(), *iter);
+ qitem->addPoolItem (poolItem);
+ addItem (qitem);
}
- CapSet conflicts = resItem->conflicts();
- for (CapSet::const_iterator iter = conflicts.begin(); iter != conflicts.end(); iter++) {
- QueueItemConflict_Ptr item = new QueueItemConflict (_context->pool(), *iter, resItem);
- addItem (item);
+ CapSet conflicts = poolItem->dep (Dep::CONFLICTS);
+ for (CapSet::const_iterator iter = conflicts.begin(); iter != conflicts.end(); ++iter) {
+ QueueItemConflict_Ptr qitem = new QueueItemConflict (_context->pool(), *iter, poolItem);
+ addItem (qitem);
}
}
void
ResolverQueue::addExtraCapability (const Capability & dep)
{
- QueueItemRequire_Ptr item = new QueueItemRequire (_context->pool(), dep);
- addItem (item);
+ QueueItemRequire_Ptr qitem = new QueueItemRequire (_context->pool(), dep);
+ addItem (qitem);
}
void
ResolverQueue::addExtraConflict (const Capability & dep)
{
- QueueItemConflict_Ptr item = new QueueItemConflict (_context->pool(), dep, NULL);
- addItem (item);
+ QueueItemConflict_Ptr qitem = new QueueItemConflict (_context->pool(), dep, PoolItem_Ref());
+ addItem (qitem);
}
void
-ResolverQueue::addItem (QueueItem_Ptr item)
+ResolverQueue::addItem (QueueItem_Ptr qitem)
{
- _items.push_front (item);
+ _qitems.push_front (qitem);
}
bool
ResolverQueue::containsOnlyBranches ()
{
- for (QueueItemList::const_iterator iter = _items.begin(); iter != _items.end(); iter++) {
+ for (QueueItemList::const_iterator iter = _qitems.begin(); iter != _qitems.end(); ++iter) {
if (!(*iter)->isBranch())
return false;
}
//---------------------------------------------------------------------------
static int
-itemlist_max_priority (const QueueItemList & qil)
+qitemlist_max_priority (const QueueItemList & qil)
{
int max_priority = -1;
- for (QueueItemList::const_iterator iter = qil.begin(); iter != qil.end(); iter++) {
+ for (QueueItemList::const_iterator iter = qil.begin(); iter != qil.end(); ++iter) {
if ((*iter)->priority() > max_priority) {
max_priority = (*iter)->priority();
}
bool
ResolverQueue::processOnce ()
{
- QueueItemList new_items;
+ QueueItemList new_qitems;
int max_priority;
bool did_something = false;
- _DBG("QUEUE_SPEW") << "ResolverQueue::processOnce(" << asString() <<", " << (int) _items.size() << " items" << endl;
- while ( (max_priority = itemlist_max_priority (_items)) >= 0
+ DBG << "ResolverQueue::processOnce(" << *this <<", " << (int) _qitems.size() << " items" << endl;
+ while ( (max_priority = qitemlist_max_priority (_qitems)) >= 0
&& _context->isValid () ) {
bool did_something_recently = false;
- _DBG("QUEUE_SPEW") << "ResolverQueue::processOnce() inside loop" << endl;
- for (QueueItemList::iterator iter = _items.begin(); iter != _items.end() && _context->isValid();) {
- QueueItem_Ptr item = *iter;
- _DBG("QUEUE_SPEW") << "=====> 1st pass: [" << item->asString() << "]" << endl;
+ DBG << "ResolverQueue::processOnce() inside loop" << endl;
+ for (QueueItemList::iterator iter = _qitems.begin(); iter != _qitems.end() && _context->isValid();) {
+ QueueItem_Ptr qitem = *iter;
+ DBG << "=====> 1st pass: [" << qitem << "]" << endl;
QueueItemList::iterator next = iter; ++next;
- if (item && item->priority() == max_priority) {
- if (item->process (_context, new_items)) {
+ if (qitem && qitem->priority() == max_priority) {
+ if (qitem->process (_context, new_qitems)) {
did_something_recently = true;
}
- _items.erase (iter);
+ _qitems.erase (iter);
}
iter = next;
}
}
}
- _items = new_items;
- _DBG("QUEUE_SPEW") << (int) _items.size() << " items after first pass" << endl;
+ _qitems = new_qitems;
+ DBG << (int) _qitems.size() << " qitems after first pass" << endl;
/*
Now make a second pass over the queue, removing any super-branches.
*/
_XXX("QUEUE_SPEW") << "ResolverQueue::processOnce() second pass" << endl;
- for (QueueItemList::iterator iter = _items.begin(); iter != _items.end();) {
+ for (QueueItemList::iterator iter = _qitems.begin(); iter != _qitems.end();) {
QueueItemList::iterator next = iter; next++;
- QueueItem_Ptr item = *iter;
-
- _DBG("QUEUE_SPEW") << "=====> 2nd pass: [" << item->asString() << "]" << endl;
- if (item->isBranch()) {
- _DBG("QUEUE_SPEW") << "ResolverQueue::processOnce() is branch" << endl;
- QueueItemBranch_Ptr branch = dynamic_pointer_cast<QueueItemBranch>(item);
- for (QueueItemList::const_iterator iter2 = _items.begin(); iter2 != _items.end(); iter2++) {
- _DBG("QUEUE_SPEW") << "Compare branch with [" << (*iter2)->asString() << "]" << endl;
+ QueueItem_Ptr qitem = *iter;
+
+ DBG << "=====> 2nd pass: [" << qitem << "]" << endl;
+ if (qitem->isBranch()) {
+ DBG << "ResolverQueue::processOnce() is branch" << endl;
+ QueueItemBranch_Ptr branch = dynamic_pointer_cast<QueueItemBranch>(qitem);
+ for (QueueItemList::const_iterator iter2 = _qitems.begin(); iter2 != _qitems.end(); iter2++) {
+ DBG << "Compare branch with [" << (*iter2) << "]" << endl;
if (iter != iter2
&& branch->contains (*iter2)) {
- _DBG("QUEUE_SPEW") << "Contained within, removing" << endl;
- _items.erase (iter);
+ DBG << "Contained within, removing" << endl;
+ _qitems.erase (iter);
break;
}
}
iter = next;
}
if (did_something)
- _DBG("QUEUE_SPEW") << "did somesthing: " << (int)_items.size() << " items" << endl;
+ DBG << "did somesthing: " << (int)_qitems.size() << " qitems" << endl;
else
- _DBG("QUEUE_SPEW") << "did nothing: " << (int)_items.size() << " items" << endl;
+ DBG << "did nothing: " << (int)_qitems.size() << " qitems" << endl;
return did_something;
}
//---------------------------------------------------------------------------
static ResolverQueue_Ptr
-copy_queue_except_for_branch (ResolverQueue_Ptr queue, QueueItem_Ptr branch_item, QueueItem_Ptr subitem)
+copy_queue_except_for_branch (ResolverQueue_Ptr queue, QueueItem_Ptr branch_qitem, QueueItem_Ptr subqitem)
{
ResolverContext_Ptr new_context;
ResolverQueue_Ptr new_queue;
new_context = new ResolverContext (queue->context());
new_queue = new ResolverQueue (new_context);
- QueueItemList qil = queue->items();
- for (QueueItemList::const_iterator iter = qil.begin(); iter != qil.end(); iter++) {
- QueueItem_Ptr item = *iter;
- QueueItem_Ptr new_item;
+ QueueItemList qil = queue->qitems();
+ for (QueueItemList::const_iterator iter = qil.begin(); iter != qil.end(); ++iter) {
+ QueueItem_Ptr qitem = *iter;
+ QueueItem_Ptr new_qitem;
- if (item == branch_item) {
- new_item = subitem->copy ();
-
- if (new_item->isInstall()) {
- QueueItemInstall_Ptr install_item = dynamic_pointer_cast<QueueItemInstall>(new_item);
+ if (qitem == branch_qitem) {
+ new_qitem = subqitem->copy ();
+ if (new_qitem->isInstall()) {
+ QueueItemInstall_Ptr install_qitem = dynamic_pointer_cast<QueueItemInstall>(new_qitem);
+#warning needs Source backref
+#if 0
/* Penalties are negative priorities */
int penalty;
- penalty = - queue->context()->getChannelPriority (install_item->resItem()->channel());
+ penalty = - queue->context()->getChannelPriority (install_qitem->poolItem()->channel());
- install_item->setOtherPenalty (penalty);
+ install_qitem->setOtherPenalty (penalty);
+#endif
}
} else {
- new_item = item->copy ();
+ new_qitem = qitem->copy ();
}
- new_queue->addItem (new_item);
+ new_queue->addItem (new_qitem);
}
return new_queue;
typedef std::map <QueueItem_Ptr, QueueItem_Ptr> DeferTable;
DeferTable to_defer;
- for (QueueItemList::const_iterator iter = _items.begin(); iter != _items.end() && first_branch == NULL; iter++) {
- QueueItem_Ptr item = *iter;
- if (item->isBranch()) {
- first_branch = dynamic_pointer_cast<QueueItemBranch>(item);
+ for (QueueItemList::const_iterator iter = _qitems.begin(); iter != _qitems.end() && first_branch == NULL; ++iter) {
+ QueueItem_Ptr qitem = *iter;
+ if (qitem->isBranch()) {
+ first_branch = dynamic_pointer_cast<QueueItemBranch>(qitem);
}
}
if (first_branch == NULL)
return;
+ QueueItemList possible_qitems = first_branch->possibleQItems();
+
+#warning Needs Source backref
+#if 0
/*
- Check for deferrable items: if we have two install items where the to-be-installed
- resItems have the same name, then we will defer the lower-priority install if
+ Check for deferrable qitems: if we have two install qitems where the to-be-installed
+ poolItems have the same name, then we will defer the lower-priority install if
one of the following is true:
- (1) Both resItems have the same version
+ (1) Both poolItems have the same version
(2) The lower-priority channel is a previous version.
*/
- QueueItemList possible_items = first_branch->possibleItems();
- for (QueueItemList::const_iterator iter = possible_items.begin(); iter != possible_items.end(); iter++) {
+ for (QueueItemList::const_iterator iter = possible_qitems.begin(); iter != possible_qitems.end(); ++iter) {
QueueItemList::const_iterator iter2 = iter;
- for (iter2++; iter2 != possible_items.end(); iter2++) {
- QueueItem_Ptr item = *iter;
- QueueItem_Ptr item2 = *iter2;
+ for (iter2++; iter2 != possible_qitems.end(); iter2++) {
+ QueueItem_Ptr qitem = *iter;
+ QueueItem_Ptr qitem2 = *iter2;
- if (item->isInstall() && item2->isInstall()) {
- ResItem_constPtr r = (dynamic_pointer_cast<QueueItemInstall>(item))->resItem();
- ResItem_constPtr r2 = (dynamic_pointer_cast<QueueItemInstall>(item2))->resItem();
+ if (qitem->isInstall() && qitem2->isInstall()) {
+ PoolItem_Ref r = (dynamic_pointer_cast<QueueItemInstall>(qitem))->item();
+ PoolItem_Ref r2 = (dynamic_pointer_cast<QueueItemInstall>(qitem2))->item();
Channel_constPtr channel = r->channel();
Channel_constPtr channel2 = r2->channel();
int priority, priority2;
|| (priority > priority2 && ResItem::compare (r, r2) > 0)) {
if (priority < priority2)
- to_defer[item] = item;
+ to_defer[qitem] = qitem;
else /* if (priority > priority2) */
- to_defer[item2] = item2;
+ to_defer[qitem2] = qitem2;
}
}
}
}
}
+#endif
- for (QueueItemList::const_iterator iter = possible_items.begin(); iter != possible_items.end(); iter++) {
+ for (QueueItemList::const_iterator iter = possible_qitems.begin(); iter != possible_qitems.end(); ++iter) {
ResolverQueue_Ptr new_queue;
- QueueItem_Ptr new_item = *iter;
+ QueueItem_Ptr new_qitem = *iter;
- new_queue = copy_queue_except_for_branch (this, (QueueItem_Ptr) first_branch, new_item);
+ new_queue = copy_queue_except_for_branch (this, (QueueItem_Ptr) first_branch, new_qitem);
- DeferTable::const_iterator pos = to_defer.find (new_item);
+ DeferTable::const_iterator pos = to_defer.find (new_qitem);
if (pos != to_defer.end()) {
deferred_queues.push_back (new_queue);
} else {
{
_DBG("RC_SPEW") << "Resolver Queue: " << (_context->isInvalid() ? "INVALID" : "") << endl;
- if (_items.empty()) {
+ if (_qitems.empty()) {
_DBG("RC_SPEW") << " (empty)" << endl;
} else {
- for (QueueItemList::const_iterator iter = _items.begin(); iter != _items.end(); iter++) {
- _DBG("RC_SPEW") << " " << (*iter)->asString() << endl;
+ for (QueueItemList::const_iterator iter = _qitems.begin(); iter != _qitems.end(); ++iter) {
+ _DBG("RC_SPEW") << " " << (*iter) << endl;
}
}
private:
ResolverContext_Ptr _context;
- QueueItemList _items;
+ QueueItemList _qitems;
public:
ResolverQueue (ResolverContext_Ptr context = NULL);
// ---------------------------------- accessors
ResolverContext_Ptr context (void) const { return _context; }
- QueueItemList items(void) const { return _items; }
+ QueueItemList qitems(void) const { return _qitems; }
// ---------------------------------- methods
- void addPoolItemToInstall (PoolItem_Ref item);
- void addPoolItemToEstablish (PoolItem_Ref item);
- void addPoolItemToRemove (PoolItem_Ref item, bool remove_only_mode);
- void addPoolItemToVerify (PoolItem_Ref item);
+ void addPoolItemToInstall (PoolItem_Ref poolItem);
+ void addPoolItemToEstablish (PoolItem_Ref poolItem);
+ void addPoolItemToRemove (PoolItem_Ref poolItem, bool remove_only_mode);
+ void addPoolItemToVerify (PoolItem_Ref poolItem);
void addExtraCapability (const Capability & cap);
void addExtraConflict (const Capability & cap);
- void addItem (QueueItem_Ptr item);
+ void addItem (QueueItem_Ptr qtem);
- bool isEmpty () const { return _items.empty(); }
+ bool isEmpty () const { return _qitems.empty(); }
bool isInvalid ();
bool containsOnlyBranches ();