1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
-module(ataxia_entry).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-record
(
entry,
{
id :: any(),
read_perm :: ataxia_security:permission(),
write_perm :: ataxia_security:permission(),
lock :: ataxia_security:lock(),
val :: any()
}
).
-type type() :: #entry{}.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-export_type([type/0]).
-export
(
[
new/4,
get_id/1,
get_read_permission/1,
get_write_permission/1,
get_value/1,
set_read_permission/2,
set_write_permission/2,
set_value/2,
get_id_field/0,
get_record_info/0,
get_record_name/0
]
).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-spec new
(
any(),
ataxia_security:permission(),
ataxia_security:permission(),
any()
) -> type().
new (ID, ReadPermission, WritePermission, Value) ->
#entry
{
id = ID,
read_perm = ReadPermission,
write_perm = WritePermission,
lock = ataxia_security:unlocked(),
val = Value
}.
-spec get_id (type()) -> any().
get_id (#entry { id = Result }) -> Result.
-spec get_read_permission (type()) -> ataxia_security:permission().
get_read_permission (#entry { read_perm = Result }) -> Result.
-spec get_write_permission (type()) -> ataxia_security:permission().
get_write_permission (#entry { write_perm = Result }) -> Result.
-spec get_value (type()) -> any().
get_value (#entry { val = Result }) -> Result.
-spec set_read_permission (ataxia_security:permission(), type()) -> type().
set_read_permission (Perm, Item) -> Item#entry{ read_perm = Perm }.
-spec set_write_permission (ataxia_security:permission(), type()) -> type().
set_write_permission (Perm, Item) -> Item#entry{ write_perm = Perm }.
-spec set_value (any(), type()) -> type().
set_value (Value, Item) -> Item#entry{ val = Value }.
-spec get_id_field () -> non_neg_integer().
get_id_field () -> #entry.id.
get_record_info () -> record_info(fields, entry).
get_record_name () -> entry.
|