resolvePool()
[platform/upstream/libzypp.git] / zypp / solver / detail / Resolver.h
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
2 /* Resolver.h
3  *
4  * Copyright (C) 2000-2002 Ximian, Inc.
5  * Copyright (C) 2005 SUSE Linux Products GmbH
6  *
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.
10  *
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.
15  *
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
19  * 02111-1307, USA.
20  */
21
22 #ifndef ZYPP_SOLVER_DETAIL_RESOLVER_H
23 #define ZYPP_SOLVER_DETAIL_RESOLVER_H
24
25 #include <iosfwd>
26 #include <list>
27 #include <string>
28
29 #include "zypp/base/ReferenceCounted.h"
30 #include "zypp/base/PtrTypes.h"
31
32 #include "zypp/ResPool.h"
33
34 #include "zypp/solver/detail/Types.h"
35 #include "zypp/solver/detail/ResolverQueue.h"
36 #include "zypp/solver/detail/ResolverContext.h"
37
38 #include "zypp/CapSet.h"
39
40 /////////////////////////////////////////////////////////////////////////
41 namespace zypp
42 { ///////////////////////////////////////////////////////////////////////
43   ///////////////////////////////////////////////////////////////////////
44   namespace solver
45   { /////////////////////////////////////////////////////////////////////
46     /////////////////////////////////////////////////////////////////////
47     namespace detail
48     { ///////////////////////////////////////////////////////////////////
49
50 ///////////////////////////////////////////////////////////////////
51 //
52 //      CLASS NAME : Resolver
53
54 class Resolver : public base::ReferenceCounted, private base::NonCopyable {
55
56   private:
57     ResPool _pool;
58
59     int _timeout_seconds;
60     bool _verifying;
61
62     QueueItemList _initial_items;
63     PoolItemList _items_to_install;
64     PoolItemList _items_to_establish;
65     PoolItemList _items_to_remove;
66     PoolItemList _items_to_verify;
67
68     CapSet _extra_caps;
69     CapSet _extra_conflicts;
70
71     ResolverQueueList _pending_queues;
72     ResolverQueueList _pruned_queues;
73     ResolverQueueList _complete_queues;
74     ResolverQueueList _deferred_queues;
75     ResolverQueueList _invalid_queues;
76
77     int _valid_solution_count;
78
79     ResolverContext_Ptr _best_context;
80     bool _timed_out;
81
82   public:
83
84     Resolver (const ResPool & pool);
85     virtual ~Resolver();
86
87     // ---------------------------------- I/O
88
89     friend std::ostream& operator<<(std::ostream&, const Resolver &resolver);
90
91     // ---------------------------------- accessors
92
93     QueueItemList initialItems () const { return _initial_items; }
94
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; }
100
101     ResolverContext_Ptr bestContext (void) const { return _best_context; }
102
103     // ---------------------------------- methods
104
105     void setTimeout (int seconds) { _timeout_seconds = seconds; }
106
107     ResPool pool (void) const;
108     void setPool (const ResPool & pool) { _pool = pool; }
109
110 //    void setCurrentChannel (Channel_constPtr channel) { _current_channel = channel; }
111 //    void addSubscribedChannel (Channel_constPtr channel);
112
113     void addPoolItemToInstall (PoolItem_Ref item);
114     void addPoolItemsToInstallFromList (PoolItemList & rl);
115
116     void addPoolItemToRemove (PoolItem_Ref item);
117     void addPoolItemsToRemoveFromList (PoolItemList & rl);
118
119     void addPoolItemToEstablish (PoolItem_Ref item);
120     void addPoolItemsToEstablishFromList (PoolItemList & rl);
121
122     void addPoolItemToVerify (PoolItem_Ref item);
123
124     void addExtraCapability (const Capability & capability);
125     void addExtraConflict (const Capability & capability);
126
127     void verifySystem (void);
128     void establishState (const ResolverContext_Ptr context = NULL);
129     bool resolveDependencies (const ResolverContext_Ptr context = NULL);
130     bool resolvePool (void);
131
132     ResolverProblemList problems (void) const;
133     bool applySolutions (const ProblemSolutionList &solutions);
134
135     void reset (void);
136 };
137
138 ///////////////////////////////////////////////////////////////////
139     };// namespace detail
140     /////////////////////////////////////////////////////////////////////
141     /////////////////////////////////////////////////////////////////////
142   };// namespace solver
143   ///////////////////////////////////////////////////////////////////////
144   ///////////////////////////////////////////////////////////////////////
145 };// namespace zypp
146 /////////////////////////////////////////////////////////////////////////
147
148 #endif // ZYPP_SOLVER_DETAIL_RESOLVER_H