cleanup in ignore dependencies
[platform/upstream/libzypp.git] / zypp / solver / detail / SolutionAction.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_SOLVER_DETAIL_SOLUTIONACTION_H
10 #define ZYPP_SOLVER_DETAIL_SOLUTIONACTION_H
11
12 #include <list>
13 #include <string>
14
15 #include "zypp/base/ReferenceCounted.h"
16 #include "zypp/base/PtrTypes.h"
17
18 #include "zypp/Dep.h"
19 #include "zypp/Capability.h"
20
21 #include "zypp/solver/detail/Types.h"
22 #include "zypp/solver/detail/Resolver.h"
23
24 /////////////////////////////////////////////////////////////////////////
25 namespace zypp
26 { ///////////////////////////////////////////////////////////////////////
27   ///////////////////////////////////////////////////////////////////////
28   namespace solver
29   { /////////////////////////////////////////////////////////////////////
30     /////////////////////////////////////////////////////////////////////
31     namespace detail
32     { ///////////////////////////////////////////////////////////////////
33
34         /**
35          * Abstract base class for one action of a problem solution.
36          **/
37         class SolutionAction : public base::ReferenceCounted
38         {
39         protected:
40             SolutionAction ();
41         public:
42             virtual ~SolutionAction();
43
44             // ---------------------------------- I/O
45             virtual std::ostream & dumpOn( std::ostream & str ) const;
46             friend std::ostream& operator<<(std::ostream & str, const SolutionAction & action)
47                 { return action.dumpOn (str); }
48             friend std::ostream& operator<<(std::ostream & str, const SolutionActionList & actionlist);
49             friend std::ostream& operator<<(std::ostream & str, const CSolutionActionList & actionlist);
50
51             // ---------------------------------- methods
52             /**
53              * Execute this action.
54              * Returns 'true' on success, 'false' on error.
55              **/
56             virtual bool execute (Resolver & resolver) const = 0;
57         };
58
59
60         /**
61          * A problem solution action that performs a transaction
62          * (installs, removes, keep ...)  one resolvable
63          * (package, patch, pattern, product).
64          **/
65         typedef enum
66         {
67             KEEP,
68             INSTALL,
69             REMOVE,
70             UNLOCK
71         } TransactionKind;
72
73
74         class TransactionSolutionAction: public SolutionAction
75         {
76         public:
77             TransactionSolutionAction( PoolItem item,
78                                        TransactionKind action )
79                 : SolutionAction(),
80                   _item( item ), _action( action ) {}
81
82             TransactionSolutionAction( TransactionKind action )
83                 : SolutionAction(),
84                   _item(), _action( action ) {}
85
86           // ---------------------------------- I/O
87           virtual std::ostream & dumpOn( std::ostream & str ) const;
88           friend std::ostream& operator<<(std::ostream& str, const TransactionSolutionAction & action)
89                 { return action.dumpOn (str); }
90
91           // ---------------------------------- accessors
92
93           const PoolItem item() const { return _item; }
94           TransactionKind action() const { return _action; }
95
96           // ---------------------------------- methods
97             virtual bool execute(Resolver & resolver) const;
98
99         protected:
100
101             PoolItem _item;
102             const TransactionKind _action;
103         };
104
105
106         /**
107          * Type of ignoring; currently only WEAK
108          **/
109
110         typedef enum
111         {
112             WEAK
113         } InjectSolutionKind;
114
115
116         /**
117          * A problem solution action that injects an artificial "provides" to
118          * the pool to satisfy open requirements or remove the conflict of
119          * concerning resolvable
120          *
121          * This is typically used by "ignore" (user override) solutions.
122          **/
123         class InjectSolutionAction: public SolutionAction
124         {
125         public:
126
127             InjectSolutionAction( PoolItem item,
128                                   const InjectSolutionKind & kind)
129                 : SolutionAction(),
130                   _item( item ), 
131                   _kind( kind ) {}
132
133           // ---------------------------------- I/O
134           virtual std::ostream & dumpOn( std::ostream & str ) const;
135           friend std::ostream& operator<<(std::ostream& str, const InjectSolutionAction & action)
136                 { return action.dumpOn (str); }
137
138           // ---------------------------------- accessors
139             const PoolItem item() const { return _item; }
140
141           // ---------------------------------- methods
142             virtual bool execute(Resolver & resolver) const;
143
144         protected:
145             PoolItem _item;
146             const InjectSolutionKind _kind;
147         };
148
149
150       ///////////////////////////////////////////////////////////////////
151     };// namespace detail
152     /////////////////////////////////////////////////////////////////////
153     /////////////////////////////////////////////////////////////////////
154   };// namespace solver
155   ///////////////////////////////////////////////////////////////////////
156   ///////////////////////////////////////////////////////////////////////
157 };// namespace zypp
158 /////////////////////////////////////////////////////////////////////////
159
160 #endif // ZYPP_SOLVER_DETAIL_SOLUTIONACTION_H
161