7fd59977 |
1 | -- File: EntityCluster.cdl |
2 | -- Created: Mon Nov 2 16:03:55 1992 |
3 | -- Author: Christian CAILLET |
4 | -- <cky@topsn2> |
5 | ---Copyright: Matra Datavision 1992 |
6 | |
7 | |
8 | private class EntityCluster from Interface inherits TShared |
9 | |
10 | ---Purpose : Auxiliary class for EntityList. An EntityList designates an |
11 | -- EntityCluster, which brings itself an fixed maximum count of |
12 | -- Entities. If it is full, it gives access to another cluster |
13 | -- ("Next"). This class is intended to give a good compromise |
14 | -- between access time (faster than a Sequence, good for little |
15 | -- count) and memory use (better than a Sequence in any case, |
16 | -- overall for little count, better than an Array for a very |
17 | -- little count. It is designed for a light management. |
18 | -- Remark that a new Item may not be Null, because this is the |
19 | -- criterium used for "End of List" |
20 | |
21 | uses EntityIterator, Transient |
22 | |
23 | raises OutOfRange, NullObject |
24 | |
25 | is |
26 | |
27 | Create returns mutable EntityCluster; |
28 | ---Purpose : Creates an empty, non-chained, EntityCluster |
29 | |
30 | Create (ent : any Transient) returns mutable EntityCluster; |
31 | ---Purpose : Creates a non-chained EntityCluster, filled with one Entity |
32 | |
33 | Create (ec : mutable EntityCluster) returns mutable EntityCluster; |
34 | ---Purpose : Creates an empty EntityCluster, chained with another one |
35 | -- (that is, put BEFORE this other one in the list) |
36 | |
37 | Create (ant : any Transient; ec : mutable EntityCluster) |
38 | returns mutable EntityCluster; |
39 | ---Purpose : Creates an EntityCluster, filled with a first Entity, and |
40 | -- chained to another EntityCluster (BEFORE it, as above) |
41 | |
42 | |
43 | Append (me : mutable; ent : any Transient) |
44 | ---Purpose : Appends an Entity to the Cluster. If it is not full, adds the |
45 | -- entity directly inside itself. Else, transmits to its Next |
46 | -- and Creates it if it does not yet exist |
47 | raises NullObject is static; |
48 | -- Error if <ent> is Null |
49 | |
50 | Remove (me : mutable; ent : any Transient) returns Boolean |
51 | ---Purpose : Removes an Entity from the Cluster. If it is not found, calls |
52 | -- its Next one to do so. |
53 | -- Returns True if it becomes itself empty, False else |
54 | -- (thus, a Cluster which becomes empty is deleted from the list) |
55 | raises NullObject is static; |
56 | -- Error if <ent> is Null |
57 | |
58 | Remove (me : mutable; num : Integer) returns Boolean |
59 | ---Purpose : Removes an Entity from the Cluster, given its rank. If <num> |
60 | -- is greater than NbLocal, calls its Next with (num - NbLocal), |
61 | -- Returns True if it becomes itself empty, False else |
62 | raises OutOfRange is static; |
63 | -- Raises an Exception if there is no Next to do so. |
64 | |
65 | NbEntities (me) returns Integer is static; |
66 | ---Purpose : Returns total count of Entities (including Next) |
67 | |
68 | Value (me; num : Integer) returns any Transient |
69 | ---Purpose : Returns the Entity identified by its rank in the list |
70 | -- (including Next) |
71 | raises OutOfRange is static; |
72 | -- Error if num less than 1 or num more then NbEntities |
73 | ---C++ : return const & |
74 | |
75 | SetValue (me : mutable; num : Integer; ent : any Transient) |
76 | ---Purpose : Changes an Entity given its rank. |
77 | raises OutOfRange, NullObject is static; |
78 | -- Error if <num> is not in [1 - NbEntities], or if <ent> is Null |
79 | |
80 | FillIterator (me; iter : in out EntityIterator) is static; |
81 | ---Purpose : Fills an Iterator with designated Entities (includes Next) |
82 | |
83 | -- -- Internal Queries, also used by EntityList -- -- |
84 | |
85 | IsLocalFull (me) returns Boolean is static private; |
86 | ---Purpose : Returns True if all the set of entities local to a Cluster is |
87 | -- full. Used by EntityList. |
88 | |
89 | NbLocal (me) returns Integer is static private; |
90 | ---Purpose : Returns count of entities in the local set (without Next) |
91 | -- Entities can then be read normally by method Value |
92 | |
93 | HasNext (me) returns Boolean is static private; |
94 | ---Purpose : Returns True if a Cluster has a Next |
95 | |
96 | Next (me) returns mutable EntityCluster is static private; |
97 | ---Purpose : Returns Next Cluster in the chain |
98 | |
99 | fields |
100 | |
101 | theents : Transient[4]; -- 4 : best compromise for memory use |
102 | thenext : EntityCluster; |
103 | |
104 | friends |
105 | |
106 | class EntityList -- of which EntityCluster stores content |
107 | |
108 | end EntityCluster; |