libyui-qt-pkg  2.45.6
 All Classes Functions Variables Enumerations
YQPkgSelMapper.h
1 /**************************************************************************
2 Copyright (C) 2000 - 2010 Novell, Inc.
3 All Rights Reserved.
4 
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
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 along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 
19 **************************************************************************/
20 
21 
22 /*---------------------------------------------------------------------\
23 | |
24 | __ __ ____ _____ ____ |
25 | \ \ / /_ _/ ___|_ _|___ \ |
26 | \ V / _` \___ \ | | __) | |
27 | | | (_| |___) || | / __/ |
28 | |_|\__,_|____/ |_| |_____| |
29 | |
30 | core system |
31 | (C) SuSE GmbH |
32 \----------------------------------------------------------------------/
33 
34  File: YQPkgSelMapper.h
35 
36  Author: Stefan Hundhammer <sh@suse.de>
37 
38 /-*/
39 
40 
41 #ifndef YQPkgSelMapper_h
42 #define YQPkgSelMapper_h
43 
44 #include "YQZypp.h"
45 #include <map>
46 
47 
48 
49 /**
50  * Mapping from ZyppPkg to the correspoinding ZyppSel.
51  *
52  * All instances of this class share the same cache. The cache remains alive as
53  * long as any instance of this class exists.
54  **/
56 {
57 public:
58 
59  /**
60  * Constructor. Builds a cache, if necessary.
61  **/
63 
64  /**
65  * Destructor. Clears the cache if this was the last YQPkgSelMapper
66  * (i.e. if refCount() reaches 0)
67  **/
68  virtual ~YQPkgSelMapper();
69 
70  /**
71  * Find the corresponding ZyppSel to a ZyppPkg.
72  * Returns 0 if there is no corresponding ZyppSel.
73  **/
74 
75  ZyppSel findZyppSel( ZyppPkg pkg );
76 
77  /**
78  * Reference count - indicates how many instances of this class are alive
79  * right now.
80  **/
81  static int refCount() { return _refCount; }
82 
83  /**
84  * Rebuild the shared cache. This is expensive. Call this only when the
85  * ZyppPool has changed, i.e. after installation sources were added or
86  * removed.
87  *
88  * Since the cache is shared, this affects all instances of this class.
89  **/
90  void rebuildCache();
91 
92 
93 protected:
94 
95  typedef std::map<ZyppPkg, ZyppSel> Cache;
96  typedef std::pair<ZyppPkg, ZyppSel> CachePair;
97  typedef Cache::iterator CacheIterator;
98 
99  static int _refCount;
100  static Cache _cache;
101 };
102 
103 
104 
105 #endif // YQPkgSelMapper_h
YQPkgSelMapper()
Constructor.
virtual ~YQPkgSelMapper()
Destructor.
static int refCount()
Reference count - indicates how many instances of this class are alive right now. ...
Mapping from ZyppPkg to the correspoinding ZyppSel.
ZyppSel findZyppSel(ZyppPkg pkg)
Find the corresponding ZyppSel to a ZyppPkg.
void rebuildCache()
Rebuild the shared cache.