description added
[platform/upstream/libzypp.git] / zypp / Resolver.h
1 /*---------------------------------------------------------------------\
2 |                          ____ _   __ __ ___                          |
3 |                         |__  / \ / / . \ . \                         |
4 |                           / / \ V /|  _/  _/                         |
5 |                          / /__ | | | | | |                           |
6 |                         /_____||_| |_| |_|                           |
7 |                                                                      |
8 \---------------------------------------------------------------------*/
9 /** \file       zypp/Resolver.h
10  *
11 */
12 #ifndef ZYPP_RESOLVER_H
13 #define ZYPP_RESOLVER_H
14
15 #include <iosfwd>
16 #include <functional>
17
18 #include "zypp/base/ReferenceCounted.h"
19 #include "zypp/base/PtrTypes.h"
20
21 #include "zypp/ResPool.h"
22 #include "zypp/UpgradeStatistics.h"
23 #include "zypp/solver/detail/Resolver.h"
24 #include "zypp/solver/detail/ResolverContext.h"
25 #include "zypp/ProblemTypes.h"
26
27 ///////////////////////////////////////////////////////////////////
28 namespace zypp
29 { /////////////////////////////////////////////////////////////////
30
31
32
33   ///////////////////////////////////////////////////////////////////
34   //
35   //    CLASS NAME : Resolver
36   //
37   /** Resolver interface.
38   */
39   class Resolver : public base::ReferenceCounted, private base::NonCopyable
40   {
41   public:
42
43     /** Ctor */
44     Resolver( const ResPool & pool );
45     /** Dtor */
46     virtual ~Resolver();
47
48     /**
49      * Resolve package dependencies:
50      *
51      * Verify consistency of system
52      *
53      **/
54     bool verifySystem (void);
55
56     /**
57      * Establish state of 'higher level' Resolvables in Pool
58      *
59      * Must be called when dealing with non-package resolvables,
60      * like Patches, Patterns, and Products
61      *
62      * Must be called with a 'plain' pool, e.g. no additonal
63      * transacts set.
64      *
65      * return true if it was successful
66      * return false if not (this will only happen if other
67      *   transactions are in the pool which will lead to
68      *   no solution)
69      **/
70     bool establishPool (void);
71
72     /**
73      * Resolve package dependencies:
74      *
75      * Try to execute all pending transactions (there may be more than
76      * one!).
77      *
78      * Returns "true" on success (i.e., if there were no problems that
79      * need user interaction) and "false" if there were problems.  In
80      * the latter case, use problems() and later applySolutions()
81      * below.
82      **/
83     bool resolvePool (void);
84
85     /*
86      * Undo solver changes done in resolvePool()
87      * Throwing away all ignored dependencies.
88      */
89     void undo( void );
90
91     /*
92      * Get the most recent resolver context
93      *
94      * It will be NULL if resolvePool() or establishPool() was never called.
95      * Depending on the return code of the last resolvePool() call,
96      * it _either_ points to a valid or an invalid solution.
97      */
98     solver::detail::ResolverContext_Ptr context (void) const;
99
100     /**
101      * Do an distribution upgrade
102      *
103      * This will run a full upgrade on the pool, taking all upgrade
104      * dependencies (provide/obsolete for package renames, split-
105      * provides, etc.) into account and actually removing installed
106      * packages if no upgrade exists.
107      *
108      * To be run with great caution. It basically brings your
109      * system 'back to start'.
110      * Quite helpful to get back to a 'sane state'. Quite disastrous
111      * since you'll loose all non-distribution packages
112      **/
113     void doUpgrade( UpgradeStatistics & opt_stats_r );
114
115     /**
116      * Return the dependency problems found by the last call to
117      * resolveDependencies(). If there were no problems, the returned
118      * list will be empty.
119      **/
120     ResolverProblemList problems();
121
122     /**
123      * Apply problem solutions. No more than one solution per problem
124      * can be applied.
125      **/
126     void applySolutions( const ProblemSolutionList & solutions );
127
128     Arch architecture() const;
129     void setArchitecture( const Arch & arch);
130
131     /**      
132      * Remove resolvables which are conflicts with others or
133      * have unfulfilled requirements.
134      * This behaviour is favourited by ZMD.
135      **/
136     void setForceResolve (const bool force);
137     const bool forceResolve();
138
139     /**
140      * transact a single ResObject
141      *
142      * Installs (install == true) or removes (install == false) all required
143      * and recommended packages(!) of \c robj
144      * (More or less a 'single step' resolver call
145      *
146      * returns false if requirements are not all fulfillable
147      *
148      */
149     bool transactResObject( ResObject::constPtr robj, bool install = true);
150
151   protected:
152
153   private:
154     solver::detail::Resolver_Ptr _pimpl;
155   };
156   ///////////////////////////////////////////////////////////////////
157
158   /////////////////////////////////////////////////////////////////
159 } // namespace zypp
160 ///////////////////////////////////////////////////////////////////
161 #endif // ZYPP_RESOLVER_H