* added documentation
authorMichal Voců <michal@ruk.cuni.cz>
Thu, 24 Feb 2005 17:15:08 +0000 (17:15 +0000)
committerMichal Voců <michal@ruk.cuni.cz>
Thu, 24 Feb 2005 17:15:08 +0000 (17:15 +0000)
org.glite.lb.client-interface/interface/CountRef.h

index 462800d..13250ee 100644 (file)
 
 EWL_BEGIN_NAMESPACE
 
+/** Class implementing simple reference counting mechanism.
+ * 
+ * This class is used instead of simple pointers to enable sharing of
+ * objects using simple reference counting mechanism. It encapsulates
+ * the given (pointer to) object and remembers the number of
+ * references to it. Taking and getting rid of the reference to
+ * encapsulated object is explicit by calling member functions use()
+ * and release().
+ */
 template<typename T>
 class CountRef {
 public:
-       CountRef(void *);
+       CountRef(void *); 
 //     CountRef(void *,void (*)(void *));
 
-       void use(void);
+       void use(void); 
        void release(void);
 
-       void    *ptr;
+       void    *ptr; /**< Pointer to the encapsulated object. */
+
 private:
        int     count;
 //     void    (*destroy)(void *);
 };
 
+/** 
+ * Encapsulate the given object and set reference count to 1.
+ *
+ */
 template <typename T>
 CountRef<T>::CountRef(void *p)
 {
@@ -35,6 +49,12 @@ CountRef<T>::CountRef(void *p)
        count = 1;
 }
 
+/** Decrease the reference count, possibly deallocating the
+ * encapsulated object.
+ *
+ * This method should be called when the holder no longer plans to use
+ * the encapsulated object, instead of deleting it.
+ */
 template <typename T>
 void CountRef<T>::release(void)
 {
@@ -44,6 +64,11 @@ void CountRef<T>::release(void)
        }
 }
 
+/** Increase the number of references to the object.
+ *
+ * This method should be called every time the pointer (ie. this
+ * instance) is copied.
+ */
 template <typename T>
 void CountRef<T>::use(void)
 {