OFFIS DCMTK
Version 3.6.0
Main Page
Related Pages
Classes
Files
File List
File Members
dcmimgle
include
dcmtk
dcmimgle
diobjcou.h
1
/*
2
*
3
* Copyright (C) 1996-2010, OFFIS e.V.
4
* All rights reserved. See COPYRIGHT file for details.
5
*
6
* This software and supporting documentation were developed by
7
*
8
* OFFIS e.V.
9
* R&D Division Health
10
* Escherweg 2
11
* D-26121 Oldenburg, Germany
12
*
13
*
14
* Module: dcmimgle
15
*
16
* Author: Joerg Riesmeier
17
*
18
* Purpose: DicomObjectCounter (Header)
19
*
20
* Last Update: $Author: joergr $
21
* Update Date: $Date: 2010-10-14 13:16:26 $
22
* CVS/RCS Revision: $Revision: 1.14 $
23
* Status: $State: Exp $
24
*
25
* CVS/RCS Log at end of file
26
*
27
*/
28
29
30
#ifndef DIOBJCOU_H
31
#define DIOBJCOU_H
32
33
#include "dcmtk/config/osconfig.h"
34
35
#ifdef WITH_THREADS
36
#include "dcmtk/ofstd/ofthread.h"
37
#endif
38
39
40
/*---------------------*
41
* class declaration *
42
*---------------------*/
43
47
class
DiObjectCounter
48
{
49
50
public
:
51
55
inline
void
addReference
()
56
{
57
#ifdef WITH_THREADS
58
theMutex.lock();
59
#endif
60
++
Counter
;
61
#ifdef WITH_THREADS
62
theMutex.unlock();
63
#endif
64
}
65
69
inline
void
removeReference
()
70
{
71
#ifdef WITH_THREADS
72
theMutex.lock();
73
#endif
74
if
(--
Counter
== 0)
75
{
76
#ifdef WITH_THREADS
77
theMutex.unlock();
78
#endif
79
delete
this
;
80
#ifdef WITH_THREADS
81
}
else
{
82
theMutex.unlock();
83
#endif
84
}
85
}
86
87
88
protected
:
89
93
DiObjectCounter
()
94
:
Counter
(1)
95
#ifdef WITH_THREADS
96
,theMutex()
97
#endif
98
{
99
}
100
103
virtual
~DiObjectCounter
()
104
{
105
}
106
107
108
private
:
109
111
unsigned
long
Counter
;
112
113
#ifdef WITH_THREADS
114
117
OFMutex
theMutex;
118
#endif
119
};
120
121
122
#endif
123
124
125
/*
126
*
127
* CVS/RCS Log:
128
* $Log: diobjcou.h,v $
129
* Revision 1.14 2010-10-14 13:16:26 joergr
130
* Updated copyright header. Added reference to COPYRIGHT file.
131
*
132
* Revision 1.13 2010-10-04 14:44:45 joergr
133
* Replaced "#ifdef _REENTRANT" by "#ifdef WITH_THREADS" where appropriate (i.e.
134
* in all cases where OFMutex, OFReadWriteLock, etc. are used).
135
*
136
* Revision 1.12 2010-03-01 09:08:47 uli
137
* Removed some unnecessary include directives in the headers.
138
*
139
* Revision 1.11 2005-12-08 16:47:59 meichel
140
* Changed include path schema for all DCMTK header files
141
*
142
* Revision 1.10 2003/12/23 15:53:22 joergr
143
* Replaced post-increment/decrement operators by pre-increment/decrement
144
* operators where appropriate (e.g. 'i++' by '++i').
145
*
146
* Revision 1.9 2003/12/08 19:30:16 joergr
147
* Removed leading underscore characters from preprocessor symbols (reserved
148
* symbols). Updated copyright header.
149
*
150
* Revision 1.8 2001/06/01 15:49:48 meichel
151
* Updated copyright header
152
*
153
* Revision 1.7 2000/07/12 12:47:47 joergr
154
* Correct bug in destructor of ObjectCounter class.
155
*
156
* Revision 1.6 2000/05/25 10:35:23 joergr
157
* Added member variable to member initialization list (avoid compiler
158
* warnings).
159
*
160
* Revision 1.5 2000/04/28 12:30:51 joergr
161
* ObjectCounter uses now class OFMutex to be MT-safe.
162
*
163
* Revision 1.4 2000/03/08 16:24:21 meichel
164
* Updated copyright header.
165
*
166
* Revision 1.3 1999/09/17 12:44:08 joergr
167
* Added/changed/completed DOC++ style comments in the header files.
168
*
169
* Revision 1.2 1999/03/24 17:20:18 joergr
170
* Added/Modified comments and formatting.
171
*
172
* Revision 1.1 1998/11/27 15:40:30 joergr
173
* Added copyright message.
174
*
175
* Revision 1.3 1998/05/11 14:53:24 joergr
176
* Added CVS/RCS header to each file.
177
*
178
*
179
*/
Generated on Thu Dec 20 2012 for
OFFIS DCMTK
Version 3.6.0 by
Doxygen
1.8.2