BRepositoryCache: Add iteration, etc.

* Remove InitCheck() and the initializing constructor.
* Rename PackageCount() to CountPackages().
* Use BOpenHashTable instead of HashMap for the internal PackageMap.
* Allow multiple packages with the same name. Equally named packages are
  in a singly linked list after the first package with that name.
* Add an Iterator inner class and a GetIterator() method, so one can now
  iterate through the packages in the repository.
This commit is contained in:
Ingo Weinhold
2011-11-25 06:19:44 +01:00
parent 156ea481b3
commit 4f5f15f080
3 changed files with 211 additions and 40 deletions
+33 -5
View File
@@ -15,14 +15,18 @@
namespace BPackageKit {
class BPackageInfo;
class BRepositoryCache {
public:
class Iterator;
public:
BRepositoryCache();
BRepositoryCache(const BEntry& entry);
virtual ~BRepositoryCache();
status_t SetTo(const BEntry& entry);
status_t InitCheck() const;
const BRepositoryInfo& Info() const;
const BEntry& Entry() const;
@@ -30,14 +34,19 @@ public:
void SetIsUserSpecific(bool isUserSpecific);
uint32 PackageCount() const;
uint32 CountPackages() const;
Iterator GetIterator() const;
private:
struct PackageInfo;
struct PackageInfoHashDefinition;
struct PackageMap;
struct RepositoryContentHandler;
struct StandardErrorOutput;
friend class Iterator;
private:
status_t fInitStatus;
BEntry fEntry;
BRepositoryInfo fInfo;
bool fIsUserSpecific;
@@ -46,6 +55,25 @@ private:
};
class BRepositoryCache::Iterator {
public:
Iterator();
bool HasNext() const;
const BPackageInfo* Next();
private:
Iterator(const BRepositoryCache* cache);
private:
friend class BRepositoryCache;
private:
const BRepositoryCache* fCache;
PackageInfo* fNextInfo;
};
} // namespace BPackageKit