b311480e |
1 | -- Created on: 1992-05-13 |
2 | -- Created by: NW,JPB,CAL |
3 | -- Copyright (c) 1992-1999 Matra Datavision |
973c2be1 |
4 | -- Copyright (c) 1999-2014 OPEN CASCADE SAS |
7fd59977 |
5 | -- |
973c2be1 |
6 | -- This file is part of Open CASCADE Technology software library. |
7fd59977 |
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. |
7fd59977 |
13 | -- |
973c2be1 |
14 | -- Alternatively, this file may be used under the terms of Open CASCADE |
15 | -- commercial license or contractual agreement. |
7fd59977 |
16 | |
17 | class GenId from Aspect |
18 | |
a9568545 |
19 | ---Purpose: This class permits the creation and control of integer identifiers. |
7fd59977 |
20 | |
21 | uses |
22 | |
a9568545 |
23 | ListOfInteger from TColStd |
7fd59977 |
24 | |
25 | raises |
26 | |
a9568545 |
27 | IdentDefinitionError from Aspect |
7fd59977 |
28 | |
29 | is |
30 | |
a9568545 |
31 | Create |
32 | returns GenId from Aspect; |
33 | ---Purpose: Creates an available set of identifiers with the lower bound 0 and the upper bound INT_MAX / 2. |
7fd59977 |
34 | |
a9568545 |
35 | Create (theLow, theUpper : Integer from Standard) |
36 | returns GenId from Aspect |
37 | ---Purpose: Creates an available set of identifiers with specified range. |
38 | -- Raises IdentDefinitionError if theUpper is less than theLow. |
39 | raises IdentDefinitionError from Aspect; |
7fd59977 |
40 | |
a9568545 |
41 | Free (me : in out); |
42 | ---Level: Internal |
43 | ---Purpose: Free all identifiers - make the whole range available again. |
44 | |
45 | Free (me : in out; |
46 | theId : Integer from Standard); |
47 | ---Purpose: Free specified identifier. Warning - method has no protection against double-freeing! |
48 | |
49 | HasFree (me) |
50 | returns Boolean from Standard; |
51 | ---Purpose: Returns true if there are available identifiers in range. |
7fd59977 |
52 | |
a9568545 |
53 | Available (me) |
54 | returns Integer from Standard; |
55 | ---Purpose: Returns the number of available identifiers. |
7fd59977 |
56 | |
a9568545 |
57 | Lower (me) |
58 | returns Integer from Standard; |
59 | ---Purpose: Returns the lower identifier in range. |
7fd59977 |
60 | |
a9568545 |
61 | Next (me : in out) |
62 | returns Integer from Standard |
63 | ---Purpose: Returns the next available identifier. |
64 | -- Warning: Raises IdentDefinitionError if all identifiers are busy. |
65 | raises IdentDefinitionError from Aspect; |
66 | |
67 | Upper (me) |
68 | returns Integer from Standard; |
69 | ---Purpose: Returns the upper identifier in range. |
70 | |
71 | fields |
7fd59977 |
72 | |
a9568545 |
73 | myFreeCount : Integer from Standard; -- the current number of available identifiers in range, excluding freed numbers |
74 | myLength : Integer from Standard; -- the number of identifiers |
75 | myLowerBound : Integer from Standard; -- the lower limit for identifiers |
76 | myUpperBound : Integer from Standard; -- the upper limit for identifiers |
77 | myFreeIds : ListOfInteger from TColStd; -- to save free identifiers |
7fd59977 |
78 | |
79 | end GenId; |