class GenId from Aspect
- ---Version:
-
- ---Level: Internal
- ---Purpose: This class permits the creation and control of all
- -- identifiers.
- -- Warning: An identifier is an integer.
-
- ---References:
+ ---Purpose: This class permits the creation and control of integer identifiers.
uses
- ListOfInteger from TColStd
+ ListOfInteger from TColStd
raises
- IdentDefinitionError from Aspect
+ IdentDefinitionError from Aspect
is
- Create
- returns GenId from Aspect;
- ---Level: Internal
- ---Purpose: Creates an available set of identifiers with the lower
- -- bound 0 and the upper bound INT_MAX/2.
-
- Create ( Low, Up : Integer from Standard )
- returns GenId from Aspect
- ---Level: Internal
- ---Purpose: Creates an available set of identifiers with the lower
- -- bound <Low> and the upper bound <Up>.
- -- Warning: Raises IdentDefinitionError if <Up> is less than <Low>.
- raises IdentDefinitionError from Aspect;
-
- ---------------------------------------------------
- -- Category: Methods to modify the class definition
- ---------------------------------------------------
-
- --Assign ( me : in out;
- --Other : GenId from Aspect );
- ---Level: Internal
- ---Purpose: Copies the content of <Other> into <me>.
- ---Category: Methods to modify the class definition
- -- C++: alias operator =
-
- Free ( me : in out );
- ---Level: Internal
- ---Purpose: Frees all identifiers of <me>.
- ---Category: Methods to modify the class definition
-
- Free ( me : in out;
- Id : Integer from Standard );
- ---Level: Internal
- ---Purpose: Frees the identifier <Id> of <me>.
- ---Category: Methods to modify the class definition
-
- ----------------------------
- -- Category: Inquire methods
- ----------------------------
-
- Available ( me )
- returns Integer from Standard;
- ---Level: Internal
- ---Purpose: Returns the number of available identifiers of <me>.
- ---Category: Inquire methods
-
- Lower ( me )
- returns Integer from Standard;
- ---Level: Internal
- ---Purpose: Returns the lower bound of <me>.
- ---Category: Inquire methods
-
- Next ( me : in out )
- returns Integer from Standard
- ---Level: Internal
- ---Purpose: Returns an available identifier of <me>.
- -- Warning: Raises IdentDefinitionError if all identifiers are busy.
- raises IdentDefinitionError from Aspect;
-
- Upper ( me )
- returns Integer from Standard;
- ---Level: Internal
- ---Purpose: Returns the upper bound of <me>.
- ---Category: Inquire methods
-
---\f
+ Create
+ returns GenId from Aspect;
+ ---Purpose: Creates an available set of identifiers with the lower bound 0 and the upper bound INT_MAX / 2.
-fields
+ Create (theLow, theUpper : Integer from Standard)
+ returns GenId from Aspect
+ ---Purpose: Creates an available set of identifiers with specified range.
+ -- Raises IdentDefinitionError if theUpper is less than theLow.
+ raises IdentDefinitionError from Aspect;
---
--- Class : Aspect_GenId
---
--- Purpose : Declaration of variables specific to identifiers
---
--- Reminder : An identifier is an integer
---
+ Free (me : in out);
+ ---Level: Internal
+ ---Purpose: Free all identifiers - make the whole range available again.
+
+ Free (me : in out;
+ theId : Integer from Standard);
+ ---Purpose: Free specified identifier. Warning - method has no protection against double-freeing!
+
+ HasFree (me)
+ returns Boolean from Standard;
+ ---Purpose: Returns true if there are available identifiers in range.
- -- the current number of available identifiers
- MyCount : Integer from Standard;
+ Available (me)
+ returns Integer from Standard;
+ ---Purpose: Returns the number of available identifiers.
- -- the number of identifiers
- MyLength : Integer from Standard;
+ Lower (me)
+ returns Integer from Standard;
+ ---Purpose: Returns the lower identifier in range.
- -- the limits for identifiers
- MyLowerBound : Integer from Standard;
- MyUpperBound : Integer from Standard;
+ Next (me : in out)
+ returns Integer from Standard
+ ---Purpose: Returns the next available identifier.
+ -- Warning: Raises IdentDefinitionError if all identifiers are busy.
+ raises IdentDefinitionError from Aspect;
+
+ Upper (me)
+ returns Integer from Standard;
+ ---Purpose: Returns the upper identifier in range.
+
+fields
- -- to save free identifiers
- MyFreeIds : ListOfInteger from TColStd;
+ myFreeCount : Integer from Standard; -- the current number of available identifiers in range, excluding freed numbers
+ myLength : Integer from Standard; -- the number of identifiers
+ myLowerBound : Integer from Standard; -- the lower limit for identifiers
+ myUpperBound : Integer from Standard; -- the upper limit for identifiers
+ myFreeIds : ListOfInteger from TColStd; -- to save free identifiers
end GenId;