1/*
2 * Copyright 2013, Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
4 */
5#ifndef _PACKAGE__SOLVER_REPOSITORY_H_
6#define _PACKAGE__SOLVER_REPOSITORY_H_
7
8
9#include <ObjectList.h>
10#include <package/PackageDefs.h>
11#include <package/PackageInfoSet.h>
12#include <String.h>
13
14
15namespace BPackageKit {
16
17
18class BPackageInfo;
19class BRepositoryCache;
20class BRepositoryConfig;
21class BSolverPackage;
22
23
24class BSolverRepository {
25public:
26			enum BAllInstallationLocations {
27				B_ALL_INSTALLATION_LOCATIONS
28			};
29
30			typedef BPackageInfoSet::Iterator Iterator;
31
32public:
33								BSolverRepository();
34								BSolverRepository(const BString& name);
35								BSolverRepository(
36									BPackageInstallationLocation location);
37								BSolverRepository(BAllInstallationLocations);
38								BSolverRepository(
39									const BRepositoryConfig& config);
40	virtual						~BSolverRepository();
41
42			status_t			SetTo(const BString& name);
43			status_t			SetTo(BPackageInstallationLocation location);
44			status_t			SetTo(BAllInstallationLocations);
45			status_t			SetTo(const BRepositoryConfig& config);
46			status_t			SetTo(const BRepositoryCache& cache);
47			void				Unset();
48
49			status_t			InitCheck();
50
51			bool				IsInstalled() const;
52			void				SetInstalled(bool isInstalled);
53
54			BString				Name() const;
55
56			int32				Priority() const;
57			void				SetPriority(int32 priority);
58									// negative priority is fine
59
60			bool				IsEmpty() const;
61			int32				CountPackages() const;
62			BSolverPackage*		PackageAt(int32 index) const;
63
64			status_t			AddPackage(const BPackageInfo& info,
65									BSolverPackage** _package = NULL);
66			status_t			AddPackages(
67									BPackageInstallationLocation location);
68			bool				RemovePackage(BSolverPackage* package);
69			bool				DeletePackage(BSolverPackage* package);
70
71			uint64				ChangeCount() const;
72
73private:
74			typedef BObjectList<BSolverPackage> PackageList;
75
76private:
77			BString				fName;
78			int32				fPriority;
79			bool				fIsInstalled;
80			PackageList			fPackages;
81			uint64				fChangeCount;
82};
83
84
85}	// namespace BPackageKit
86
87
88#endif // _PACKAGE__SOLVER_REPOSITORY_H_
89