mirror of
https://review.haiku-os.org/haiku
synced 2025-01-24 07:14:48 +01:00
711a2a6eea
* Implement copy-on-write support. * Add copy constructor and assignment operator. * Remove Init(). Initialize lazily instead. Since AddInfo() can fail and we check initialization anyway, there's no point in having an explicit Init(). Given that there was only one invocation of Init() in the package kit and its users, it was very likely missing in some places. * Fix a few places where we ignored that the PackageMap actually contains lists of PackageInfo objects.
71 lines
1.1 KiB
C++
71 lines
1.1 KiB
C++
/*
|
|
* Copyright 2011, Haiku, Inc.
|
|
* Distributed under the terms of the MIT License.
|
|
*/
|
|
#ifndef _PACKAGE_PACKAGE_INFO_SET_H_
|
|
#define _PACKAGE_PACKAGE_INFO_SET_H_
|
|
|
|
|
|
#include <SupportDefs.h>
|
|
|
|
|
|
namespace BPackageKit {
|
|
|
|
|
|
class BPackageInfo;
|
|
|
|
|
|
class BPackageInfoSet {
|
|
public:
|
|
class Iterator;
|
|
|
|
public:
|
|
BPackageInfoSet();
|
|
BPackageInfoSet(const BPackageInfoSet& other);
|
|
virtual ~BPackageInfoSet();
|
|
|
|
status_t AddInfo(const BPackageInfo& info);
|
|
void MakeEmpty();
|
|
|
|
uint32 CountInfos() const;
|
|
Iterator GetIterator() const;
|
|
|
|
BPackageInfoSet& operator=(const BPackageInfoSet& other);
|
|
|
|
private:
|
|
bool _CopyOnWrite();
|
|
|
|
private:
|
|
struct PackageInfo;
|
|
struct PackageInfoHashDefinition;
|
|
struct PackageMap;
|
|
|
|
friend class Iterator;
|
|
|
|
private:
|
|
PackageMap* fPackageMap;
|
|
};
|
|
|
|
|
|
class BPackageInfoSet::Iterator {
|
|
public:
|
|
Iterator();
|
|
Iterator(const PackageMap* map);
|
|
|
|
bool HasNext() const;
|
|
const BPackageInfo* Next();
|
|
|
|
private:
|
|
friend class BRepositoryCache;
|
|
|
|
private:
|
|
const PackageMap* fMap;
|
|
PackageInfo* fNextInfo;
|
|
};
|
|
|
|
|
|
} // namespace BPackageKit
|
|
|
|
|
|
#endif // _PACKAGE_PACKAGE_INFO_SET_H_
|