b311480e |
1 | -- Created on: 1992-11-02 |
2 | -- Created by: Christian CAILLET |
3 | -- Copyright (c) 1992-1999 Matra Datavision |
4 | -- Copyright (c) 1999-2012 OPEN CASCADE SAS |
5 | -- |
6 | -- The content of this file is subject to the Open CASCADE Technology Public |
7 | -- License Version 6.5 (the "License"). You may not use the content of this file |
8 | -- except in compliance with the License. Please obtain a copy of the License |
9 | -- at http://www.opencascade.org and read it completely before using this file. |
10 | -- |
11 | -- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its |
12 | -- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. |
13 | -- |
14 | -- The Original Code and all software distributed under the License is |
15 | -- distributed on an "AS IS" basis, without warranty of any kind, and the |
16 | -- Initial Developer hereby disclaims all such warranties, including without |
17 | -- limitation, any warranties of merchantability, fitness for a particular |
18 | -- purpose or non-infringement. Please see the License for the specific terms |
19 | -- and conditions governing the rights and limitations under the License. |
20 | |
7fd59977 |
21 | |
22 | |
23 | private class EntityCluster from Interface inherits TShared |
24 | |
25 | ---Purpose : Auxiliary class for EntityList. An EntityList designates an |
26 | -- EntityCluster, which brings itself an fixed maximum count of |
27 | -- Entities. If it is full, it gives access to another cluster |
28 | -- ("Next"). This class is intended to give a good compromise |
29 | -- between access time (faster than a Sequence, good for little |
30 | -- count) and memory use (better than a Sequence in any case, |
31 | -- overall for little count, better than an Array for a very |
32 | -- little count. It is designed for a light management. |
33 | -- Remark that a new Item may not be Null, because this is the |
34 | -- criterium used for "End of List" |
35 | |
36 | uses EntityIterator, Transient |
37 | |
38 | raises OutOfRange, NullObject |
39 | |
40 | is |
41 | |
42 | Create returns mutable EntityCluster; |
43 | ---Purpose : Creates an empty, non-chained, EntityCluster |
44 | |
45 | Create (ent : any Transient) returns mutable EntityCluster; |
46 | ---Purpose : Creates a non-chained EntityCluster, filled with one Entity |
47 | |
48 | Create (ec : mutable EntityCluster) returns mutable EntityCluster; |
49 | ---Purpose : Creates an empty EntityCluster, chained with another one |
50 | -- (that is, put BEFORE this other one in the list) |
51 | |
52 | Create (ant : any Transient; ec : mutable EntityCluster) |
53 | returns mutable EntityCluster; |
54 | ---Purpose : Creates an EntityCluster, filled with a first Entity, and |
55 | -- chained to another EntityCluster (BEFORE it, as above) |
56 | |
57 | |
58 | Append (me : mutable; ent : any Transient) |
59 | ---Purpose : Appends an Entity to the Cluster. If it is not full, adds the |
60 | -- entity directly inside itself. Else, transmits to its Next |
61 | -- and Creates it if it does not yet exist |
62 | raises NullObject is static; |
63 | -- Error if <ent> is Null |
64 | |
65 | Remove (me : mutable; ent : any Transient) returns Boolean |
66 | ---Purpose : Removes an Entity from the Cluster. If it is not found, calls |
67 | -- its Next one to do so. |
68 | -- Returns True if it becomes itself empty, False else |
69 | -- (thus, a Cluster which becomes empty is deleted from the list) |
70 | raises NullObject is static; |
71 | -- Error if <ent> is Null |
72 | |
73 | Remove (me : mutable; num : Integer) returns Boolean |
74 | ---Purpose : Removes an Entity from the Cluster, given its rank. If <num> |
75 | -- is greater than NbLocal, calls its Next with (num - NbLocal), |
76 | -- Returns True if it becomes itself empty, False else |
77 | raises OutOfRange is static; |
78 | -- Raises an Exception if there is no Next to do so. |
79 | |
80 | NbEntities (me) returns Integer is static; |
81 | ---Purpose : Returns total count of Entities (including Next) |
82 | |
83 | Value (me; num : Integer) returns any Transient |
84 | ---Purpose : Returns the Entity identified by its rank in the list |
85 | -- (including Next) |
86 | raises OutOfRange is static; |
87 | -- Error if num less than 1 or num more then NbEntities |
88 | ---C++ : return const & |
89 | |
90 | SetValue (me : mutable; num : Integer; ent : any Transient) |
91 | ---Purpose : Changes an Entity given its rank. |
92 | raises OutOfRange, NullObject is static; |
93 | -- Error if <num> is not in [1 - NbEntities], or if <ent> is Null |
94 | |
95 | FillIterator (me; iter : in out EntityIterator) is static; |
96 | ---Purpose : Fills an Iterator with designated Entities (includes Next) |
97 | |
98 | -- -- Internal Queries, also used by EntityList -- -- |
99 | |
100 | IsLocalFull (me) returns Boolean is static private; |
101 | ---Purpose : Returns True if all the set of entities local to a Cluster is |
102 | -- full. Used by EntityList. |
103 | |
104 | NbLocal (me) returns Integer is static private; |
105 | ---Purpose : Returns count of entities in the local set (without Next) |
106 | -- Entities can then be read normally by method Value |
107 | |
108 | HasNext (me) returns Boolean is static private; |
109 | ---Purpose : Returns True if a Cluster has a Next |
110 | |
111 | Next (me) returns mutable EntityCluster is static private; |
112 | ---Purpose : Returns Next Cluster in the chain |
113 | |
114 | fields |
115 | |
116 | theents : Transient[4]; -- 4 : best compromise for memory use |
117 | thenext : EntityCluster; |
118 | |
119 | friends |
120 | |
121 | class EntityList -- of which EntityCluster stores content |
122 | |
123 | end EntityCluster; |