File: /home/oboss/Users/gec/sources/Basic_Services/Source_Data/source_data_manager.ads

1     --% Compilation Unit:	Source_Data_Manager
2     --
3     --% Category: Package Declaration
4     --
5     --% Release:  $Name:  $
6     --
7     --% Version:  $Revision: 2.0 $
8     --
9     --% Author:   $Author: gec $
10     --
11     --% Revision Log:
12     --    $Log: source_data_manager.ads,v $
13     --    Revision 2.0  2003/04/04 08:50:18  gec
14     --    Initial release of source files serving as baseline for OBOSS-III project.
15     --
16     --    Revision 1.1.1.1  2003/04/04 08:13:04  gec
17     --    Imported using TkCVS
18     --
19     --
20     --
21     --% Project: OBOSS
22     --
23     --% Copyright (C) 2003 by Terma A/S
24     --  Proprietary and intellectual rights of Terma A/S, Denmark,
25     --  are involved in the subject-matter of this material and
26     --  all manufacturing, reproduction, use, disclosure, and
27     --  sales rights pertaining to such subject-matter are
28     --  expressly reserved. This material is submitted for a
29     --  specific purpose as agreed, and the recipient by
30     --  accepting this material agrees that this material will
31     --  not be used, copied, or reproduced in whole or in part
32     --  nor its contents revealed in any manner or to any person,
33     --  except to meet the purpose for which it was submitted and
34     --  subject to the terms of the agreement.
35     --
36     --% Target Dependencies:
37     --    None
38     --% Compiler Dependencies:
39     --    None
40     
41     --~-----------------------------------------------------------------------------
42     
43     with Basic_Types;
44     with Cell_Package;
45     with Storage_Configuration;
46     package Source_Data_Manager is
47     
48        --% Library Package:
49        --    Manages collection of heaps of source data buffers, including
50        --+    reference counting on these.
51        --    Upon allocation of source data buffer, the heap with best fit buffer
52        --+    size is selected.
53        --% Active Tasks:
54        -->   None
55        --% Passive Tasks:
56        -->   Small_Cell_Pool.Cell_Pool.Allocator - Critical region ensuring atomic
57        --+    execution of operations on heap of small source data buffers.
58        -->   Large_Cell_Pool.Cell_Pool.Allocator - Critical region ensuring atomic
59        --+    execution of operations on heap of large source data buffers.
60     
61        -- Total number of available source data buffers
62        Total_Cell_Number : constant :=
63                               Storage_Configuration.Small_Source_Data_Number +
64                               Storage_Configuration.Large_Source_Data_Number;
65     
66        -- Reference to buffer including special Void element indicating an
67        --+    unallocated reference.
68        type Optional_Location is new Natural range 0 .. Total_Cell_Number;
69        Void : constant Optional_Location := 0;
70     
71        -- Reference to allocated buffer.
72        subtype Location is Optional_Location range 1 .. Optional_Location'Last;
73     
74        -- Range of supported source data buffer sizez
75        subtype Allocation_Size is
76              Basic_Types.Bit_Size range
77              0 .. Storage_Configuration.Large_Source_Data_Size;
78     
79        -- Not_Allocated indicates that an operation has been performed on an
80        --+    unallocated Optional_Location.
81        Not_Allocated : exception;
82     
83        -- No_Buffers_Available indicates that an Allocate operation has failed due
84        --+    to lack of free buffers.
85        No_Buffers_Available : exception;
86     
87        --% Subprogram:
88        --    Allocate a source data buffer that may hold at least S number of bits.
89        --+
90        --% Parameter Constraints:
91        -->   S  - If S = 0 then Void is returned.
92        --% Exceptions Raised:
93        -->   No_Buffers_Available - Heap of buffers has been exhausted.
94        function Allocate
95              (S :        Allocation_Size)
96              return Optional_Location;
97     
98        --% Subprogram:
99        --    Release the source data buffer referenced by L using reference
100        --+    counting (re. Share).
101        --    If L = Void operation has no effect.
102        --% Parameter Constraints:
103        -->   None
104        --% Exceptions Raised:
105        -->   Not_Allocated - L does not reference an allocated buffer.
106        procedure Deallocate
107              (L : in     Optional_Location);
108     
109        --% Subprogram:
110        --    Share the reference L using reference counting.
111        --    If L = Void operation has no effect.
112        --% Parameter Constraints:
113        -->   None
114        --% Exceptions Raised:
115        -->   Not_Allocated - L does not reference an allocated buffer.
116        procedure Share
117              (L : in     Optional_Location);
118     
119        --% Subprogram:
120        --    Dereference the reference L returning an accessor to the associated
121        --+    memory cell.
122        --    If L = Void then null is returned.
123        --% Parameter Constraints:
124        -->   None
125        --% Exceptions Raised:
126        -->   Not_Allocated - L does not reference an allocated buffer.
127        function Dereference
128              (L :        Optional_Location)
129              return Cell_Package.Cell_Ref;
130     
131        --% Subprogram:
132        --     Dereference the reference L returning an accessor to the associated
133        --+    memory cell.
134        --% Parameter Constraints:
135        -->   L must denote an allocated memory cell
136        --% Exceptions Raised:
137        -->   None
138        function Dereference_Safe
139              (L :        Location)
140              return Cell_Package.Cell_Ref;
141     
142     end Source_Data_Manager;
143     
144     --~-----------------------------------------------------------------------------
145