1with Agar.Core.Thin;
2
3package Agar.Core.Database is
4
5  subtype Database_Access_t          is Thin.DB.DB_Access_t;
6  subtype Database_Not_Null_Access_t is Thin.DB.DB_Not_Null_Access_t;
7
8  type Type_t is new Thin.DB.Type_t;
9
10  procedure New_Database
11    (Database_Type : in     Type_t;
12     Database      :    out Database_Access_t);
13
14  procedure Sync
15    (Database : in Database_Not_Null_Access_t)
16      renames Thin.DB.Sync;
17
18  generic
19    type Key_Type         is private;
20    type Key_Type_Access  is access all Key_Type;
21    type Data_Type        is private;
22    type Data_Type_Access is access all Data_Type;
23
24  package Generic_Database is
25
26    type Entry_t is record
27      Key       : Key_Type_Access;
28      Key_Size  : Natural;
29      Data      : Data_Type_Access;
30      Data_Size : Natural;
31    end record;
32
33    Null_Entry : constant Entry_t :=
34      (Key       => null,
35       Key_Size  => 0,
36       Data      => null,
37       Data_Size => 0);
38
39    function Exists
40      (Database : in Database_Not_Null_Access_t;
41       Key      : in Key_Type) return Boolean;
42
43    procedure Lookup
44      (Database       : in     Database_Not_Null_Access_t;
45       Key            : in     Key_Type;
46       Database_Entry :    out Entry_t;
47       Found          :    out Boolean);
48
49    function Delete
50      (Database : in Database_Not_Null_Access_t;
51       Key      : in Key_Type) return Boolean;
52
53    function Put
54      (Database : in Database_Not_Null_Access_t;
55       Key      : in Key_Type_Access;
56       Data     : in Data_Type_Access) return Boolean;
57
58  end Generic_Database;
59
60end Agar.Core.Database;
61