92f52adcdb2a2416914db4e56b37bddb299dc2c6
[platform/upstream/libzypp.git] / zypp / ResolverProblem.h
1 /*
2  *
3  * Easy-to use interface to the ZYPP dependency resolver
4  *
5  * Author: Stefan Hundhammer <sh@suse.de>
6  *
7  **/
8
9 #ifndef ZYPP_RESOLVERPROBLEM_H
10 #define ZYPP_RESOLVERPROBLEM_H
11
12 #include <list>
13 #include <string>
14
15 #include "zypp/base/ReferenceCounted.h"
16 #include "zypp/base/PtrTypes.h"
17 #include "zypp/ProblemSolution.h"
18
19 /////////////////////////////////////////////////////////////////////////
20 namespace zypp
21 { ///////////////////////////////////////////////////////////////////////
22
23
24     class ResolverProblem : public base::ReferenceCounted
25     {
26     private:
27
28         /**
29          * Clear all data.
30          * In particular, delete all members of _solutions.
31          **/
32         void clear();
33
34
35         //
36         // Data members
37         //
38
39         Resolver_constPtr       _resolver;
40         std::string             _description;
41         std::string             _details;
42         ProblemSolutionList     _solutions;
43
44     public:
45
46         /**
47          * Constructor.
48          **/
49         ResolverProblem( const std::string & description, const std::string & details );
50
51         /**
52          * Destructor.
53          **/
54         ~ResolverProblem();
55
56         // ---------------------------------- I/O
57
58         friend std::ostream& operator<<(std::ostream&, const ResolverProblem & problem);
59
60         // ---------------------------------- accessors
61
62         /**
63          * Return a one-line description of the problem.
64          **/
65         std::string description() const { return _description; }
66
67         /**
68          * Return a (possibly muti-line) detailed description of the problem
69          * or an empty string if there are no useful details.
70          **/
71         std::string details() const { return _details; }
72
73         /**
74          * Set description of the problem.
75          **/
76         void setDescription(const std::string & description)
77             { _description=description; }
78
79         /**
80          * Set detail description of the problem.
81          **/
82         void setDetails(const std::string & detail)
83             { _details=detail; }
84
85         /**
86          * Return the possible solutions to this problem.
87          * All problems should have at least 2-3 (mutually exclusive) solutions:
88          *
89          *        -  Undo: Do not perform the offending transaction
90          *       (do not install the package that had unsatisfied requirements,
91          *        do not remove  the package that would break other packages' requirements)
92          *
93          *        - Remove referrers: Remove all packages that would break because
94          *      they depend on the package that is requested to be removed
95          *
96          *        - Ignore: Inject artificial "provides" for a missing requirement
97          *      (pretend that requirement is satisfied)
98          **/
99         ProblemSolutionList solutions() const;
100
101         /**
102          * Return the parent dependency resolver.
103          **/
104         Resolver_constPtr resolver() const { return _resolver; }
105
106         // ---------------------------------- methods
107
108         /**
109          * Add a solution to this problem. This class takes over ownership of
110          * the problem and will delete it when neccessary.
111          **/
112         void addSolution( ProblemSolution_Ptr solution, bool inFront = false );
113
114     };
115     ///////////////////////////////////////////////////////////////////////
116 };// namespace zypp
117 /////////////////////////////////////////////////////////////////////////
118
119 #endif // ZYPP_RESOLVERPROBLEM_H
120