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