libyui-ncurses-pkg  2.48.9
NCPkgStatusStrategy.h
1 /****************************************************************************
2 |
3 | Copyright (c) [2002-2011] Novell, Inc.
4 | All Rights Reserved.
5 |
6 | This program is free software; you can redistribute it and/or
7 | modify it under the terms of version 2 of the GNU General Public License as
8 | published by the Free Software Foundation.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program; if not, contact Novell, Inc.
17 |
18 | To contact Novell about this file by physical or electronic mail,
19 | you may find current contact information at www.novell.com
20 |
21 |***************************************************************************/
22 
23 
24 /*---------------------------------------------------------------------\
25 | |
26 | __ __ ____ _____ ____ |
27 | \ \ / /_ _/ ___|_ _|___ \ |
28 | \ V / _` \___ \ | | __) | |
29 | | | (_| |___) || | / __/ |
30 | |_|\__,_|____/ |_| |_____| |
31 | |
32 | core system |
33 | (C) SuSE GmbH |
34 \----------------------------------------------------------------------/
35 
36  File: NCPkgStatusStrategy.h
37 
38  Author: Gabriele Strattner <gs@suse.de>
39 
40 
41 /-*/
42 #ifndef NCPkgStatusStrategy_h
43 #define NCPkgStatusStrategy_h
44 
45 #include "NCZypp.h"
46 #include <zypp/ui/Selectable.h>
47 
48 
49 //------------------------------------------------------------
50 // Abstract base class for strategies to get status for packages or patches
51 //------------------------------------------------------------
53 {
54 
55 public:
56 
58 
59  virtual ~NCPkgStatusStrategy() = 0;
60 
61  /**
62  * Gets the status information from the package manager.
63  * @param slbPtr The package whose status to calculate.
64  * @return UI_Status The new status of the given package
65  *
66  **/
67  virtual ZyppStatus getPackageStatus ( ZyppSel slbPtr, ZyppObj objPtr );
68 
69  /**
70  * Informs the package manager about the new status.
71  * @param newStatus The new package status
72  * @param slbPtr The selectable pointer (e.g. a package pointer)
73  * @param pkgPtr The object pointer (used for candidate selection)
74  * @return bool
75  */
76  virtual bool setObjectStatus ( ZyppStatus newstatus,
77  ZyppSel slbPtr,
78  ZyppObj objPtr
79  );
80  /**
81  * Returns the new status to the given key (respecting the old
82  * status of th eobject).
83  * @param key The userinput (the key which is pressed)
84  * @param slbPtr The object pointer (e.g. a package pointer)
85  * @param newStatus The new package status
86  * @return bool
87  */
88  virtual bool keyToStatus( const int & key,
89  ZyppSel slbPtr,
90  ZyppObj objPtr,
91  ZyppStatus & newStat );
92 
93  /**
94  * Toggles the package status (e.g. from installed to delete)
95  * @param The object pointer
96  * @return bool
97  */
98  virtual bool toggleStatus( ZyppSel slbPtr,
99  ZyppObj objPtr,
100  ZyppStatus & newStat );
101  /**
102  * Do a "small" solver run for all "resolvable collections", i.e., for
103  * selections, patterns, languages, patches.
104  **/
106 
107 
108 };
109 
110 //------------------------------------------------------------
111 // Class for strategies to handle status of packages
112 //------------------------------------------------------------
114 {
115 public:
116 
118 
119  virtual ~PackageStatStrategy() {}
120 
121 };
122 
123 //------------------------------------------------------------
124 // Class for strategies to handle dependencies
125 //------------------------------------------------------------
127 {
128 public:
129 
131 
132  virtual ~DependencyStatStrategy() {}
133 
134 };
135 
136 //------------------------------------------------------------
137 // Class for strategies of update
138 //------------------------------------------------------------
140 {
141 public:
142 
144 
145  virtual ~UpdateStatStrategy() {}
146 
147 };
148 
149 //------------------------------------------------------------
150 // Class for strategies of selections
151 //------------------------------------------------------------
153 {
154 public:
155 
157 
158  virtual ~SelectionStatStrategy() {}
159 
160  /**
161  * Sets the status of the selection
162  * @param newStatus The new selection status
163  * @param slbPtr The selectable pointer
164  * @qparam objPtr The object (selection) pointer
165  * @return bool
166  */
167  virtual bool setObjectStatus( ZyppStatus newstatus,
168  ZyppSel slbPtr,
169  ZyppObj objPtr );
170 
171 };
172 
173 //------------------------------------------------------------
174 // Class for strategies to handle status of packages belonging to a patch
175 //------------------------------------------------------------
177 {
178 public:
179 
181 
182  virtual ~PatchPkgStatStrategy() {}
183 
184  /**
185  * It is not possible to std::set the package status for packages belonging to a patch,
186  * i.e. returns always false.
187  */
188  virtual bool setObjectStatus( ZyppStatus newstatus,
189  ZyppSel slbPtr,
190  ZyppObj objPtr );
191 
192 };
193 
194 
195 
196 //------------------------------------------------------------
197 // Class for strategies to handle status of patches
198 //------------------------------------------------------------
200 {
201 public:
202 
204 
205  virtual ~PatchStatStrategy() {}
206 
207  /**
208  * Returns the new status to the given key (respecting the old
209  * status of the patch).
210  * @param key The userinput (the key which is pressed)
211  * @param slbPtr The object pointer (the patch pointer)
212  * @param newStatus The new package status
213  * @return bool
214  */
215  virtual bool keyToStatus( const int & key,
216  ZyppSel slbPtr,
217  ZyppObj objPtr,
218  ZyppStatus & newStat );
219 
220  /**
221  * Toggles the patch status (e.g. from selected to unselected)
222  * @param The object pointer
223  * @return bool
224  */
225  virtual bool toggleStatus( ZyppSel slbPtr,
226  ZyppObj objPtr,
227  ZyppStatus & newStat );
228 
229  /**
230  * Sets the status of the patch AND the status of the patch packages
231  * @param newStatus The new package status
232  * @param slbPtr The object pointer (e.g. a package pointer)
233  * @return bool
234  */
235  virtual bool setObjectStatus( ZyppStatus newstatus, ZyppSel slbPtr, ZyppObj objPtr );
236 };
237 
238 
239 
240 //------------------------------------------------------------
241 // Class for strategies to handle status of available packages
242 //------------------------------------------------------------
244 {
245 public:
246 
248 
249  virtual ~AvailableStatStrategy() {}
250 
251  /**
252  * Informs the package manager about the new status and
253  * additionally sets the candidate object to the user chosen object.
254  * @param newStatus The new package status
255  * @param slbPtr The package pointer
256  * @param pkgPtr The object pointer (used for candidate selection)
257  * @return bool
258  */
259  virtual bool setObjectStatus( ZyppStatus newstatus,
260  ZyppSel slbPtr, ZyppObj objPtr );
261 
262 };
263 
264 //----------------------------------------------------------------
265 // Class for strategies to handle status of multi version packages
266 //----------------------------------------------------------------
268 {
269 public:
270 
272 
273  virtual ~MultiVersionStatStrategy() {}
274 
275  /**
276  * Gets the status information from the package manager.
277  * @param slbPtr The package whose status to calculate.
278  * @return UI_Status The new status of the given package
279  *
280  **/
281  virtual ZyppStatus getPackageStatus ( ZyppSel slbPtr, ZyppObj objPtr );
282 
283  /**
284  * Informs the package manager about the new status and
285  * additionally sets the candidate object to the user chosen object.
286  * @param newStatus The new package status
287  * @param slbPtr The package pointer
288  * @param pkgPtr The object pointer (used for candidate selection)
289  * @return bool
290  */
291  virtual bool setObjectStatus( ZyppStatus newstatus,
292  ZyppSel slbPtr, ZyppObj objPtr );
293 
294 
295  /**
296  * Check if any package version is marked for installation where its
297  * 'multiversion' flag is set to 'multiversion'.
298  * @param slbPtr The selectable whose status has to be calculated.
299  * @param multiversion Check for multiversion or non-multiversion packages.
300  * @return bool
301  *
302  **/
303  virtual bool anyMultiVersionToInstall( ZyppSel slbPtr, bool multiversion ) const;
304 
305  /**
306  * Ask user if he really wants to install incompatible package versions.
307  * @param multiversion Selected package is a multiversion package.
308  * @return bool Return 'true' if he hits [Continue], 'false' if [Cancel].
309  *
310  **/
311  virtual bool mixedMultiVersionPopup( bool multiversion ) const;
312 
313 };
314 
315 
316 #endif
virtual bool keyToStatus(const int &key, ZyppSel slbPtr, ZyppObj objPtr, ZyppStatus &newStat)
Returns the new status to the given key (respecting the old status of th eobject).
virtual bool anyMultiVersionToInstall(ZyppSel slbPtr, bool multiversion) const
Check if any package version is marked for installation where its &#39;multiversion&#39; flag is set to &#39;mult...
virtual bool toggleStatus(ZyppSel slbPtr, ZyppObj objPtr, ZyppStatus &newStat)
Toggles the package status (e.g.
virtual bool toggleStatus(ZyppSel slbPtr, ZyppObj objPtr, ZyppStatus &newStat)
Toggles the patch status (e.g.
virtual bool keyToStatus(const int &key, ZyppSel slbPtr, ZyppObj objPtr, ZyppStatus &newStat)
Returns the new status to the given key (respecting the old status of the patch). ...
virtual bool setObjectStatus(ZyppStatus newstatus, ZyppSel slbPtr, ZyppObj objPtr)
Informs the package manager about the new status.
virtual ZyppStatus getPackageStatus(ZyppSel slbPtr, ZyppObj objPtr)
Gets the status information from the package manager.
virtual bool setObjectStatus(ZyppStatus newstatus, ZyppSel slbPtr, ZyppObj objPtr)
It is not possible to std::set the package status for packages belonging to a patch, i.e.
virtual bool setObjectStatus(ZyppStatus newstatus, ZyppSel slbPtr, ZyppObj objPtr)
Informs the package manager about the new status and additionally sets the candidate object to the us...
virtual bool setObjectStatus(ZyppStatus newstatus, ZyppSel slbPtr, ZyppObj objPtr)
Sets the status of the patch AND the status of the patch packages.
virtual bool setObjectStatus(ZyppStatus newstatus, ZyppSel slbPtr, ZyppObj objPtr)
Sets the status of the selection.
virtual ZyppStatus getPackageStatus(ZyppSel slbPtr, ZyppObj objPtr)
Gets the status information from the package manager.
virtual bool mixedMultiVersionPopup(bool multiversion) const
Ask user if he really wants to install incompatible package versions.
virtual bool setObjectStatus(ZyppStatus newstatus, ZyppSel slbPtr, ZyppObj objPtr)
Informs the package manager about the new status and additionally sets the candidate object to the us...
void solveResolvableCollections()
Do a "small" solver run for all "resolvable collections", i.e., for selections, patterns, languages, patches.