AdaCL.Pointer.Holder

AdaCL Reference counted smart pointer.

More...

Entities

Access types

Element_Class

Tagged types

Object

Subprograms

Initialize

Dispatching subprograms

Adjust
Create
Exist
Finalize
Get
Get_Base
Object_Image
Reset
Reset

Description

Element and Holder: A reference counted smart pointer for tagged types where the reference count is kept inside the tagged type. This is slightly faster, uses less memory and is more reliable. However it can only be uses for limited tagged types. Holder class for the actual element @formal Element_Type Type for which we want to supply a reference counter. Since, in Ada one can not overload the

1":=" operator the type need to be limited so the counter is not damaged by assignment.
2Mind you, in C++ I almost always make the operator = private in Reference counted classes as
3well.

Element_Class [source]

50 type Element_Class is access Element_Type'Class;

an access type to match the element type.

Object [source]

62 type Object is new AdaCL.Base.Object with private;

Parametrized Class AdaCL.Pointer.Reference : Object Access for Reference Counted Instances. Most smart pointer library's keep the counter inside the smart pointer. While this implementations allows the use with existing classes it is also very error prune: The counted instance always need to be handled with the smart pointer and is never allowed to be used any other way. I prefer to count inside the instance itself. This keeps the pointer far more reliable.

Inherits Object

Inherited by Protected_Object

Initialize [source]

118 procedure Initialize (Object : in out Ada.Finalization.Controlled) renames Ada.Finalization.Initialize;
Object of type Controlled

Adjust [source]

124 overriding procedure Adjust (This : in out Object);

When adjusting we need to increase the counter.

This of type AdaCL.Pointer.Holder.Object

Object itself.

Create [source]

68 function Create (Referent : in Element_Class := null) return Object;

Creates a new smart pointer from normal pointer. Pointer to reference counted object

Referent of type AdaCL.Pointer.Holder.Element_Class
Return value

Exist [source]

75 function Exist (This : in Object) return Boolean;

Checks if a pointers is set

This of type AdaCL.Pointer.Holder.Object

Object itself.

Return value

true when pointer is not null

Finalize [source]

130 overriding procedure Finalize (This : in out Object);

When finalizing we need to decrease the counter. When the counter reaches 0 we delete the insanz.

This of type AdaCL.Pointer.Holder.Object

Object itself.

Get [source]

81 function Get (This : in Object) return Element_Class;

Returns the Pointer to the counted Object. Object itself.

This of type AdaCL.Pointer.Holder.Object
Return value

Get_Base [source]

87 function Get_Base (This : in Object) return AdaCL.Limited_Base.Object_Class;

Returns the Pointer to the counted Object as base. Object itself.

This of type AdaCL.Pointer.Holder.Object
Return value

Object_Image [source]

116 procedure Object_Image (Output : in out Ada.Strings.Text_Buffers.Root_Buffer_Type'Class; This : Object);
Output of type Root_Buffer_Type
This of type AdaCL.Pointer.Holder.Object

Reset [source]

95 procedure Reset (This : in out Object; Referent : Element_Class := null);

Set a new Pointer. This decreases the counter for the previous instance and increases the Pointer to the newly set instance.

This of type AdaCL.Pointer.Holder.Object

Object itself.

Referent of type AdaCL.Pointer.Holder.Element_Class

The Object. Set to null to clean the pointer.

Reset [source]

103 procedure Reset (This : in out Object; Reference : Object);

Set a new Pointer. This decreases the counter for the previous instance and increases the Pointer to the newly set instance.

This of type AdaCL.Pointer.Holder.Object

Object itself.

Reference of type AdaCL.Pointer.Holder.Object

The Object. Set to null to clean the pointer.