agpl_1.0.0_b5da3320/src/agpl-trace-buffer.ads

 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
with Ada.Calendar;
with Ada.Containers.Doubly_Linked_Lists;
with Agpl.Ustrings; use Agpl.Ustrings;
with Agpl.Trace.Root;

package Agpl.Trace.Buffer is

   type Object (Max_Length : Natural) is new Root.Object with private;
   --  Stores at most Max_Length log messages

   type Object_Access is access all Object'Class;

   pragma Preelaborable_Initialization (Object);

   type Log_Entry is record
      Level : Levels;
      Text  : Ustring;
      Sect  : Ustring;
      Stamp : Ada.Calendar.Time;
   end record;

   overriding
   procedure Log (This    : in out Object;
                  Text    : in String;
                  Level   : in Levels;
                  Section : in String := "");

   package Entry_Lists is new Ada.Containers.Doubly_Linked_Lists (Log_Entry);

   not overriding
   function Get (This : Object) return Entry_Lists.List;

private

   protected type Safe (Max_Length : Natural) is

      procedure Add (X : Log_Entry);

      function Get return Entry_Lists.List;

   private

      Entries : Entry_Lists.List;

   end Safe;

   type Object (Max_Length : Natural) is new Root.Object with record
      Entries : Safe (Max_Length);
   end record;

end Agpl.Trace.Buffer;