1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
4 * Copyright (C) 2008 SUSE Linux Products GmbH
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
21 #include "zypp/base/Logger.h"
22 #include "zypp/solver/detail/SolverQueueItemInstallOneOf.h"
23 #include "satsolver/solver.h"
25 /////////////////////////////////////////////////////////////////////////
27 { ///////////////////////////////////////////////////////////////////////
28 ///////////////////////////////////////////////////////////////////////
30 { /////////////////////////////////////////////////////////////////////
31 /////////////////////////////////////////////////////////////////////
33 { ///////////////////////////////////////////////////////////////////
37 IMPL_PTR_TYPE(SolverQueueItemInstallOneOf);
39 //---------------------------------------------------------------------------
42 SolverQueueItemInstallOneOf::dumpOn( std::ostream & os ) const
44 os << "[" << (_soft?"Soft":"") << "InstallOneOf: ";
45 for (PoolItemList::const_iterator iter = _oneOfList.begin();
46 iter != _oneOfList.end();
54 //---------------------------------------------------------------------------
56 SolverQueueItemInstallOneOf::SolverQueueItemInstallOneOf (const ResPool & pool, const PoolItemList & itemList,
58 : SolverQueueItem (QUEUE_ITEM_TYPE_INSTALL_ONE_OF, pool)
59 , _oneOfList (itemList)
65 SolverQueueItemInstallOneOf::~SolverQueueItemInstallOneOf()
69 //---------------------------------------------------------------------------
71 bool SolverQueueItemInstallOneOf::addRule (_Queue & q)
74 MIL << "Install one of " << (_soft ? "(soft):" : ":")<< endl;
77 queue_push( &(q), SOLVER_INSTALL_SOLVABLE_ONE_OF | SOLVER_WEAK);
79 queue_push( &(q), SOLVER_INSTALL_SOLVABLE_ONE_OF );
82 for (PoolItemList::const_iterator iter = _oneOfList.begin(); iter != _oneOfList.end(); iter++) {
83 Id id = (*iter)->satSolvable().id();
85 ERR << *iter << " not found" << endl;
88 MIL << " candidate:" << *iter << " with the SAT-Pool ID: " << id << endl;
89 queue_push( &(q), id );
92 queue_push( &(q), 0 ); // finish candidate
98 SolverQueueItemInstallOneOf::copy (void) const
100 SolverQueueItemInstallOneOf_Ptr new_installOneOf = new SolverQueueItemInstallOneOf (pool(), _oneOfList);
101 new_installOneOf->SolverQueueItem::copy(this);
102 new_installOneOf->_soft = _soft;
104 return new_installOneOf;
108 SolverQueueItemInstallOneOf::cmp (SolverQueueItem_constPtr item) const
110 int cmp = this->compare (item);
113 SolverQueueItemInstallOneOf_constPtr install = dynamic_pointer_cast<const SolverQueueItemInstallOneOf>(item);
115 return (_oneOfList == install->_oneOfList) ? 0 : -1; // more evaluation would be not useful
119 //---------------------------------------------------------------------------
122 ///////////////////////////////////////////////////////////////////
123 };// namespace detail
124 /////////////////////////////////////////////////////////////////////
125 /////////////////////////////////////////////////////////////////////
126 };// namespace solver
127 ///////////////////////////////////////////////////////////////////////
128 ///////////////////////////////////////////////////////////////////////
130 /////////////////////////////////////////////////////////////////////////