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 #include "zypp/base/Logger.h"
26 #include "zypp/solver/detail/SolverQueueItemInstallOneOf.h"
27 #include "zypp/sat/Pool.h"
29 /////////////////////////////////////////////////////////////////////////
31 { ///////////////////////////////////////////////////////////////////////
32 ///////////////////////////////////////////////////////////////////////
34 { /////////////////////////////////////////////////////////////////////
35 /////////////////////////////////////////////////////////////////////
37 { ///////////////////////////////////////////////////////////////////
41 IMPL_PTR_TYPE(SolverQueueItemInstallOneOf);
43 //---------------------------------------------------------------------------
46 SolverQueueItemInstallOneOf::dumpOn( std::ostream & os ) const
48 os << "[" << (_soft?"Soft":"") << "InstallOneOf: ";
49 for (PoolItemList::const_iterator iter = _oneOfList.begin();
50 iter != _oneOfList.end();
58 //---------------------------------------------------------------------------
60 SolverQueueItemInstallOneOf::SolverQueueItemInstallOneOf (const ResPool & pool, const PoolItemList & itemList,
62 : SolverQueueItem (QUEUE_ITEM_TYPE_INSTALL_ONE_OF, pool)
63 , _oneOfList (itemList)
69 SolverQueueItemInstallOneOf::~SolverQueueItemInstallOneOf()
73 //---------------------------------------------------------------------------
75 bool SolverQueueItemInstallOneOf::addRule (sat::detail::CQueue & q)
78 MIL << "Install one of " << (_soft ? "(soft):" : ":")<< endl;
82 queue_push( &(q), SOLVER_INSTALL | SOLVER_SOLVABLE_ONE_OF | SOLVER_WEAK);
84 queue_push( &(q), SOLVER_INSTALL | SOLVER_SOLVABLE_ONE_OF );
88 for (PoolItemList::const_iterator iter = _oneOfList.begin(); iter != _oneOfList.end(); iter++) {
89 Id id = (*iter)->satSolvable().id();
91 ERR << *iter << " not found" << endl;
94 MIL << " candidate:" << *iter << " with the SAT-Pool ID: " << id << endl;
95 queue_push( &(qs), id );
98 sat::Pool satPool( sat::Pool::instance() );
99 queue_push( &(q), pool_queuetowhatprovides(satPool.get(), &qs));
106 SolverQueueItemInstallOneOf::copy (void) const
108 SolverQueueItemInstallOneOf_Ptr new_installOneOf = new SolverQueueItemInstallOneOf (pool(), _oneOfList);
109 new_installOneOf->SolverQueueItem::copy(this);
110 new_installOneOf->_soft = _soft;
112 return new_installOneOf;
116 SolverQueueItemInstallOneOf::cmp (SolverQueueItem_constPtr item) const
118 int cmp = this->compare (item);
121 SolverQueueItemInstallOneOf_constPtr install = dynamic_pointer_cast<const SolverQueueItemInstallOneOf>(item);
123 return (_oneOfList == install->_oneOfList) ? 0 : -1; // more evaluation would be not useful
127 //---------------------------------------------------------------------------
130 ///////////////////////////////////////////////////////////////////
131 };// namespace detail
132 /////////////////////////////////////////////////////////////////////
133 /////////////////////////////////////////////////////////////////////
134 };// namespace solver
135 ///////////////////////////////////////////////////////////////////////
136 ///////////////////////////////////////////////////////////////////////
138 /////////////////////////////////////////////////////////////////////////