From: Wolfgang Bangerth Date: Wed, 18 Dec 2024 19:54:27 +0000 (-0700) Subject: Hide the implementation functions of EnableObserverPointer. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5064b13bbe8bf59953d7530784c9042ca744b428;p=dealii.git Hide the implementation functions of EnableObserverPointer. --- diff --git a/include/deal.II/base/enable_observer_pointer.h b/include/deal.II/base/enable_observer_pointer.h index 1fffaa2c6c..1da17d0510 100644 --- a/include/deal.II/base/enable_observer_pointer.h +++ b/include/deal.II/base/enable_observer_pointer.h @@ -29,6 +29,12 @@ DEAL_II_NAMESPACE_OPEN + +// Forward declaration +template +class ObserverPointer; + + /** * This class supports the functioning of the ObserverPointer class. * @@ -108,32 +114,11 @@ public: operator=(EnableObserverPointer &&) noexcept; /** - * @name EnableObserverPointer functionality + * @name Querying the observer pointers an object has. * - * Classes derived from EnableObserverPointer provide a facility - * to subscribe to this object. This is mostly used by the ObserverPointer - * class. * @{ */ - /** - * Subscribes a user of the object by storing the pointer @p validity. The - * subscriber may be identified by text supplied as @p identifier. - */ - void - subscribe(std::atomic *const validity, - const std::string &identifier = "") const; - - /** - * Unsubscribes a user from the object. - * - * @note The @p identifier and the @p validity pointer must be the same as - * the one supplied to subscribe(). - */ - void - unsubscribe(std::atomic *const validity, - const std::string &identifier = "") const; - /** * Return the present number of subscriptions to this object. This allows to * use this class for reference counted lifetime determination where the @@ -256,6 +241,40 @@ private: */ mutable const std::type_info *object_info; + /** + * A mutex used to ensure data consistency when accessing the `mutable` + * members of this class. This lock is used in the subscribe() and + * unsubscribe() functions, as well as in `list_subscribers()`. + */ + static std::mutex mutex; + + /** + * @name EnableObserverPointer functionality + * + * Classes derived from EnableObserverPointer provide a facility + * to subscribe to this object. This is mostly used by the ObserverPointer + * class. + * @{ + */ + + /** + * Subscribes a user of the object by storing the pointer @p validity. The + * subscriber may be identified by text supplied as @p identifier. + */ + void + subscribe(std::atomic *const validity, + const std::string &identifier = "") const; + + /** + * Unsubscribes a user from the object. + * + * @note The @p identifier and the @p validity pointer must be the same as + * the one supplied to subscribe(). + */ + void + unsubscribe(std::atomic *const validity, + const std::string &identifier = "") const; + /** * Check that there are no objects subscribing to this object. If this check * passes then it is safe to destroy the current object. It this check fails @@ -272,12 +291,10 @@ private: void check_no_subscribers() const noexcept; - /** - * A mutex used to ensure data consistency when accessing the `mutable` - * members of this class. This lock is used in the subscribe() and - * unsubscribe() functions, as well as in `list_subscribers()`. - */ - static std::mutex mutex; + template + friend class ObserverPointer; + + /** @} */ };