0024624: Lost word in license statement in source files
[occt.git] / src / Aspect / Aspect_GenId.cxx
CommitLineData
b311480e 1// Created on: 1992-05-14
2// Created by: NW,JPB,CAL
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//-Version
18
19//-Design Declaration des variables specifiques aux identificateurs
20
21//-Warning Un identificateur est un entier.
22
23//-References
24
25//-Language C++ 2.0
26
27//-Declarations
28
29// for the class
30#include <Aspect_GenId.ixx>
31
32//-Aliases
33
34//-Global data definitions
35
36//-Constructors
37
38//-Destructors
39
40//-Methods, in order
41
42Aspect_GenId::Aspect_GenId ():
43
44 MyCount (INT_MAX/2 + 1),
45 MyLength (INT_MAX/2 + 1),
46 MyLowerBound (0),
47 MyUpperBound (INT_MAX/2),
48 MyFreeIds () {
49
50}
51
52Aspect_GenId::Aspect_GenId (const Standard_Integer Low, const Standard_Integer Up):MyFreeIds () {
53
54 if (Low <= Up) {
55 MyLowerBound = Low;
56 MyUpperBound = Up;
57 MyLength = MyUpperBound - MyLowerBound + 1;
58 MyCount = MyLength;
59 }
60 else
61 Aspect_IdentDefinitionError::Raise
62 ("GenId Create Error: Low > Up");
63
64}
65
66Standard_Integer Aspect_GenId::Available () const {
67
68 return (MyCount);
69
70}
71
72void Aspect_GenId::Free () {
73
74 MyCount = MyLength;
75 MyFreeIds.Clear ();
76
77}
78
79void Aspect_GenId::Free (const Standard_Integer Id) {
80
81 if ( (Id >= MyLowerBound) && (Id <= MyUpperBound) )
82 MyFreeIds.Prepend (Id);
83
84}
85
86Standard_Integer Aspect_GenId::Lower () const {
87
88 return (MyLowerBound);
89
90}
91
92Standard_Integer Aspect_GenId::Next () {
93
94 if (MyCount == 0)
95 Aspect_IdentDefinitionError::Raise
96 ("GenId Next Error: Available == 0");
97
98Standard_Integer Id;
99
100 if (! MyFreeIds.IsEmpty ()) {
101 Id = MyFreeIds.First ();
102 MyFreeIds.RemoveFirst ();
103 }
104 else {
105 MyCount --;
106 Id = MyLowerBound + MyLength - MyCount - 1;
107 }
108
109 return Id;
110
111}
112
113Standard_Integer Aspect_GenId::Upper () const {
114
115 return (MyUpperBound);
116
117}
118
119//void Aspect_GenId::Assign (const Aspect_GenId& Other) {
120//
121// MyLowerBound = Other.Lower ();
122// MyUpperBound = Other.Upper ();
123//
124//}