Cupt
cache.hpp
Go to the documentation of this file.
1 /**************************************************************************
2 * Copyright (C) 2010 by Eugene V. Lyubimkin *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License *
6 * (version 3 or above) as published by the Free Software Foundation. *
7 * *
8 * This program is distributed in the hope that it will be useful, *
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
11 * GNU General Public License for more details. *
12 * *
13 * You should have received a copy of the GNU GPL *
14 * along with this program; if not, write to the *
15 * Free Software Foundation, Inc., *
16 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA *
17 **************************************************************************/
18 #ifndef CUPT_CACHE_CACHE_SEEN
19 #define CUPT_CACHE_CACHE_SEEN
20 
22 
23 #include <set>
24 #include <map>
25 
26 #include <cupt/common.hpp>
27 #include <cupt/fwd.hpp>
28 #include <cupt/range.hpp>
29 
30 namespace cupt {
31 
32 namespace internal {
33 
34 struct CacheImpl;
35 
36 }
37 
38 using std::set;
39 using std::map;
40 
41 using namespace cache;
42 
44 class CUPT_API Cache
45 {
46  public:
48 
52  struct IndexEntry
53  {
55  enum Type { Source, Binary } category;
56  string uri;
57  string distribution;
58  string component;
59  map< string, string > options;
60  };
62  struct ExtendedInfo
63  {
64  set< string > automaticallyInstalled;
65  };
66 
68  {
69  public:
70  typedef const string value_type;
71 
72  class Impl;
73  PackageNameIterator(Impl* impl);
76  PackageNameIterator& operator=(const PackageNameIterator&);
78 
79  bool operator==(const PackageNameIterator&) const;
80  bool operator!=(const PackageNameIterator&) const;
81 
82  value_type& operator*() const;
83  PackageNameIterator& operator++();
84 
85  private:
86  Impl* p_impl;
87  };
88 
89  private:
90  internal::CacheImpl* __impl;
91  Cache(const Cache&);
92  Cache& operator=(const Cache&);
93  public:
95 
103  Cache(shared_ptr< const Config > config, bool useSource, bool useBinary, bool useInstalled);
105  virtual ~Cache();
106 
108  vector< shared_ptr< const ReleaseInfo > > getBinaryReleaseData() const;
110  vector< shared_ptr< const ReleaseInfo > > getSourceReleaseData() const;
111 
113  Range< PackageNameIterator > getBinaryPackageNames() const;
115 
119  const BinaryPackage* getBinaryPackage(const string& packageName) const;
121  Range< PackageNameIterator > getSourcePackageNames() const;
123 
127  const SourcePackage* getSourcePackage(const string& packageName) const;
128 
130  vector< const BinaryVersion* > getInstalledVersions() const;
131 
133 
137  bool isAutomaticallyInstalled(const string& packageName) const;
138 
140  vector< IndexEntry > getIndexEntries() const;
141 
143  const system::State* getSystemState() const;
144 
146  ssize_t getPin(const Version*) const;
147 
150  {
151  const Version* version;
152  ssize_t pin;
153  };
155  vector< PinnedVersion > getSortedPinnedVersions(const Package*) const;
157  const Version* getPreferredVersion(const Package*) const;
158 
160  vector< const BinaryVersion* > getSatisfyingVersions(const RelationExpression&) const;
161 
163  const ExtendedInfo& getExtendedInfo() const;
164 
166 
169  string getLocalizedDescription(const BinaryVersion*) const;
170 
172 
176  static string getPathOfCopyright(const BinaryVersion*);
178 
182  static string getPathOfChangelog(const BinaryVersion*);
183 
185 
189  static bool memoize;
190 };
191 
192 }
193 
194 #endif
195