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 <boost/xpressive/xpressive_fwd.hpp>
24 
25 #include <set>
26 
27 #include <cupt/common.hpp>
28 #include <cupt/fwd.hpp>
29 #include <cupt/hashsums.hpp>
30 
31 namespace cupt {
32 
33 namespace internal {
34 
35 struct CacheImpl;
36 
37 }
38 
39 using std::set;
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  };
62  {
63  string uri;
64  uint32_t size;
65  HashSums hashSums;
66  };
69  {
70  string uri;
71  string localPath;
72  };
74  struct ExtendedInfo
75  {
76  set< string > automaticallyInstalled;
77  };
78 
79  private:
80  internal::CacheImpl* __impl;
81  Cache(const Cache&);
82  Cache& operator=(const Cache&);
83  public:
85 
94  Cache(shared_ptr< const Config > config, bool useSource, bool useBinary, bool useInstalled,
95  const vector< string >& packageNameGlobsToReinstall = vector< string >());
97  virtual ~Cache();
98 
100  vector< shared_ptr< const ReleaseInfo > > getBinaryReleaseData() const;
102  vector< shared_ptr< const ReleaseInfo > > getSourceReleaseData() const;
103 
105  vector< string > getBinaryPackageNames() const;
107 
111  shared_ptr< const BinaryPackage > getBinaryPackage(const string& packageName) const;
113  vector< string > getSourcePackageNames() const;
115 
119  shared_ptr< const SourcePackage > getSourcePackage(const string& packageName) const;
120 
122  vector< shared_ptr< const BinaryVersion > > getInstalledVersions() const;
123 
125 
129  bool isAutomaticallyInstalled(const string& packageName) const;
130 
132  vector< IndexEntry > getIndexEntries() const;
133 
135  string getPathOfReleaseList(const IndexEntry& entry) const;
137  string getPathOfIndexList(const IndexEntry& entry) const;
139  string getPathOfExtendedStates() const;
140 
142  string getDownloadUriOfReleaseList(const IndexEntry&) const;
144  vector< IndexDownloadRecord > getDownloadInfoOfIndexList(const IndexEntry&) const;
146  vector< LocalizationDownloadRecord > getDownloadInfoOfLocalizedDescriptions(const IndexEntry&) const;
147 
149  shared_ptr< const system::State > getSystemState() const;
150 
152  ssize_t getPin(const shared_ptr< const Version >&) const;
153 
156  {
157  shared_ptr< const Version > version;
158  ssize_t pin;
159 
161  PinnedVersion(shared_ptr< const Version > _version, ssize_t _pin)
162  : version(_version), pin(_pin) {}
163  };
165  vector< PinnedVersion > getSortedPinnedVersions(const shared_ptr< const Package >&) const;
167  shared_ptr< const Version > getPolicyVersion(const shared_ptr< const Package >&) const;
168 
170  vector< shared_ptr< const BinaryVersion > > getSatisfyingVersions(const RelationExpression&) const;
171 
173  const ExtendedInfo& getExtendedInfo() const;
174 
176 
180  pair< string, string > getLocalizedDescriptions(const shared_ptr< const BinaryVersion >&) const;
181 
183  static bool verifySignature(const shared_ptr< const Config >&, const string& path);
185 
189  static string getPathOfCopyright(const shared_ptr< const BinaryVersion >&);
191 
195  static string getPathOfChangelog(const shared_ptr< const BinaryVersion >&);
196 
198 
202  static bool memoize;
203 };
204 
205 }
206 
207 #endif
208