/usr/include/cupt/cache.hpp is in libcupt2-dev 2.3.2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 | /**************************************************************************
* Copyright (C) 2010 by Eugene V. Lyubimkin *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License *
* (version 3 or above) as published by the Free Software Foundation. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU GPL *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA *
**************************************************************************/
#ifndef CUPT_CACHE_CACHE_SEEN
#define CUPT_CACHE_CACHE_SEEN
/// @file
#include <boost/xpressive/xpressive_fwd.hpp>
#include <set>
#include <cupt/common.hpp>
#include <cupt/fwd.hpp>
#include <cupt/hashsums.hpp>
namespace cupt {
namespace internal {
struct CacheImpl;
}
using std::set;
using namespace cache;
/// the source of package and version information
class CUPT_API Cache
{
public:
/// describes smallest index source piece
/**
* When Cache reads source entries from configuration files, it breaks them
* into these logical pieces.
*/
struct IndexEntry
{
/// does this index entry contains source or binary packages
enum Type { Source, Binary } category;
string uri; ///< base index URI, as specified in source list
string distribution; ///< distribution part, e.g. @c lenny, @c squeeze
string component; ///< component part, e.g. @c main, @c contrib, @c non-free
};
/// @deprecated an internal structure, should not be used
struct IndexDownloadRecord
{
string uri;
uint32_t size;
HashSums hashSums;
};
/// @copydoc IndexDownloadRecord
struct LocalizationDownloadRecord
{
string uri;
string localPath;
};
/// extended package information
struct ExtendedInfo
{
set< string > automaticallyInstalled; ///< names of automatically installed packages
};
private:
internal::CacheImpl* __impl;
Cache(const Cache&);
Cache& operator=(const Cache&);
public:
/// constructor
/**
* Reads package metadata and builds index on it.
*
* @param config
* @param useSource whether to read source package metadata
* @param useBinary whether to read binary package metadata
* @param useInstalled whether to read dpkg metadata (installed binary packages)
* @param packageNameGlobsToReinstall array of glob expressions, allow these packages to be re-installed
*/
Cache(shared_ptr< const Config > config, bool useSource, bool useBinary, bool useInstalled,
const vector< string >& packageNameGlobsToReinstall = vector< string >());
/// destructor
virtual ~Cache();
/// gets release data list of indexed metadata for binary packages
vector< shared_ptr< const ReleaseInfo > > getBinaryReleaseData() const;
/// gets release data list of indexed metadata for source packages
vector< shared_ptr< const ReleaseInfo > > getSourceReleaseData() const;
/// gets the list of names of available binary packages
vector< string > getBinaryPackageNames() const;
/// gets BinaryPackage by name
/**
* @param packageName name of the binary package
* @return pointer to binary package if found, empty pointer if not
*/
shared_ptr< const BinaryPackage > getBinaryPackage(const string& packageName) const;
/// gets the list of names of available source packages
vector< string > getSourcePackageNames() const;
/// gets SourcePackage by name
/**
* @param packageName name of the source package
* @return pointer to source package if found, empty pointer if not
*/
shared_ptr< const SourcePackage > getSourcePackage(const string& packageName) const;
/// gets all installed versions
vector< shared_ptr< const BinaryVersion > > getInstalledVersions() const;
/// is binary package automatically installed?
/**
* @param packageName name of the binary package
* @return @c true if yes, @c false if no
*/
bool isAutomaticallyInstalled(const string& packageName) const;
/// gets list of available index entries
vector< IndexEntry > getIndexEntries() const;
/// @deprecated an internal method, should not be used
string getPathOfReleaseList(const IndexEntry& entry) const;
/// @copydoc getPathOfReleaseList
string getPathOfIndexList(const IndexEntry& entry) const;
/// @copydoc getPathOfReleaseList
string getPathOfExtendedStates() const;
/// @copydoc getPathOfReleaseList
string getDownloadUriOfReleaseList(const IndexEntry&) const;
/// @copydoc getPathOfReleaseList
vector< IndexDownloadRecord > getDownloadInfoOfIndexList(const IndexEntry&) const;
/// @copydoc getPathOfReleaseList
vector< LocalizationDownloadRecord > getDownloadInfoOfLocalizedDescriptions(const IndexEntry&) const;
/// gets system state
shared_ptr< const system::State > getSystemState() const;
/// gets pin value for a version
ssize_t getPin(const shared_ptr< const Version >&) const;
/// contains version and a corresponding pin value
struct PinnedVersion
{
shared_ptr< const Version > version; ///< version
ssize_t pin; ///< pin value
/// trivial constructor
PinnedVersion(shared_ptr< const Version > _version, ssize_t _pin)
: version(_version), pin(_pin) {}
};
/// gets list of versions with pins of certain package
vector< PinnedVersion > getSortedPinnedVersions(const shared_ptr< const Package >&) const;
/// gets version of highest pin from the package
shared_ptr< const Version > getPolicyVersion(const shared_ptr< const Package >&) const;
/// gets list of binary versions which satisfy given relation expression
vector< shared_ptr< const BinaryVersion > > getSatisfyingVersions(const RelationExpression&) const;
/// gets extended info
const ExtendedInfo& getExtendedInfo() const;
/// gets localized short and long descriptions for the binary version
/**
* @return first pair element - short description, long pair element - long description;
* if localized descriptions are not available, short description will be empty
*/
pair< string, string > getLocalizedDescriptions(const shared_ptr< const BinaryVersion >&) const;
/// @copydoc getPathOfReleaseList
static bool verifySignature(const shared_ptr< const Config >&, const string& path);
/// gets a supposed system path of package copyright file for certain binary version
/**
* You must not assume that the file actually exists even if installed
* version is passed as parameter.
*/
static string getPathOfCopyright(const shared_ptr< const BinaryVersion >&);
/// gets a supposed system path of package changelog file for certain binary version
/**
* You must not assume that the file actually exists even if installed
* version is passed as parameter.
*/
static string getPathOfChangelog(const shared_ptr< const BinaryVersion >&);
/// controls internal caching
/**
* If set to @c true, enables internal caching in methods @ref getPin and
* @ref getSatisfyingVersions. Defaults to @c false.
*/
static bool memoize;
};
}
#endif
|