0028854: The documentation should state where handle reference counting happens
authorBenjamin Bihler <benjamin.bihler@compositence.de>
Mon, 19 Jun 2017 08:55:26 +0000 (11:55 +0300)
committerbugmaster <bugmaster@opencascade.com>
Thu, 24 Aug 2017 16:12:06 +0000 (19:12 +0300)
The comment to class opencascade::handle<> in Standard_Handle.hxx now explains better the features differing it from std::shared_ptr<>.

src/Standard/Standard_Handle.hxx

index f4fc154..ee0abc7 100644 (file)
@@ -35,16 +35,26 @@ namespace opencascade {
 
   //! Intrusive smart pointer for use with Standard_Transient class and its descendants.
   //!
-  //! This class is similar to boost::intrusive_ptr<>, with additional
-  //! feature historically supported by Handles in OCCT:
-  //! it has type conversion to const reference to handle to the base types,
-  //! which allows it to be passed by reference
-  //! in functions accepting reference to handle to base class.
+  //! This class is similar to boost::intrusive_ptr<>. The reference counter
+  //! is part of the base class (Standard_Transient), thus creation of a handle
+  //! does not require allocation of additional memory for the counter.
+  //! All handles to the same object share the common counter; object is deleted
+  //! when the last handle pointing on it is destroyed. It is safe to create a new
+  //! handle from plain C pointer to the object already pointed by another handle.
+  //! The same object can be referenced by handles of different types (as soon as 
+  //! they are compatible with the object type).
   //!
+  //! Handle has type cast operator to const reference to handle to the base
+  //! types, which allows it to be passed by reference in functions accepting 
+  //! reference to handle to base class, without copying.
+  //!
+  //! By default, the type cast operator is provided also for non-const reference.
   //! These casts (potentially unsafe) can be disabled by defining macro
   //! OCCT_HANDLE_NOCAST; if it is defined, generalized copy constructor
   //! and assignment operators are defined allowing to initialize handle
   //! of base type from handle to derived type.
+  //!
+  //! Weak pointers are not supported.
   template <class T>
   class handle
   {