xref: /haiku/headers/os/package/solver/Solver.h (revision 8e8f7748d39f8407894a5ab79f7b4f93bc4f4652)
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			FullSync() = 0;
76 	virtual	status_t			VerifyInstallation(uint32 flags = 0) = 0;
77 
78 			bool				HasProblems() const
79 									{ return CountProblems() > 0; }
80 	virtual	int32				CountProblems() const = 0;
81 	virtual	BSolverProblem*		ProblemAt(int32 index) const = 0;
82 
83 	virtual	status_t			SelectProblemSolution(
84 									BSolverProblem* problem,
85 									const BSolverProblemSolution* solution) = 0;
86 	virtual	status_t			SolveAgain() = 0;
87 
88 	virtual	status_t			GetResult(BSolverResult& _result) = 0;
89 
90 protected:
91 								BSolver();
92 };
93 
94 
95 // function exported by the libsolv based add-on
96 extern "C" BSolver* create_solver();
97 
98 
99 }	// namespace BPackageKit
100 
101 
102 #endif // _PACKAGE__SOLVER_H_
103