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
22 #include <solv/solver.h>
25 #define ZYPP_USE_RESOLVER_INTERNALS
27 #include "zypp/base/Logger.h"
28 #include "zypp/solver/detail/SolverQueueItemInstallOneOf.h"
29 #include "zypp/sat/Pool.h"
31 /////////////////////////////////////////////////////////////////////////
33 { ///////////////////////////////////////////////////////////////////////
34 ///////////////////////////////////////////////////////////////////////
36 { /////////////////////////////////////////////////////////////////////
37 /////////////////////////////////////////////////////////////////////
39 { ///////////////////////////////////////////////////////////////////
43 IMPL_PTR_TYPE(SolverQueueItemInstallOneOf);
45 //---------------------------------------------------------------------------
48 SolverQueueItemInstallOneOf::dumpOn( std::ostream & os ) const
50 os << "[" << (_soft?"Soft":"") << "InstallOneOf: ";
51 for (PoolItemList::const_iterator iter = _oneOfList.begin();
52 iter != _oneOfList.end();
60 //---------------------------------------------------------------------------
62 SolverQueueItemInstallOneOf::SolverQueueItemInstallOneOf (const ResPool & pool, const PoolItemList & itemList,
64 : SolverQueueItem (QUEUE_ITEM_TYPE_INSTALL_ONE_OF, pool)
65 , _oneOfList (itemList)
71 SolverQueueItemInstallOneOf::~SolverQueueItemInstallOneOf()
75 //---------------------------------------------------------------------------
77 bool SolverQueueItemInstallOneOf::addRule (sat::detail::CQueue & q)
80 MIL << "Install one of " << (_soft ? "(soft):" : ":")<< endl;
84 queue_push( &(q), SOLVER_INSTALL | SOLVER_SOLVABLE_ONE_OF | SOLVER_WEAK);
86 queue_push( &(q), SOLVER_INSTALL | SOLVER_SOLVABLE_ONE_OF );
90 for (PoolItemList::const_iterator iter = _oneOfList.begin(); iter != _oneOfList.end(); iter++) {
91 Id id = (*iter)->satSolvable().id();
93 ERR << *iter << " not found" << endl;
96 MIL << " candidate:" << *iter << " with the SAT-Pool ID: " << id << endl;
97 queue_push( &(qs), id );
100 sat::Pool satPool( sat::Pool::instance() );
101 queue_push( &(q), pool_queuetowhatprovides(satPool.get(), &qs));
108 SolverQueueItemInstallOneOf::copy (void) const
110 SolverQueueItemInstallOneOf_Ptr new_installOneOf = new SolverQueueItemInstallOneOf (pool(), _oneOfList);
111 new_installOneOf->SolverQueueItem::copy(this);
112 new_installOneOf->_soft = _soft;
114 return new_installOneOf;
118 SolverQueueItemInstallOneOf::cmp (SolverQueueItem_constPtr item) const
120 int cmp = this->compare (item);
123 SolverQueueItemInstallOneOf_constPtr install = dynamic_pointer_cast<const SolverQueueItemInstallOneOf>(item);
125 return (_oneOfList == install->_oneOfList) ? 0 : -1; // more evaluation would be not useful
129 //---------------------------------------------------------------------------
132 ///////////////////////////////////////////////////////////////////
133 };// namespace detail
134 /////////////////////////////////////////////////////////////////////
135 /////////////////////////////////////////////////////////////////////
136 };// namespace solver
137 ///////////////////////////////////////////////////////////////////////
138 ///////////////////////////////////////////////////////////////////////
140 /////////////////////////////////////////////////////////////////////////