]> cygwin.com Git - cygwin-apps/setup.git/blame - libsolv.h
Change to using a libsolv pool for storing package information
[cygwin-apps/setup.git] / libsolv.h
CommitLineData
1c159e0a
JT
1/*
2 * Copyright (c) 2017 Jon Turney
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * A copy of the GNU General Public License can be found at
10 * http://www.gnu.org/
11 *
12 */
13
14#ifndef LIBSOLV_H
15#define LIBSOLV_H
16
17#include "solv/pool.h"
18#include "solv/repo.h"
19#include "PackageSpecification.h"
20#include "PackageTrust.h"
21#include "package_source.h"
22#include "package_depends.h"
23#include <map>
24#include <vector>
25
26typedef trusts package_stability_t;
27
28typedef enum
29{
30 package_binary,
31 package_source
32}
33package_type_t;
34
35// ---------------------------------------------------------------------------
36// interface to class SolverVersion
37//
38// a wrapper around a libsolv Solvable
39// ---------------------------------------------------------------------------
40
41class SolverPool;
42
43class SolvableVersion
44{
45 public:
46 SolvableVersion() : id(0), pool(0) {};
47 SolvableVersion(Id _id, Pool *_pool) : id(_id), pool(_pool) {};
48
49 // converted to a bool, this is true if this isn't the result of the default
50 // constructor (an 'empty' version, in some sense)
51 explicit operator bool () const { return (id != 0); }
52
53 const std::string Name () const;
54 const std::string SDesc () const;
55 // In setup-speak, 'Canonical' version means 'e:v-r', the non-decomposed version
56 const std::string Canonical_version () const;
57 const PackageDepends depends() const;
58 bool accessible () const;
59 package_type_t Type () const;
60 package_stability_t Stability () const;
61 // the associated source package, if this is a binary package
62 SolvableVersion sourcePackage () const;
63 // where this package archive can be obtained from
64 packagesource *source() const;
65
66 // utility function to compare package versions
67 static int compareVersions(const SolvableVersion &a, const SolvableVersion &b);
68
69 // comparison operators
70
71 // these are somewhat necessary as otherwise we are compared as bool values
72 bool operator == (SolvableVersion const &) const;
73 bool operator != (SolvableVersion const &) const;
74
75 // these are only well defined for versions of the same package
76 bool operator < (SolvableVersion const &) const;
77 bool operator <= (SolvableVersion const &) const;
78 bool operator > (SolvableVersion const &) const;
79 bool operator >= (SolvableVersion const &) const;
80
81 private:
82 Id id;
83 Pool *pool;
84
85 friend SolverPool;
86};
87
88// ---------------------------------------------------------------------------
89// Helper class SolvRepo
90//
91// ---------------------------------------------------------------------------
92
93class SolvRepo
94{
95public:
96 Repo *repo;
97 Repodata *data;
98 bool test;
99};
100
101// ---------------------------------------------------------------------------
102// interface to class SolverPool
103//
104// a simplified wrapper for libsolv
105// ---------------------------------------------------------------------------
106
107class SolverPool
108{
109public:
110 SolverPool();
111 SolvRepo *getRepo(const std::string &name, bool test = false);
112
113 // Utility class for passing arguments to addPackage()
114 class addPackageData
115 {
116 public:
117 std::string reponame;
118 std::string version;
119 std::string vendor;
120 std::string sdesc;
121 std::string ldesc;
122 package_stability_t stability;
123 package_type_t type;
124 packagesource archive;
125 PackageSpecification spkg;
126 SolvableVersion spkg_id;
127 PackageDepends *requires;
128 };
129
130 SolvableVersion addPackage(const std::string& pkgname,
131 const addPackageData &pkgdata);
132
133 void internalize(void);
134
135private:
136 Id makedeps(Repo *repo, PackageDepends *requires);
137 Pool *pool;
138
139 typedef std::map<std::string, SolvRepo *> RepoList;
140 RepoList repos;
141};
142
143
144#endif // LIBSOLV_H
This page took 0.034713 seconds and 5 git commands to generate.