3 * Easy-to use interface to the ZYPP dependency resolver
5 * Author: Stefan Hundhammer <sh@suse.de>
9 #ifndef ZYPP_SOLVER_DETAIL_SOLUTIONACTION_H
10 #define ZYPP_SOLVER_DETAIL_SOLUTIONACTION_H
15 #include "zypp/base/ReferenceCounted.h"
16 #include "zypp/base/PtrTypes.h"
18 #include "zypp/Capability.h"
19 #include "zypp/solver/detail/Resolver.h"
20 #include "zypp/solver/detail/ProblemSolutionPtr.h"
21 #include "zypp/solver/detail/ResolverProblemPtr.h"
22 #include "zypp/solver/detail/SolutionActionPtr.h"
24 /////////////////////////////////////////////////////////////////////////
26 { ///////////////////////////////////////////////////////////////////////
27 ///////////////////////////////////////////////////////////////////////
29 { /////////////////////////////////////////////////////////////////////
30 /////////////////////////////////////////////////////////////////////
32 { ///////////////////////////////////////////////////////////////////
35 * Abstract base class for one action of a problem solution.
37 class SolutionAction : public base::ReferenceCounted
41 virtual ~SolutionAction();
43 // ---------------------------------- I/O
45 static std::string toString (const SolutionAction & action);
46 static std::string toString (const SolutionActionList & actionlist);
47 static std::string toString (const CSolutionActionList & actionlist);
49 virtual std::ostream & dumpOn(std::ostream & str ) const = 0;
51 friend std::ostream& operator<<(std::ostream&, const SolutionAction & action);
53 virtual std::string asString (void) const = 0;
55 // ---------------------------------- methods
57 * Execute this action.
58 * Returns 'true' on success, 'false' on error.
60 virtual bool execute() = 0;
65 * A problem solution action that performs a transaction
66 * (installs, updates, removes, ...) one resolvable
67 * (package, patch, pattern, product).
69 class TransactionSolutionAction: public SolutionAction
75 // TO DO: use some already existing enum (?)
83 TransactionSolutionAction( ResItem_constPtr resolvable,
84 TransactionKind action )
85 : SolutionAction(), _resolvable( resolvable ), _action( action ) {}
87 // ---------------------------------- I/O
89 static std::string toString (const TransactionSolutionAction & action);
91 virtual std::ostream & dumpOn(std::ostream & str ) const;
93 friend std::ostream& operator<<(std::ostream&, const TransactionSolutionAction & action);
95 std::string asString (void) const;
97 // ---------------------------------- accessors
98 ResItem_constPtr resolvable() const { return _resolvable; }
99 TransactionKind action() const { return _action; }
101 // ---------------------------------- methods
102 virtual bool execute();
107 ResItem_constPtr _resolvable;
108 TransactionKind _action;
113 * A problem solution action that injects an artificial "provides" to
114 * the pool to satisfy open requirements or remove the conflict of
115 * concerning resolvable
117 * This is typically used by "ignore" (user override) solutions.
119 class InjectSolutionAction: public SolutionAction
129 InjectSolutionAction( const Capability & capability, const CapabilityKind & kind )
130 : SolutionAction(), _capability( capability ), _kind( kind ) {}
132 // ---------------------------------- I/O
134 static std::string toString (const InjectSolutionAction & action);
136 virtual std::ostream & dumpOn(std::ostream & str ) const;
138 friend std::ostream& operator<<(std::ostream&, const InjectSolutionAction & action);
140 std::string asString (void) const;
142 // ---------------------------------- accessors
143 const Capability & capability() const { return _capability; };
145 // ---------------------------------- methods
146 virtual bool execute();
150 const Capability & _capability;
151 const CapabilityKind & _kind;
155 ///////////////////////////////////////////////////////////////////
156 };// namespace detail
157 /////////////////////////////////////////////////////////////////////
158 /////////////////////////////////////////////////////////////////////
159 };// namespace solver
160 ///////////////////////////////////////////////////////////////////////
161 ///////////////////////////////////////////////////////////////////////
163 /////////////////////////////////////////////////////////////////////////
165 #endif // ZYPP_SOLVER_DETAIL_SOLUTIONACTION_H