| 1 | // -*- mode: cpp; mode: fold -*- |
| 2 | // Description /*{{{*/ |
| 3 | /* ###################################################################### |
| 4 | Set of methods to help writing and reading everything needed for EDSP |
| 5 | ##################################################################### */ |
| 6 | /*}}}*/ |
| 7 | #ifndef PKGLIB_EDSP_H |
| 8 | #define PKGLIB_EDSP_H |
| 9 | |
| 10 | #include <apt-pkg/depcache.h> |
| 11 | #include <apt-pkg/cacheset.h> |
| 12 | |
| 13 | #include <string> |
| 14 | |
| 15 | class EDSP /*{{{*/ |
| 16 | { |
| 17 | // we could use pkgCache::DepType and ::Priority, but these would be localized stringsā¦ |
| 18 | static const char * const PrioMap[]; |
| 19 | static const char * const DepMap[]; |
| 20 | |
| 21 | bool static ReadLine(int const input, std::string &line); |
| 22 | bool static StringToBool(char const *answer, bool const defValue); |
| 23 | |
| 24 | void static WriteScenarioVersion(pkgDepCache &Cache, FILE* output, |
| 25 | pkgCache::PkgIterator const &Pkg, |
| 26 | pkgCache::VerIterator const &Ver); |
| 27 | void static WriteScenarioDependency(pkgDepCache &Cache, FILE* output, |
| 28 | pkgCache::PkgIterator const &Pkg, |
| 29 | pkgCache::VerIterator const &Ver); |
| 30 | void static WriteScenarioLimitedDependency(pkgDepCache &Cache, FILE* output, |
| 31 | pkgCache::PkgIterator const &Pkg, |
| 32 | pkgCache::VerIterator const &Ver, |
| 33 | APT::PackageSet const &pkgset); |
| 34 | public: |
| 35 | bool static WriteRequest(pkgDepCache &Cache, FILE* output, |
| 36 | bool const upgrade = false, |
| 37 | bool const distUpgrade = false, |
| 38 | bool const autoRemove = false); |
| 39 | bool static WriteScenario(pkgDepCache &Cache, FILE* output); |
| 40 | bool static WriteLimitedScenario(pkgDepCache &Cache, FILE* output, |
| 41 | APT::PackageSet const &pkgset); |
| 42 | bool static ReadResponse(int const input, pkgDepCache &Cache); |
| 43 | |
| 44 | // ReadScenario is provided by the listparser infrastructure |
| 45 | bool static ReadRequest(int const input, std::list<std::string> &install, |
| 46 | std::list<std::string> &remove, bool &upgrade, |
| 47 | bool &distUpgrade, bool &autoRemove); |
| 48 | bool static ApplyRequest(std::list<std::string> const &install, |
| 49 | std::list<std::string> const &remove, |
| 50 | pkgDepCache &Cache); |
| 51 | bool static WriteSolution(pkgDepCache &Cache, FILE* output); |
| 52 | bool static WriteProgress(unsigned short const percent, const char* const message, FILE* output); |
| 53 | bool static WriteError(std::string const &message, FILE* output); |
| 54 | |
| 55 | bool static ExecuteSolver(const char* const solver, int *solver_in, int *solver_out); |
| 56 | bool static ResolveExternal(const char* const solver, pkgDepCache &Cache, |
| 57 | bool const upgrade, bool const distUpgrade, |
| 58 | bool const autoRemove); |
| 59 | }; |
| 60 | /*}}}*/ |
| 61 | #endif |