Cupt
|
00001 /************************************************************************** 00002 * Copyright (C) 2010 by Eugene V. Lyubimkin * 00003 * * 00004 * This program is free software; you can redistribute it and/or modify * 00005 * it under the terms of the GNU General Public License * 00006 * (version 3 or above) as published by the Free Software Foundation. * 00007 * * 00008 * This program is distributed in the hope that it will be useful, * 00009 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00010 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00011 * GNU General Public License for more details. * 00012 * * 00013 * You should have received a copy of the GNU GPL * 00014 * along with this program; if not, write to the * 00015 * Free Software Foundation, Inc., * 00016 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA * 00017 **************************************************************************/ 00018 #ifndef CUPT_CACHE_CACHE_SEEN 00019 #define CUPT_CACHE_CACHE_SEEN 00020 00022 00023 #include <boost/xpressive/xpressive_fwd.hpp> 00024 00025 #include <set> 00026 00027 #include <cupt/common.hpp> 00028 #include <cupt/fwd.hpp> 00029 #include <cupt/hashsums.hpp> 00030 00031 namespace cupt { 00032 00033 namespace internal { 00034 00035 struct CacheImpl; 00036 00037 } 00038 00039 using std::set; 00040 00041 using namespace cache; 00042 00044 class CUPT_API Cache 00045 { 00046 public: 00048 00052 struct IndexEntry 00053 { 00055 enum Type { Source, Binary } category; 00056 string uri; 00057 string distribution; 00058 string component; 00059 }; 00061 struct IndexDownloadRecord 00062 { 00063 string uri; 00064 uint32_t size; 00065 HashSums hashSums; 00066 }; 00068 struct LocalizationDownloadRecord 00069 { 00070 string uri; 00071 string localPath; 00072 }; 00074 struct ExtendedInfo 00075 { 00076 set< string > automaticallyInstalled; 00077 }; 00078 00079 private: 00080 internal::CacheImpl* __impl; 00081 Cache(const Cache&); 00082 Cache& operator=(const Cache&); 00083 public: 00085 00094 Cache(shared_ptr< const Config > config, bool useSource, bool useBinary, bool useInstalled, 00095 const vector< string >& packageNameGlobsToReinstall = vector< string >()); 00097 virtual ~Cache(); 00098 00100 vector< shared_ptr< const ReleaseInfo > > getBinaryReleaseData() const; 00102 vector< shared_ptr< const ReleaseInfo > > getSourceReleaseData() const; 00103 00105 vector< string > getBinaryPackageNames() const; 00107 00111 shared_ptr< const BinaryPackage > getBinaryPackage(const string& packageName) const; 00113 vector< string > getSourcePackageNames() const; 00115 00119 shared_ptr< const SourcePackage > getSourcePackage(const string& packageName) const; 00120 00122 vector< shared_ptr< const BinaryVersion > > getInstalledVersions() const; 00123 00125 00129 bool isAutomaticallyInstalled(const string& packageName) const; 00130 00132 vector< IndexEntry > getIndexEntries() const; 00133 00135 string getPathOfReleaseList(const IndexEntry& entry) const; 00137 string getPathOfIndexList(const IndexEntry& entry) const; 00139 string getPathOfExtendedStates() const; 00140 00142 string getDownloadUriOfReleaseList(const IndexEntry&) const; 00144 vector< IndexDownloadRecord > getDownloadInfoOfIndexList(const IndexEntry&) const; 00146 vector< LocalizationDownloadRecord > getDownloadInfoOfLocalizedDescriptions(const IndexEntry&) const; 00147 00149 shared_ptr< const system::State > getSystemState() const; 00150 00152 ssize_t getPin(const shared_ptr< const Version >&) const; 00153 00155 struct PinnedVersion 00156 { 00157 shared_ptr< const Version > version; 00158 ssize_t pin; 00159 00161 PinnedVersion(shared_ptr< const Version > _version, ssize_t _pin) 00162 : version(_version), pin(_pin) {} 00163 }; 00165 vector< PinnedVersion > getSortedPinnedVersions(const shared_ptr< const Package >&) const; 00167 shared_ptr< const Version > getPolicyVersion(const shared_ptr< const Package >&) const; 00168 00170 vector< shared_ptr< const BinaryVersion > > getSatisfyingVersions(const RelationExpression&) const; 00171 00173 const ExtendedInfo& getExtendedInfo() const; 00174 00176 00180 pair< string, string > getLocalizedDescriptions(const shared_ptr< const BinaryVersion >&) const; 00181 00183 static bool verifySignature(const shared_ptr< const Config >&, const string& path); 00185 00189 static string getPathOfCopyright(const shared_ptr< const BinaryVersion >&); 00191 00195 static string getPathOfChangelog(const shared_ptr< const BinaryVersion >&); 00196 00198 00202 static bool memoize; 00203 }; 00204 00205 } 00206 00207 #endif 00208