Arbiter
Dependency manager library that supports decentralization
include
arbiter
Value.h
Go to the documentation of this file.
1
#
ifndef
ARBITER_VALUE_H
2
#
define
ARBITER_VALUE_H
3
4
#
ifdef
__cplusplus
5
extern
"C"
{
6
#
endif
7
8
#
include
<
stdbool
.
h
>
9
#
include
<
stddef
.
h
>
10
11
/**
12
* Represents an arbitrary value type that can be associated with Arbiter data
13
* types and functionality.
14
*
15
* For example, ArbiterProjectIdentifiers are defined by providing a user value
16
* type.
17
*/
18
typedef
struct
19
{
20
/**
21
* The underlying data object.
22
*
23
* This object should be considered to be owned by Arbiter as soon as the
24
* ArbiterUserValue is passed into any API. It will eventually be cleaned up
25
* by the library through invocation of the provided `destructor`.
26
*/
27
void
*
data
;
28
29
/**
30
* An equality operation over two data objects.
31
*
32
* This must not be NULL.
33
*/
34
bool
(*equalTo)(
const
void
*first,
const
void
*second);
35
36
/**
37
* Returns whether `first` is less than (should be ordered before) `second`.
38
*
39
* This must not be NULL.
40
*/
41
bool
(*lessThan)(
const
void
*first,
const
void
*second);
42
43
/**
44
* Generates a hash of the data object. The hash does not need to be
45
* cryptographically secure.
46
*
47
* This must not be NULL.
48
*/
49
size_t (*hash)(
const
void
*first);
50
51
/**
52
* An operation to convert this data object to a string. The returned value
53
* must be dynamically allocated and support being destroyed with free().
54
*
55
* This may be NULL.
56
*/
57
char
*(*
createDescription
)(
const
void
*data);
58
59
/**
60
* A cleanup function to call when the ArbiterUserValue is done being used.
61
*
62
* This may be NULL.
63
*/
64
void
(*
destructor
)(
void
*data);
65
} ArbiterUserValue;
66
67
/**
68
* Represents opaque data that can be passed to Arbiter data types and
69
* functionality, then later retrieved.
70
*
71
* This type is used instead of raw pointers to make memory management safer.
72
*/
73
typedef
struct
74
{
75
/**
76
* The underlying data pointer.
77
*
78
* This pointer should be considered to be owned by Arbiter as soon as the
79
* ArbiterUserContext is passed into any API. It will eventually be cleaned up
80
* by the library through invocation of the provided `destructor`.
81
*/
82
void
*
data
;
83
84
/**
85
* A cleanup function to call when the ArbiterUserContext is done being used.
86
*
87
* This may be NULL.
88
*/
89
void
(*
destructor
)(
void
*data);
90
} ArbiterUserContext;
91
92
#
ifdef
__cplusplus
93
}
94
#
endif
95
96
#
endif
ArbiterUserValue::createDescription
char *(* createDescription)(const void *data)
An operation to convert this data object to a string.
Definition:
Value.h:57
ArbiterUserValue::destructor
void(* destructor)(void *data)
A cleanup function to call when the ArbiterUserValue is done being used.
Definition:
Value.h:64
ArbiterUserContext::destructor
void(* destructor)(void *data)
A cleanup function to call when the ArbiterUserContext is done being used.
Definition:
Value.h:89
ArbiterUserValue::data
void * data
The underlying data object.
Definition:
Value.h:27
ArbiterUserContext::data
void * data
The underlying data pointer.
Definition:
Value.h:82
Generated on Mon Sep 26 2016 15:09:06 for Arbiter by
1.8.12