libyui-ncurses-pkg  2.43.4.1
 All Classes Functions
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 #define EXTRA_PATCH_STRATEGY 0
49 
50 //------------------------------------------------------------
51 // Abstract base class for strategies to get status for packages or patches
52 //------------------------------------------------------------
54 {
55 
56 public:
57 
59 
60  virtual ~NCPkgStatusStrategy() = 0;
61 
62  /**
63  * Gets the status information from the package manager.
64  * @param slbPtr The package whose status to calculate.
65  * @return UI_Status The new status of the given package
66  *
67  **/
68  virtual ZyppStatus getPackageStatus ( ZyppSel slbPtr, ZyppObj objPtr );
69 
70  /**
71  * Informs the package manager about the new status.
72  * @param newStatus The new package status
73  * @param slbPtr The selectable pointer (e.g. a package pointer)
74  * @param pkgPtr The object pointer (used for candidate selection)
75  * @return bool
76  */
77  virtual bool setObjectStatus ( ZyppStatus newstatus,
78  ZyppSel slbPtr,
79  ZyppObj objPtr
80  );
81  /**
82  * Returns the new status to the given key (respecting the old
83  * status of th eobject).
84  * @param key The userinput (the key which is pressed)
85  * @param slbPtr The object pointer (e.g. a package pointer)
86  * @param newStatus The new package status
87  * @return bool
88  */
89  virtual bool keyToStatus( const int & key,
90  ZyppSel slbPtr,
91  ZyppObj objPtr,
92  ZyppStatus & newStat );
93 
94  /**
95  * Toggles the package status (e.g. from installed to delete)
96  * @param The object pointer
97  * @return bool
98  */
99  virtual bool toggleStatus( ZyppSel slbPtr,
100  ZyppObj objPtr,
101  ZyppStatus & newStat );
102  /**
103  * Do a "small" solver run for all "resolvable collections", i.e., for
104  * selections, patterns, languages, patches.
105  **/
107 
108 
109 };
110 
111 //------------------------------------------------------------
112 // Class for strategies to handle status of packages
113 //------------------------------------------------------------
115 {
116 public:
117 
119 
120  virtual ~PackageStatStrategy() {}
121 
122 };
123 
124 //------------------------------------------------------------
125 // Class for strategies to handle dependencies
126 //------------------------------------------------------------
128 {
129 public:
130 
132 
133  virtual ~DependencyStatStrategy() {}
134 
135 };
136 
137 //------------------------------------------------------------
138 // Class for strategies of update
139 //------------------------------------------------------------
141 {
142 public:
143 
145 
146  virtual ~UpdateStatStrategy() {}
147 
148 };
149 
150 //------------------------------------------------------------
151 // Class for strategies of selections
152 //------------------------------------------------------------
154 {
155 public:
156 
158 
159  virtual ~SelectionStatStrategy() {}
160 
161  /**
162  * Sets the status of the selection
163  * @param newStatus The new selection status
164  * @param slbPtr The selectable pointer
165  * @qparam objPtr The object (selection) pointer
166  * @return bool
167  */
168  virtual bool setObjectStatus( ZyppStatus newstatus,
169  ZyppSel slbPtr,
170  ZyppObj objPtr );
171 
172 };
173 
174 //------------------------------------------------------------
175 // Class for strategies to handle status of packages belonging to a patch
176 //------------------------------------------------------------
178 {
179 public:
180 
182 
183  virtual ~PatchPkgStatStrategy() {}
184 
185  /**
186  * It is not possible to std::set the package status for packages belonging to a patch,
187  * i.e. returns always false.
188  */
189  virtual bool setObjectStatus( ZyppStatus newstatus,
190  ZyppSel slbPtr,
191  ZyppObj objPtr );
192 
193 };
194 
195 
196 
197 //------------------------------------------------------------
198 // Class for strategies to handle status of patches
199 //------------------------------------------------------------
201 {
202 public:
203 
205 
206  virtual ~PatchStatStrategy() {}
207 
208  /**
209  * Returns the new status to the given key (respecting the old
210  * status of the patch).
211  * @param key The userinput (the key which is pressed)
212  * @param slbPtr The object pointer (the patch pointer)
213  * @param newStatus The new package status
214  * @return bool
215  */
216  virtual bool keyToStatus( const int & key,
217  ZyppSel slbPtr,
218  ZyppObj objPtr,
219  ZyppStatus & newStat );
220 
221 #if EXTRA_PATCH_STRATEGY
222  /**
223  * Toggles the patch status (e.g. from selected to unselected)
224  * @param The object pointer
225  * @return bool
226  */
227  virtual bool toggleStatus( ZyppSel slbPtr,
228  ZyppObj objPtr,
229  ZyppStatus & newStat );
230 #endif
231 
232  /**
233  * Sets the status of the patch AND the status of the patch packages
234  * @param newStatus The new package status
235  * @param slbPtr The object pointer (e.g. a package pointer)
236  * @return bool
237  */
238  virtual bool setObjectStatus( ZyppStatus newstatus, ZyppSel slbPtr, ZyppObj objPtr );
239 };
240 
241 
242 
243 //------------------------------------------------------------
244 // Class for strategies to handle status of available packages
245 //------------------------------------------------------------
247 {
248 public:
249 
251 
252  virtual ~AvailableStatStrategy() {}
253 
254  /**
255  * Informs the package manager about the new status and
256  * additionally sets the candidate object to the user chosen object.
257  * @param newStatus The new package status
258  * @param slbPtr The package pointer
259  * @param pkgPtr The object pointer (used for candidate selection)
260  * @return bool
261  */
262  virtual bool setObjectStatus( ZyppStatus newstatus,
263  ZyppSel slbPtr, ZyppObj objPtr );
264 
265 };
266 
267 //----------------------------------------------------------------
268 // Class for strategies to handle status of multi version packages
269 //----------------------------------------------------------------
271 {
272 public:
273 
275 
276  virtual ~MultiVersionStatStrategy() {}
277 
278  /**
279  * Gets the status information from the package manager.
280  * @param slbPtr The package whose status to calculate.
281  * @return UI_Status The new status of the given package
282  *
283  **/
284  virtual ZyppStatus getPackageStatus ( ZyppSel slbPtr, ZyppObj objPtr );
285 
286  /**
287  * Informs the package manager about the new status and
288  * additionally sets the candidate object to the user chosen object.
289  * @param newStatus The new package status
290  * @param slbPtr The package pointer
291  * @param pkgPtr The object pointer (used for candidate selection)
292  * @return bool
293  */
294  virtual bool setObjectStatus( ZyppStatus newstatus,
295  ZyppSel slbPtr, ZyppObj objPtr );
296 
297 };
298 
299 
300 #endif