Imported Upstream version 16.3.2
[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/ProblemTypes.h"
16 #include "zypp/ProblemSolution.h"
17
18 /////////////////////////////////////////////////////////////////////////
19 namespace zypp
20 {
21   ///////////////////////////////////////////////////////////////////////
22   /// \class ResolverProblem
23   /// \brief Describe a solver problem and offer solutions.
24   ///////////////////////////////////////////////////////////////////////
25   class ResolverProblem : public base::ReferenceCounted
26   {
27   public:
28     /** Constructor. */
29     ResolverProblem();
30     /** Constructor. */
31     ResolverProblem( std::string description );
32     /** Constructor. */
33     ResolverProblem( std::string description, std::string details );
34
35     /** Destructor. */
36     ~ResolverProblem();
37
38
39     /**
40      * Return a one-line description of the problem.
41      **/
42     const std::string & description() const;
43
44     /**
45      * Return a (possibly muti-line) detailed description of the problem
46      * or an empty string if there are no useful details.
47      **/
48     const std::string & details() const;
49
50     /**
51      * Return the possible solutions to this problem.
52      * All problems should have at least 2-3 (mutually exclusive) solutions:
53      *
54      *    -  Undo: Do not perform the offending transaction
55      *   (do not install the package that had unsatisfied requirements,
56      *    do not remove  the package that would break other packages' requirements)
57      *
58      *    - Remove referrers: Remove all packages that would break because
59      *  they depend on the package that is requested to be removed
60      *
61      *    - Ignore: Inject artificial "provides" for a missing requirement
62      *  (pretend that requirement is satisfied)
63      **/
64     const ProblemSolutionList & solutions() const;
65
66
67     /**
68      * Set description of the problem.
69      **/
70     void setDescription( std::string description );
71
72     /**
73      * Set detail description of the problem.
74      **/
75     void setDetails( std::string details );
76
77     /**
78      * Add a solution to this problem. This class takes over ownership of
79      * the problem and will delete it when neccessary.
80      **/
81     void addSolution( ProblemSolution_Ptr solution, bool inFront = false );
82
83   private:
84     class Impl;
85     RWCOW_pointer<Impl> _pimpl;
86   };
87
88   /** \relates ResolverProblem Stream output */
89   std::ostream & operator<<( std::ostream &, const ResolverProblem & obj );
90
91   /** \relates ResolverProblem Stream output */
92   std::ostream & operator<<( std::ostream &, const ResolverProblemList & obj );
93
94
95 } // namespace zypp
96 /////////////////////////////////////////////////////////////////////////
97 #endif // ZYPP_RESOLVERPROBLEM_H
98