Imported Upstream version 16.3.2
[platform/upstream/libzypp.git] / zypp / ProblemSolution.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_PROBLEMSOLUTION_H
10 #define ZYPP_PROBLEMSOLUTION_H
11
12 #include <list>
13 #include <string>
14
15 #include "zypp/ProblemTypes.h"
16 #include "zypp/ResolverProblem.h"
17
18 /////////////////////////////////////////////////////////////////////////
19 namespace zypp
20 {
21   /////////////////////////////////////////////////////////////////////////
22   /// \class ProblemSolution
23   /// \brief Class representing one possible solution to a problem found during resolving
24   ///
25   /// All problems should have at least 2-3 (mutually exclusive) solutions:
26   ///
27   ///    -       Undo: Do not perform the offending transaction
28   ///    (do not install the package that had unsatisfied requirements,
29   ///     do not remove  the package that would break other packages' requirements)
30   ///
31   ///    - Remove referrers: Remove all packages that would break because
32   ///   they depend on the package that is requested to be removed
33   ///
34   ///    - Ignore: Inject artificial "provides" for a missing requirement
35   ///   (pretend that requirement is satisfied)
36   /////////////////////////////////////////////////////////////////////////
37   class ProblemSolution : public base::ReferenceCounted
38   {
39   public:
40     typedef solver::detail::SolutionAction_Ptr SolutionAction_Ptr;
41     typedef solver::detail::SolutionActionList SolutionActionList;
42
43     /** Constructor. */
44     ProblemSolution();
45
46     /** Constructor. */
47     ProblemSolution( std::string description );
48
49     /** Constructor. */
50     ProblemSolution( std::string description, std::string details );
51
52    /** Destructor. */
53     virtual ~ProblemSolution();
54
55
56     /**
57      * Return a one-line text description of this solution.
58      **/
59     const std::string & description() const;
60
61     /**
62      * Return a (possibly multi-line) detailed description of this
63      * solution or an empty string if there are no useful details.
64      **/
65     const std::string & details() const;
66
67     /**
68      * Return the list of actions forming this solution.
69      **/
70     const SolutionActionList & actions() const;
71
72     /**
73      * Set description of the solution.
74      **/
75     void setDescription( std::string description );
76
77     /**
78      * Set detail description of the solution.
79      **/
80     void setDetails( std::string details );
81
82     /**
83      * Collect multiple action descriptions in \ref details (NL separated)
84      **/
85     void pushDescriptionDetail( std::string description, bool front = false );
86
87
88     /**
89      * Add an action to the actions list.
90      **/
91     void addAction( SolutionAction_Ptr action );
92
93
94   private:
95     class Impl;
96     RWCOW_pointer<Impl> _pimpl;
97   };
98
99   /** \relates ProblemSolution Stream output */
100   std::ostream& operator<<(std::ostream&, const ProblemSolution & obj );
101
102   /** \relates ProblemSolution Stream output */
103   std::ostream& operator<<(std::ostream&, const ProblemSolutionList & obj );
104
105 } // namespace zypp
106 /////////////////////////////////////////////////////////////////////////
107 #endif // ZYPP_PROBLEMSOLUTION_H
108