libyui-ncurses-pkg  2.50.10
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  * Cyle the package status (e.g. from installed to delete)
95  */
96  virtual bool cycleStatus( ZyppSel slbPtr,
97  ZyppObj objPtr,
98  ZyppStatus & newStat_ret );
99  /**
100  * Do a "small" solver run for all "resolvable collections", i.e., for
101  * selections, patterns, languages, patches.
102  **/
104 
105 };
106 
107 
108 //------------------------------------------------------------
109 // Class for strategies to handle status of packages
110 //------------------------------------------------------------
112 {
113 public:
114 
116 
117  virtual ~PackageStatStrategy() {}
118 
119 };
120 
121 //------------------------------------------------------------
122 // Class for strategies to handle dependencies
123 //------------------------------------------------------------
125 {
126 public:
127 
129 
130  virtual ~DependencyStatStrategy() {}
131 
132 };
133 
134 //------------------------------------------------------------
135 // Class for strategies of update
136 //------------------------------------------------------------
138 {
139 public:
140 
142 
143  virtual ~UpdateStatStrategy() {}
144 
145 };
146 
147 //------------------------------------------------------------
148 // Class for strategies of selections
149 //------------------------------------------------------------
151 {
152 public:
153 
155 
156  virtual ~SelectionStatStrategy() {}
157 
158  /**
159  * Sets the status of the selection
160  * @param newStatus The new selection status
161  * @param slbPtr The selectable pointer
162  * @qparam objPtr The object (selection) pointer
163  * @return bool
164  */
165  virtual bool setObjectStatus( ZyppStatus newstatus,
166  ZyppSel slbPtr,
167  ZyppObj objPtr );
168 
169 };
170 
171 //------------------------------------------------------------
172 // Class for strategies to handle status of packages belonging to a patch
173 //------------------------------------------------------------
175 {
176 public:
177 
179 
180  virtual ~PatchPkgStatStrategy() {}
181 
182  /**
183  * It is not possible to std::set the package status for packages belonging to a patch,
184  * i.e. returns always false.
185  */
186  virtual bool setObjectStatus( ZyppStatus newstatus,
187  ZyppSel slbPtr,
188  ZyppObj objPtr );
189 
190 };
191 
192 
193 
194 //------------------------------------------------------------
195 // Class for strategies to handle status of patches
196 //------------------------------------------------------------
198 {
199 public:
200 
202 
203  virtual ~PatchStatStrategy() {}
204 
205  /**
206  * Returns the new status to the given key (respecting the old
207  * status of the patch).
208  * @param key The userinput (the key which is pressed)
209  * @param slbPtr The object pointer (the patch pointer)
210  * @param newStatus The new package status
211  * @return bool
212  */
213  virtual bool keyToStatus( const int & key,
214  ZyppSel slbPtr,
215  ZyppObj objPtr,
216  ZyppStatus & newStat );
217 
218  /**
219  * Cycle the patch status (e.g. from selected to unselected)
220  */
221  virtual bool cycleStatus( ZyppSel slbPtr,
222  ZyppObj objPtr,
223  ZyppStatus & newStat_ret );
224 
225  /**
226  * Sets the status of the patch AND the status of the patch packages
227  * @param newStatus The new package status
228  * @param slbPtr The object pointer (e.g. a package pointer)
229  * @return bool
230  */
231  virtual bool setObjectStatus( ZyppStatus newstatus, ZyppSel slbPtr, ZyppObj objPtr );
232 };
233 
234 
235 
236 //------------------------------------------------------------
237 // Class for strategies to handle status of available packages
238 //------------------------------------------------------------
240 {
241 public:
242 
244 
245  virtual ~AvailableStatStrategy() {}
246 
247  /**
248  * Informs the package manager about the new status and
249  * additionally sets the candidate object to the user chosen object.
250  * @param newStatus The new package status
251  * @param slbPtr The package pointer
252  * @param pkgPtr The object pointer (used for candidate selection)
253  * @return bool
254  */
255  virtual bool setObjectStatus( ZyppStatus newstatus,
256  ZyppSel slbPtr, ZyppObj objPtr );
257 
258 };
259 
260 //----------------------------------------------------------------
261 // Class for strategies to handle status of multi version packages
262 //----------------------------------------------------------------
264 {
265 public:
266 
268 
269  virtual ~MultiVersionStatStrategy() {}
270 
271  /**
272  * Gets the status information from the package manager.
273  * @param slbPtr The package whose status to calculate.
274  * @return UI_Status The new status of the given package
275  *
276  **/
277  virtual ZyppStatus getPackageStatus ( ZyppSel slbPtr, ZyppObj objPtr );
278 
279  /**
280  * Informs the package manager about the new status and
281  * additionally sets the candidate object to the user chosen object.
282  * @param newStatus The new package status
283  * @param slbPtr The package pointer
284  * @param pkgPtr The object pointer (used for candidate selection)
285  * @return bool
286  */
287  virtual bool setObjectStatus( ZyppStatus newstatus,
288  ZyppSel slbPtr, ZyppObj objPtr );
289 
290 
291  /**
292  * Check if any package version is marked for installation where its
293  * 'multiversion' flag is set to 'multiversion'.
294  * @param slbPtr The selectable whose status has to be calculated.
295  * @param multiversion Check for multiversion or non-multiversion packages.
296  * @return bool
297  *
298  **/
299  virtual bool anyMultiVersionToInstall( ZyppSel slbPtr, bool multiversion ) const;
300 
301  /**
302  * Ask user if he really wants to install incompatible package versions.
303  * @param multiversion Selected package is a multiversion package.
304  * @return bool Return 'true' if he hits [Continue], 'false' if [Cancel].
305  *
306  **/
307  virtual bool mixedMultiVersionPopup( bool multiversion ) const;
308 
309 };
310 
311 
312 #endif
NCPkgStatusStrategy::cycleStatus
virtual bool cycleStatus(ZyppSel slbPtr, ZyppObj objPtr, ZyppStatus &newStat_ret)
Cyle the package status (e.g.
Definition: NCPkgStatusStrategy.cc:242
NCPkgStatusStrategy::setObjectStatus
virtual bool setObjectStatus(ZyppStatus newstatus, ZyppSel slbPtr, ZyppObj objPtr)
Informs the package manager about the new status.
Definition: NCPkgStatusStrategy.cc:103
NCPkgStatusStrategy::keyToStatus
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).
Definition: NCPkgStatusStrategy.cc:128
AvailableStatStrategy::setObjectStatus
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...
Definition: NCPkgStatusStrategy.cc:611
PatchStatStrategy::keyToStatus
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).
Definition: NCPkgStatusStrategy.cc:373
PatchPkgStatStrategy
Definition: NCPkgStatusStrategy.h:175
PatchStatStrategy
Definition: NCPkgStatusStrategy.h:198
MultiVersionStatStrategy
Definition: NCPkgStatusStrategy.h:264
MultiVersionStatStrategy::getPackageStatus
virtual ZyppStatus getPackageStatus(ZyppSel slbPtr, ZyppObj objPtr)
Gets the status information from the package manager.
Definition: NCPkgStatusStrategy.cc:698
AvailableStatStrategy
Definition: NCPkgStatusStrategy.h:240
NCPkgStatusStrategy::solveResolvableCollections
void solveResolvableCollections()
Do a "small" solver run for all "resolvable collections", i.e., for selections, patterns,...
Definition: NCPkgStatusStrategy.cc:331
MultiVersionStatStrategy::mixedMultiVersionPopup
virtual bool mixedMultiVersionPopup(bool multiversion) const
Ask user if he really wants to install incompatible package versions.
Definition: NCPkgStatusStrategy.cc:809
NCPkgStatusStrategy::getPackageStatus
virtual ZyppStatus getPackageStatus(ZyppSel slbPtr, ZyppObj objPtr)
Gets the status information from the package manager.
Definition: NCPkgStatusStrategy.cc:82
MultiVersionStatStrategy::anyMultiVersionToInstall
virtual bool anyMultiVersionToInstall(ZyppSel slbPtr, bool multiversion) const
Check if any package version is marked for installation where its 'multiversion' flag is set to 'mult...
Definition: NCPkgStatusStrategy.cc:766
PackageStatStrategy
Definition: NCPkgStatusStrategy.h:112
PatchStatStrategy::setObjectStatus
virtual bool setObjectStatus(ZyppStatus newstatus, ZyppSel slbPtr, ZyppObj objPtr)
Sets the status of the patch AND the status of the patch packages.
Definition: NCPkgStatusStrategy.cc:517
UpdateStatStrategy
Definition: NCPkgStatusStrategy.h:138
PatchPkgStatStrategy::setObjectStatus
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,...
Definition: NCPkgStatusStrategy.cc:864
MultiVersionStatStrategy::setObjectStatus
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...
Definition: NCPkgStatusStrategy.cc:719
DependencyStatStrategy
Definition: NCPkgStatusStrategy.h:125
NCPkgStatusStrategy
Definition: NCPkgStatusStrategy.h:53
SelectionStatStrategy
Definition: NCPkgStatusStrategy.h:151
PatchStatStrategy::cycleStatus
virtual bool cycleStatus(ZyppSel slbPtr, ZyppObj objPtr, ZyppStatus &newStat_ret)
Cycle the patch status (e.g.
Definition: NCPkgStatusStrategy.cc:459
SelectionStatStrategy::setObjectStatus
virtual bool setObjectStatus(ZyppStatus newstatus, ZyppSel slbPtr, ZyppObj objPtr)
Sets the status of the selection.
Definition: NCPkgStatusStrategy.cc:558