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
30namespace cupt {
31
32namespace internal {
33
34class CacheImpl;
35
36}
37
38using std::set;
39using std::map;
40
41using namespace cache;
42
44class CUPT_API Cache
45{
46 public:
48
53 {
55 enum Type { Source, Binary } category;
56 string uri;
57 string distribution;
58 string component;
59 map< string, string > options;
60 };
63 {
64 typedef map<string, map<string, string>> Raw;
65 Raw raw;
66 set< string > automaticallyInstalled;
67 };
68
70 {
71 public:
72 typedef const string value_type;
73
74 class Impl;
75 PackageNameIterator(Impl* impl);
80
81 bool operator==(const PackageNameIterator&) const;
82 bool operator!=(const PackageNameIterator&) const;
83
84 value_type& operator*() const;
85 PackageNameIterator& operator++();
86
87 private:
88 Impl* p_impl;
89 };
90
91 private:
92 internal::CacheImpl* __impl;
93 Cache(const Cache&);
94 Cache& operator=(const Cache&);
95 public:
97
105 Cache(shared_ptr< const Config > config, bool useSource, bool useBinary, bool useInstalled);
107 virtual ~Cache();
108
110 vector< shared_ptr< const ReleaseInfo > > getBinaryReleaseData() const;
112 vector< shared_ptr< const ReleaseInfo > > getSourceReleaseData() const;
113
117
121 const BinaryPackage* getBinaryPackage(const string& packageName) const;
125
129 const SourcePackage* getSourcePackage(const string& packageName) const;
130
132 vector< const BinaryVersion* > getInstalledVersions() const;
133
135
139 bool isAutomaticallyInstalled(const string& packageName) const;
140
142 vector< IndexEntry > getIndexEntries() const;
143
146
148 ssize_t getPin(const Version*) const;
149
152 {
153 const Version* version;
154 ssize_t priority;
155 };
157 vector<VersionWithPriority> getSortedVersionsWithPriorities(const Package*) const;
159 const Version* getPreferredVersion(const Package*) const;
160
162 vector< const BinaryVersion* > getSatisfyingVersions(const RelationExpression&) const;
163
166
168
172
174
178 static string getPathOfCopyright(const BinaryVersion*);
180
184 static string getPathOfChangelog(const BinaryVersion*);
185
187
191 static bool memoize;
192};
193
194}
195
196#endif
197
Definition: cache.hpp:70
the source of package and version information
Definition: cache.hpp:45
vector< const BinaryVersion * > getInstalledVersions() const
gets all installed versions
static string getPathOfChangelog(const BinaryVersion *)
gets a supposed system path of package changelog file for certain binary version
const SourcePackage * getSourcePackage(const string &packageName) const
gets SourcePackage by name
Range< PackageNameIterator > getBinaryPackageNames() const
gets the list of names of available binary packages
Range< PackageNameIterator > getSourcePackageNames() const
gets the list of names of available source packages
const system::State * getSystemState() const
gets system state
vector< const BinaryVersion * > getSatisfyingVersions(const RelationExpression &) const
gets list of binary versions which satisfy given relation expression
static string getPathOfCopyright(const BinaryVersion *)
gets a supposed system path of package copyright file for certain binary version
vector< VersionWithPriority > getSortedVersionsWithPriorities(const Package *) const
gets list of versions with priorities of certain package
vector< shared_ptr< const ReleaseInfo > > getSourceReleaseData() const
gets release data list of indexed metadata for source packages
vector< shared_ptr< const ReleaseInfo > > getBinaryReleaseData() const
gets release data list of indexed metadata for binary packages
const ExtendedInfo & getExtendedInfo() const
gets extended info
Cache(shared_ptr< const Config > config, bool useSource, bool useBinary, bool useInstalled)
constructor
vector< IndexEntry > getIndexEntries() const
gets list of available index entries
ssize_t getPin(const Version *) const
gets pin value for a version
virtual ~Cache()
destructor
bool isAutomaticallyInstalled(const string &packageName) const
is binary package automatically installed?
static bool memoize
controls internal caching
Definition: cache.hpp:191
const BinaryPackage * getBinaryPackage(const string &packageName) const
gets BinaryPackage by name
const Version * getPreferredVersion(const Package *) const
gets version of highest pin from the package
string getLocalizedDescription(const BinaryVersion *) const
gets localized description for the binary version
Package for binary versions.
Definition: binarypackage.hpp:31
a container for all versions of the same package name
Definition: package.hpp:57
package for source versions
Definition: sourcepackage.hpp:31
stores an additional information for installed packages
Definition: state.hpp:40
extended package information
Definition: cache.hpp:63
Raw raw
all fields and values in the format "map: (package name) -> (map: field -> value)"
Definition: cache.hpp:65
set< string > automaticallyInstalled
names of automatically installed packages
Definition: cache.hpp:66
describes smallest index source piece
Definition: cache.hpp:53
string distribution
distribution part, e.g. lenny, squeeze
Definition: cache.hpp:57
Type
does this index entry contains source or binary packages
Definition: cache.hpp:55
map< string, string > options
key-value options;
Definition: cache.hpp:59
string uri
base index URI, as specified in source list
Definition: cache.hpp:56
string component
component part, e.g. main, contrib, non-free
Definition: cache.hpp:58
contains version and its corresponding priority
Definition: cache.hpp:152
Definition: range.hpp:28
binary version info
Definition: binaryversion.hpp:32
group of alternative relations
Definition: relation.hpp:110
common version information
Definition: version.hpp:40