agpl_1.0.0_b5da3320/src/agpl-drawing-multisource.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
private with Ada.Containers.Indefinite_Ordered_Maps;
private with Agpl.Drawing.Buffer;

package Agpl.Drawing.Multisource is

   pragma Preelaborate;

   type Object is limited new Drawable with private;
   --  This type is thread safe

   type Object_Access is access all Object'Class;

   procedure Draw (This : in out Object;
                   Id   :        String;
                   What :        Drawable'Class);
   --  Store or replace under Id the drawable primitives.
   --  What may dissapear afterwards.
   --  NOTE: things are drawn in lexicographical order of ID

   procedure Flush (This :        Object;
                    Dest : in out Drawer'Class);

   procedure Clear (This : in out Object);

   procedure Clear (This : in out Object;
                    Id   :        String);

   overriding
   procedure Draw (This :        Object;
                   D    : in out Drawer'Class) renames Flush;

   function Is_Dirty (This : Object) return Boolean;
   --  If any clear/draw after the last flush

private

   package Id_Buffer_Maps is
     new Ada.Containers.Indefinite_Ordered_Maps (String, Buffer.Object'Class,
                                                 "<", Buffer."=");

   protected type Safe_Type is
      procedure Draw (Id   :        String;
                      What :        Drawable'Class);
      --  Store or replace under Id the drawable primitives.
      --  What may dissapear afterwards.

      procedure Flush (Dest : in out Drawer'Class);

      procedure Clear;

      procedure Clear (Id   :        String);

      function Is_Dirty return Boolean;

   private
      Dirty   : Boolean := False;
      Buffers : Id_Buffer_Maps.Map;
   end Safe_Type;

   type Object is limited new Drawable with record
      Self : access Object := Object'Unchecked_Access;

      Safe : Safe_Type;
   end record;

end Agpl.Drawing.Multisource;