/usr/include/cupt/cache.hpp is in libcupt4-dev 2.9.9.
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 | /**************************************************************************
* 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 <set>
#include <map>
#include <cupt/common.hpp>
#include <cupt/fwd.hpp>
#include <cupt/range.hpp>
namespace cupt {
namespace internal {
class CacheImpl;
}
using std::set;
using std::map;
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
map< string, string > options; ///< key-value options;
};
/// extended package information
struct ExtendedInfo
{
typedef map<string, map<string, string>> Raw;
Raw raw; ///< all fields and values in the format "map: (package name) -> (map: field -> value)"
set< string > automaticallyInstalled; ///< names of automatically installed packages
};
class PackageNameIterator
{
public:
typedef const string value_type;
class Impl;
PackageNameIterator(Impl* impl);
~PackageNameIterator();
PackageNameIterator(const PackageNameIterator&);
PackageNameIterator& operator=(const PackageNameIterator&);
PackageNameIterator(PackageNameIterator&&) = default;
bool operator==(const PackageNameIterator&) const;
bool operator!=(const PackageNameIterator&) const;
value_type& operator*() const;
PackageNameIterator& operator++();
private:
Impl* p_impl;
};
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)
*/
Cache(shared_ptr< const Config > config, bool useSource, bool useBinary, bool useInstalled);
/// 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
Range< PackageNameIterator > getBinaryPackageNames() const;
/// gets BinaryPackage by name
/**
* @param packageName name of the binary package
* @return pointer to binary package if found, empty pointer if not
*/
const BinaryPackage* getBinaryPackage(const string& packageName) const;
/// gets the list of names of available source packages
Range< PackageNameIterator > getSourcePackageNames() const;
/// gets SourcePackage by name
/**
* @param packageName name of the source package
* @return pointer to source package if found, empty pointer if not
*/
const SourcePackage* getSourcePackage(const string& packageName) const;
/// gets all installed versions
vector< 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;
/// gets system state
const system::State* getSystemState() const;
/// gets pin value for a version
ssize_t getPin(const Version*) const;
/// contains version and its corresponding priority
struct VersionWithPriority
{
const Version* version;
ssize_t priority;
};
/// gets list of versions with priorities of certain package
vector<VersionWithPriority> getSortedVersionsWithPriorities(const Package*) const;
/// gets version of highest pin from the package
const Version* getPreferredVersion(const Package*) const;
/// gets list of binary versions which satisfy given relation expression
vector< const BinaryVersion* > getSatisfyingVersions(const RelationExpression&) const;
/// gets extended info
const ExtendedInfo& getExtendedInfo() const;
/// gets localized description for the binary version
/**
* @return localized description if available, version description otherwise
*/
string getLocalizedDescription(const BinaryVersion*) const;
/// 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 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 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
|