Index: src/natools-references__intel.adb ================================================================== --- src/natools-references__intel.adb +++ src/natools-references__intel.adb @@ -113,10 +113,16 @@ function Is_Empty (Ref : Immutable_Reference) return Boolean is begin return Ref.Count = null; end Is_Empty; + + function Is_Last (Ref : Immutable_Reference) return Boolean is + begin + return Ref.Count.all = 1; + end Is_Last; + function "=" (Left, Right : Immutable_Reference) return Boolean is begin return Left.Data = Right.Data; end "="; Index: src/natools-references__intel.ads ================================================================== --- src/natools-references__intel.ads +++ src/natools-references__intel.ads @@ -71,10 +71,15 @@ procedure Reset (Ref : in out Immutable_Reference); -- Empty Ref function Is_Empty (Ref : Immutable_Reference) return Boolean; -- Check whether Ref refers to an actual object + + function Is_Last (Ref : Immutable_Reference) return Boolean; + -- Check whether Ref is the last reference to its object. + -- WARNING: This is inherently not task-safe if Ref can be + -- concurrently accessed. function "=" (Left, Right : Immutable_Reference) return Boolean; -- Check whether Left and Right refer to the same object function Query (Ref : in Immutable_Reference) return Accessor; Index: src/natools-references__protected.adb ================================================================== --- src/natools-references__protected.adb +++ src/natools-references__protected.adb @@ -111,10 +111,16 @@ function Is_Empty (Ref : Immutable_Reference) return Boolean is begin return Ref.Count = null; end Is_Empty; + + function Is_Last (Ref : Immutable_Reference) return Boolean is + begin + return Ref.Count.Get_Value = 1; + end Is_Last; + function "=" (Left, Right : Immutable_Reference) return Boolean is begin return Left.Data = Right.Data; end "="; Index: src/natools-references__protected.ads ================================================================== --- src/natools-references__protected.ads +++ src/natools-references__protected.ads @@ -69,10 +69,15 @@ procedure Reset (Ref : in out Immutable_Reference); -- Empty Ref function Is_Empty (Ref : Immutable_Reference) return Boolean; -- Check whether Ref refers to an actual object + + function Is_Last (Ref : Immutable_Reference) return Boolean; + -- Check whether Ref is the last reference to its object. + -- WARNING: This is inherently not task-safe if Ref can be + -- concurrently accessed. function "=" (Left, Right : Immutable_Reference) return Boolean; -- Check whether Left and Right refer to the same object function Query (Ref : in Immutable_Reference) return Accessor; Index: src/natools-references__unsafe.adb ================================================================== --- src/natools-references__unsafe.adb +++ src/natools-references__unsafe.adb @@ -109,10 +109,16 @@ function Is_Empty (Ref : Immutable_Reference) return Boolean is begin return Ref.Count = null; end Is_Empty; + + function Is_Last (Ref : Immutable_Reference) return Boolean is + begin + return Ref.Count.all = 1; + end Is_Last; + function "=" (Left, Right : Immutable_Reference) return Boolean is begin return Left.Data = Right.Data; end "="; Index: src/natools-references__unsafe.ads ================================================================== --- src/natools-references__unsafe.ads +++ src/natools-references__unsafe.ads @@ -68,10 +68,13 @@ procedure Reset (Ref : in out Immutable_Reference); -- Empty Ref function Is_Empty (Ref : Immutable_Reference) return Boolean; -- Check whether Ref refers to an actual object + + function Is_Last (Ref : Immutable_Reference) return Boolean; + -- Check whether Ref is the last reference to its object function "=" (Left, Right : Immutable_Reference) return Boolean; -- Check whether Left and Right refer to the same object function Query (Ref : in Immutable_Reference) return Accessor;