xref: /haiku/headers/os/package/solver/Solver.h (revision 2b76973fa2401f7a5edf68e6470f3d3210cbcff3)
1 /*
2  * Copyright 2013, Haiku, Inc. All Rights Reserved.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef _PACKAGE__SOLVER_H_
6 #define _PACKAGE__SOLVER_H_
7 
8 
9 #include <ObjectList.h>
10 #include <SupportDefs.h>
11 
12 
13 namespace BPackageKit {
14 
15 
16 class BSolverPackage;
17 class BSolverPackageSpecifier;
18 class BSolverPackageSpecifierList;
19 class BSolverProblem;
20 class BSolverProblemSolution;
21 class BSolverRepository;
22 class BSolverResult;
23 
24 
25 class BSolver {
26 public:
27 			// FindPackages() flags
28 			enum {
29 				B_FIND_CASE_INSENSITIVE		= 0x01,
30 				B_FIND_IN_NAME				= 0x02,
31 				B_FIND_IN_SUMMARY			= 0x04,
32 				B_FIND_IN_DESCRIPTION		= 0x08,
33 				B_FIND_IN_PROVIDES			= 0x10,
34 				B_FIND_INSTALLED_ONLY		= 0x20,
35 			};
36 
37 			// VerifyInstallation() flags
38 			enum {
39 				B_VERIFY_ALLOW_UNINSTALL	= 0x01,
40 			};
41 
42 public:
43 	virtual						~BSolver();
44 
45 	static	status_t			Create(BSolver*& _solver);
46 
47 	virtual	status_t			Init() = 0;
48 
49 	virtual	status_t			AddRepository(
50 									BSolverRepository* repository) = 0;
51 
52 	virtual	status_t			FindPackages(const char* searchString,
53 									uint32 flags,
54 									BObjectList<BSolverPackage>& _packages) = 0;
55 	virtual	status_t			FindPackages(
56 									const BSolverPackageSpecifierList& packages,
57 									uint32 flags,
58 									BObjectList<BSolverPackage>& _packages,
59 									const BSolverPackageSpecifier** _unmatched
60 										= NULL) = 0;
61 
62 	virtual	status_t			Install(
63 									const BSolverPackageSpecifierList& packages,
64 									const BSolverPackageSpecifier** _unmatched
65 										= NULL) = 0;
66 	virtual	status_t			Uninstall(
67 									const BSolverPackageSpecifierList& packages,
68 									const BSolverPackageSpecifier** _unmatched
69 										= NULL) = 0;
70 	virtual	status_t			Update(
71 									const BSolverPackageSpecifierList& packages,
72 									bool installNotYetInstalled,
73 									const BSolverPackageSpecifier** _unmatched
74 										= NULL) = 0;
75 	virtual	status_t			VerifyInstallation(uint32 flags = 0) = 0;
76 
77 			bool				HasProblems() const
78 									{ return CountProblems() > 0; }
79 	virtual	int32				CountProblems() const = 0;
80 	virtual	BSolverProblem*		ProblemAt(int32 index) const = 0;
81 
82 	virtual	status_t			SelectProblemSolution(
83 									BSolverProblem* problem,
84 									const BSolverProblemSolution* solution) = 0;
85 	virtual	status_t			SolveAgain() = 0;
86 
87 	virtual	status_t			GetResult(BSolverResult& _result) = 0;
88 
89 protected:
90 								BSolver();
91 };
92 
93 
94 // function exported by the libsolv based add-on
95 extern "C" BSolver* create_solver();
96 
97 
98 }	// namespace BPackageKit
99 
100 
101 #endif // _PACKAGE__SOLVER_H_
102