xref: /haiku/headers/os/package/solver/SolverRepository.h (revision a8b832bf461cc0a4325302d929067c19f4e7aedf)
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 BRepositoryConfig;
20 class BSolverPackage;
21 
22 
23 class BSolverRepository {
24 public:
25 			enum BAllInstallationLocations {
26 				B_ALL_INSTALLATION_LOCATIONS
27 			};
28 
29 			typedef BPackageInfoSet::Iterator Iterator;
30 
31 public:
32 								BSolverRepository();
33 								BSolverRepository(const BString& name);
34 								BSolverRepository(
35 									BPackageInstallationLocation location);
36 								BSolverRepository(BAllInstallationLocations);
37 								BSolverRepository(
38 									const BRepositoryConfig& config);
39 								~BSolverRepository();
40 
41 			status_t			SetTo(const BString& name);
42 			status_t			SetTo(BPackageInstallationLocation location);
43 			status_t			SetTo(BAllInstallationLocations);
44 			status_t			SetTo(const BRepositoryConfig& config);
45 			void				Unset();
46 
47 			status_t			InitCheck();
48 
49 			bool				IsInstalled() const;
50 			void				SetInstalled(bool isInstalled);
51 
52 			BString				Name() const;
53 
54 			uint8				Priority() const;
55 			void				SetPriority(uint8 priority);
56 
57 			bool				IsEmpty() const;
58 			int32				CountPackages() const;
59 			BSolverPackage*		PackageAt(int32 index) const;
60 
61 			status_t			AddPackage(const BPackageInfo& info,
62 									BSolverPackage** _package = NULL);
63 			status_t			AddPackages(
64 									BPackageInstallationLocation location);
65 
66 private:
67 			typedef BObjectList<BSolverPackage> PackageList;
68 
69 private:
70 			BString				fName;
71 			uint8				fPriority;
72 			bool				fIsInstalled;
73 			PackageList			fPackages;
74 };
75 
76 
77 }	// namespace BPackageKit
78 
79 
80 #endif // _PACKAGE__SOLVER_REPOSITORY_H_
81