Arbiter
Dependency manager library that supports decentralization
Dependency.h
Go to the documentation of this file.
1 #ifndef ARBITER_DEPENDENCY_H
2 #define ARBITER_DEPENDENCY_H
3 
4 #ifdef __cplusplus
5 extern "C" {
6 #endif
7 
8 #include <arbiter/Value.h>
9 
10 #include <stddef.h>
11 
12 // forward declarations
13 struct ArbiterRequirement;
14 struct ArbiterSelectedVersion;
15 
16 /**
17  * An opaque value which identifies a project participating in dependency
18  * resolution.
19  */
20 typedef struct ArbiterProjectIdentifier ArbiterProjectIdentifier;
21 
22 /**
23  * Creates a project identifier from the given opaque data.
24  *
25  * The returned identifier must be freed with ArbiterFree().
26  */
27 ArbiterProjectIdentifier *ArbiterCreateProjectIdentifier (ArbiterUserValue value);
28 
29 /**
30  * Returns the opaque data which was provided to ArbiterCreateProjectIdentifier().
31  *
32  * The returned pointer is only guaranteed to remain valid for the current
33  * scope.
34  */
35 const void *ArbiterProjectIdentifierValue (const ArbiterProjectIdentifier *projectIdentifier);
36 
37 /**
38  * Represents a dependency specification, which consists of a project identifier
39  * and a version requirement.
40  */
41 typedef struct ArbiterDependency ArbiterDependency;
42 
43 /**
44  * Creates a dependency which specifies a version requirement of the given
45  * project.
46  *
47  * The returned dependency must be freed with ArbiterFree().
48  */
49 ArbiterDependency *ArbiterCreateDependency (const ArbiterProjectIdentifier *projectIdentifier, const struct ArbiterRequirement *requirement);
50 
51 /**
52  * Returns the project identified by this dependency.
53  *
54  * The returned pointer is only guaranteed to remain valid for the current
55  * scope.
56  */
57 const ArbiterProjectIdentifier *ArbiterDependencyProject (const ArbiterDependency *dependency);
58 
59 /**
60  * Returns the version requirement of this dependency.
61  *
62  * The returned pointer is only guaranteed to remain valid for the current
63  * scope.
64  */
65 const struct ArbiterRequirement *ArbiterDependencyRequirement (const ArbiterDependency *dependency);
66 
67 /**
68  * Represents a list of dependencies.
69  */
70 typedef struct ArbiterDependencyList ArbiterDependencyList;
71 
72 /**
73  * Creates a dependency list which wraps a C array of ArbiterDependency objects.
74  *
75  * The objects in the C array can be safely freed after calling this function.
76  *
77  * The returned list must be freed with ArbiterFree().
78  */
79 ArbiterDependencyList *ArbiterCreateDependencyList (const ArbiterDependency * const *dependencies, size_t count);
80 
81 /**
82  * Represents a dependency which has been resolved to a specific version.
83  */
84 typedef struct ArbiterResolvedDependency ArbiterResolvedDependency;
85 
86 /**
87  * Creates a fully resolved dependency referring to the specified version of the
88  * given project.
89  *
90  * The returned dependency must be freed with ArbiterFree().
91  */
92 ArbiterResolvedDependency *ArbiterCreateResolvedDependency (const ArbiterProjectIdentifier *project, const struct ArbiterSelectedVersion *version);
93 
94 /**
95  * Returns the project this resolved dependency refers to.
96  *
97  * The returned pointer is only guaranteed to remain valid for the current
98  * scope.
99  */
100 const ArbiterProjectIdentifier *ArbiterResolvedDependencyProject (const ArbiterResolvedDependency *dependency);
101 
102 /**
103  * Returns the version which was selected for this resolved dependency.
104  *
105  * The returned pointer is only guaranteed to remain valid for the current
106  * scope.
107  */
108 const struct ArbiterSelectedVersion *ArbiterResolvedDependencyVersion (const ArbiterResolvedDependency *dependency);
109 
110 #ifdef __cplusplus
111 }
112 #endif
113 
114 #endif
const struct ArbiterSelectedVersion * ArbiterResolvedDependencyVersion(const ArbiterResolvedDependency *dependency)
Returns the version which was selected for this resolved dependency.
std::unique_ptr< Arbiter::Base > clone() const override
ArbiterProjectIdentifier * ArbiterCreateProjectIdentifier(ArbiterUserValue value)
Creates a project identifier from the given opaque data.
const void * ArbiterProjectIdentifierValue(const ArbiterProjectIdentifier *projectIdentifier)
Returns the opaque data which was provided to ArbiterCreateProjectIdentifier().
const struct ArbiterRequirement * ArbiterDependencyRequirement(const ArbiterDependency *dependency)
Returns the version requirement of this dependency.
ArbiterResolvedDependency * ArbiterCreateResolvedDependency(const ArbiterProjectIdentifier *project, const struct ArbiterSelectedVersion *version)
Creates a fully resolved dependency referring to the specified version of the given project...
const ArbiterProjectIdentifier * ArbiterDependencyProject(const ArbiterDependency *dependency)
Returns the project identified by this dependency.
ArbiterDependencyList * ArbiterCreateDependencyList(const ArbiterDependency *const *dependencies, size_t count)
Creates a dependency list which wraps a C array of ArbiterDependency objects.
ArbiterDependency * ArbiterCreateDependency(const ArbiterProjectIdentifier *projectIdentifier, const struct ArbiterRequirement *requirement)
Creates a dependency which specifies a version requirement of the given project.
const ArbiterProjectIdentifier * ArbiterResolvedDependencyProject(const ArbiterResolvedDependency *dependency)
Returns the project this resolved dependency refers to.
virtual std::unique_ptr< ArbiterRequirement > intersect(const ArbiterRequirement &rhs) const =0
Attempts to create a requirement which expresses the intersection of this requirement and the given o...