1 /*=========================================================================
4 Module: $RCSfile: gdcmRefCounter.h,v $
6 Date: $Date: 2005/10/21 07:38:00 $
7 Version: $Revision: 1.2 $
9 Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
10 l'Image). All rights reserved. See Doc/License.txt or
11 http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
13 This software is distributed WITHOUT ANY WARRANTY; without even
14 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 PURPOSE. See the above copyright notices for more information.
17 =========================================================================*/
19 #ifndef GDCMREFCOUNTER_H
20 #define GDCMREFCOUNTER_H
23 #include "gdcmDebug.h"
27 //-----------------------------------------------------------------------------
29 * \brief Integration of reference counting with a destruction of the
30 * object only when the reference is to zero
32 class GDCM_EXPORT RefCounter : public Base
35 gdcmTypeMacro(RefCounter)
38 // Allocator / Unallocator
40 /// \remarks The object is deleted only if its reference counting is to zero
41 inline virtual void Delete(void)
47 /// Register the object
48 /// \remarks It increments the reference counting
49 inline void Register(void)
53 /// Unregister the object
54 /// \remarks It decrements the reference counting
55 inline void Unregister(void)
63 /// Get the reference counting
64 /// \return Reference count
65 inline const unsigned long &GetRefCount(void) const
72 RefCounter() { RefCount = 1; }
74 virtual ~RefCounter() {}
77 /// \brief Reference count
78 unsigned long RefCount;
80 } // end namespace gdcm
82 //-----------------------------------------------------------------------------