xref: /haiku/headers/os/package/solver/SolverRepository.h (revision 68ea01249e1e2088933cb12f9c28d4e5c5d1c9ef)
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 
15 namespace BPackageKit {
16 
17 
18 class BPackageInfo;
19 class BRepositoryCache;
20 class BRepositoryConfig;
21 class BSolverPackage;
22 
23 
24 class BSolverRepository {
25 public:
26 			enum BAllInstallationLocations {
27 				B_ALL_INSTALLATION_LOCATIONS
28 			};
29 
30 			typedef BPackageInfoSet::Iterator Iterator;
31 
32 public:
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 
73 private:
74 			typedef BObjectList<BSolverPackage> PackageList;
75 
76 private:
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