From 1465c2809f8d6cb35a1a6814ad25cdb6993a7e03 Mon Sep 17 00:00:00 2001 From: wolf Date: Fri, 13 Aug 1999 08:13:33 +0000 Subject: [PATCH] Add a function to retrieve the number of subscriptions to the Subscriptor class. This allows to do reference counting on objects. git-svn-id: https://svn.dealii.org/trunk@1693 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/base/include/base/subscriptor.h | 11 +++++++++++ deal.II/base/source/subscriptor.cc | 6 ++++++ 2 files changed, 17 insertions(+) diff --git a/deal.II/base/include/base/subscriptor.h b/deal.II/base/include/base/subscriptor.h index 20aabf2be6..cee5ed0e7e 100644 --- a/deal.II/base/include/base/subscriptor.h +++ b/deal.II/base/include/base/subscriptor.h @@ -66,6 +66,17 @@ class Subscriptor * Unsubscribes a user from the object. */ void unsubscribe () const; + + /** + * Return the present number of + * subscriptions to this object. + * This allows to use this class + * for reference counted lifetime + * determination where the last one + * to unsubscribe also deletes the + * object. + */ + unsigned int n_subscriptions () const; /** * Exception: diff --git a/deal.II/base/source/subscriptor.cc b/deal.II/base/source/subscriptor.cc index 65c8c15f25..fff7067432 100644 --- a/deal.II/base/source/subscriptor.cc +++ b/deal.II/base/source/subscriptor.cc @@ -38,3 +38,9 @@ void Subscriptor::unsubscribe () const { Assert (counter>0, NotUsed()); --counter; }; + + +unsigned int Subscriptor::n_subscriptions () const +{ + return counter; +}; -- 2.39.5