1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
4 * Copyright (C) 2000-2002 Ximian, Inc.
5 * Copyright (C) 2005 SUSE Linux Products GmbH
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License,
9 * version 2, as published by the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
22 #ifndef ZYPP_SOLVER_DETAIL_RESOLVER_H
23 #define ZYPP_SOLVER_DETAIL_RESOLVER_H
29 #include "zypp/base/ReferenceCounted.h"
30 #include "zypp/base/PtrTypes.h"
32 #include "zypp/ResPool.h"
34 #include "zypp/solver/detail/Types.h"
35 #include "zypp/solver/detail/ResolverQueue.h"
36 #include "zypp/solver/detail/ResolverContext.h"
38 #include "zypp/CapSet.h"
40 /////////////////////////////////////////////////////////////////////////
42 { ///////////////////////////////////////////////////////////////////////
43 ///////////////////////////////////////////////////////////////////////
45 { /////////////////////////////////////////////////////////////////////
46 /////////////////////////////////////////////////////////////////////
48 { ///////////////////////////////////////////////////////////////////
50 ///////////////////////////////////////////////////////////////////
52 // CLASS NAME : Resolver
54 class Resolver : public base::ReferenceCounted, private base::NonCopyable {
62 QueueItemList _initial_items;
63 PoolItemList _items_to_install;
64 PoolItemList _items_to_establish;
65 PoolItemList _items_to_remove;
66 PoolItemList _items_to_verify;
69 CapSet _extra_conflicts;
71 ResolverQueueList _pending_queues;
72 ResolverQueueList _pruned_queues;
73 ResolverQueueList _complete_queues;
74 ResolverQueueList _deferred_queues;
75 ResolverQueueList _invalid_queues;
77 int _valid_solution_count;
79 ResolverContext_Ptr _best_context;
84 Resolver (const ResPool & pool);
87 // ---------------------------------- I/O
89 friend std::ostream& operator<<(std::ostream&, const Resolver &resolver);
91 // ---------------------------------- accessors
93 QueueItemList initialItems () const { return _initial_items; }
95 ResolverQueueList pendingQueues () const { return _pending_queues; }
96 ResolverQueueList prunedQueues () const { return _pruned_queues; }
97 ResolverQueueList completeQueues () const { return _complete_queues; }
98 ResolverQueueList deferredQueues () const { return _deferred_queues; }
99 ResolverQueueList invalidQueues () const { return _invalid_queues; }
101 ResolverContext_Ptr bestContext (void) const { return _best_context; }
103 // ---------------------------------- methods
105 void setTimeout (int seconds) { _timeout_seconds = seconds; }
107 ResPool pool (void) const;
108 void setPool (const ResPool & pool) { _pool = pool; }
110 // void setCurrentChannel (Channel_constPtr channel) { _current_channel = channel; }
111 // void addSubscribedChannel (Channel_constPtr channel);
113 void addPoolItemToInstall (PoolItem_Ref item);
114 void addPoolItemsToInstallFromList (PoolItemList & rl);
116 void addPoolItemToRemove (PoolItem_Ref item);
117 void addPoolItemsToRemoveFromList (PoolItemList & rl);
119 void addPoolItemToEstablish (PoolItem_Ref item);
120 void addPoolItemsToEstablishFromList (PoolItemList & rl);
122 void addPoolItemToVerify (PoolItem_Ref item);
124 void addExtraCapability (const Capability & capability);
125 void addExtraConflict (const Capability & capability);
127 void verifySystem (void);
128 void establishState (const ResolverContext_Ptr context = NULL);
129 bool resolveDependencies (const ResolverContext_Ptr context = NULL);
130 bool resolvePool (void);
132 ResolverProblemList problems (void) const;
133 bool applySolutions (const ProblemSolutionList &solutions);
138 ///////////////////////////////////////////////////////////////////
139 };// namespace detail
140 /////////////////////////////////////////////////////////////////////
141 /////////////////////////////////////////////////////////////////////
142 };// namespace solver
143 ///////////////////////////////////////////////////////////////////////
144 ///////////////////////////////////////////////////////////////////////
146 /////////////////////////////////////////////////////////////////////////
148 #endif // ZYPP_SOLVER_DETAIL_RESOLVER_H