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 << "[" << "InstallOneOf: ";
45 for (PoolItemList::const_iterator iter = _oneOfList.begin();
46 iter != _oneOfList.end();
54 //---------------------------------------------------------------------------
56 SolverQueueItemInstallOneOf::SolverQueueItemInstallOneOf (const ResPool & pool, const PoolItemList & itemList)
57 : SolverQueueItem (QUEUE_ITEM_TYPE_INSTALL_ONE_OF, pool)
58 , _oneOfList (itemList)
63 SolverQueueItemInstallOneOf::~SolverQueueItemInstallOneOf()
67 //---------------------------------------------------------------------------
69 bool SolverQueueItemInstallOneOf::addRule (_Queue & q)
72 MIL << "Install one of: " << endl;
73 queue_push( &(q), SOLVER_INSTALL_SOLVABLE_ONE_OF );
74 for (PoolItemList::const_iterator iter = _oneOfList.begin(); iter != _oneOfList.end(); iter++) {
75 Id id = (*iter)->satSolvable().id();
77 ERR << *iter << " not found" << endl;
80 MIL << " candidate:" << *iter << " with the SAT-Pool ID: " << id << endl;
81 queue_push( &(q), id );
84 queue_push( &(q), 0 ); // finish candidate
90 SolverQueueItemInstallOneOf::copy (void) const
92 SolverQueueItemInstallOneOf_Ptr new_installOneOf = new SolverQueueItemInstallOneOf (pool(), _oneOfList);
93 new_installOneOf->SolverQueueItem::copy(this);
95 return new_installOneOf;
99 SolverQueueItemInstallOneOf::cmp (SolverQueueItem_constPtr item) const
101 int cmp = this->compare (item);
104 SolverQueueItemInstallOneOf_constPtr install = dynamic_pointer_cast<const SolverQueueItemInstallOneOf>(item);
106 return (_oneOfList == install->_oneOfList) ? 0 : -1; // more evaluation would be not useful
110 //---------------------------------------------------------------------------
113 ///////////////////////////////////////////////////////////////////
114 };// namespace detail
115 /////////////////////////////////////////////////////////////////////
116 /////////////////////////////////////////////////////////////////////
117 };// namespace solver
118 ///////////////////////////////////////////////////////////////////////
119 ///////////////////////////////////////////////////////////////////////
121 /////////////////////////////////////////////////////////////////////////