Main Page
Namespace List
Class Hierarchy
Alphabetical List
Compound List
File List
Namespace Members
Compound Members
File Members
Source
igtlMutexLock.h
Go to the documentation of this file.
1
/*=========================================================================
2
3
Program: Open IGT Link Library
4
Module: $HeadURL: http://svn.na-mic.org/NAMICSandBox/trunk/OpenIGTLink/Source/igtlMutexLock.h $
5
Language: C++
6
Date: $Date: 2008-12-22 19:05:42 -0500 (Mon, 22 Dec 2008) $
7
Version: $Revision: 3460 $
8
9
Copyright (c) Insight Software Consortium. All rights reserved.
10
11
This software is distributed WITHOUT ANY WARRANTY; without even
12
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
13
PURPOSE. See the above copyright notices for more information.
14
15
=========================================================================*/
16
/*=========================================================================
17
18
Program: Insight Segmentation & Registration Toolkit
19
Module: $RCSfile: itkMutexLock.h,v $
20
Language: C++
21
Date: $Date: 2008-12-22 19:05:42 -0500 (Mon, 22 Dec 2008) $
22
Version: $Revision: 3460 $
23
24
Copyright (c) Insight Software Consortium. All rights reserved.
25
See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
26
27
Portions of this code are covered under the VTK copyright.
28
See VTKCopyright.txt or http://www.kitware.com/VTKCopyright.htm for details.
29
30
This software is distributed WITHOUT ANY WARRANTY; without even
31
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
32
PURPOSE. See the above copyright notices for more information.
33
34
=========================================================================*/
35
#ifndef __igtlMutexLock_h
36
#define __igtlMutexLock_h
37
38
#include "
igtlObject.h
"
39
#include "
igtlObjectFactory.h
"
40
41
#ifdef OpenIGTLink_USE_SPROC
42
#include <abi_mutex.h>
43
#endif
44
45
#ifdef OpenIGTLink_USE_PTHREADS
46
#include <pthread.h>
47
#endif
48
49
#ifdef OpenIGTLink_USE_WIN32_THREADS
50
#include "
igtlWindows.h
"
51
#endif
52
53
namespace
igtl
54
{
55
56
#ifdef OpenIGTLink_USE_SPROC
57
typedef
abilock_t
MutexType
;
58
#endif
59
60
#ifdef OpenIGTLink_USE_PTHREADS
61
typedef
pthread_mutex_t
MutexType
;
62
#endif
63
64
#ifdef OpenIGTLink_USE_WIN32_THREADS
65
typedef
HANDLE
MutexType
;
66
#endif
67
68
#ifndef OpenIGTLink_USE_SPROC
69
#ifndef OpenIGTLink_USE_PTHREADS
70
#ifndef OpenIGTLink_USE_WIN32_THREADS
71
typedef
int
MutexType
;
72
#endif
73
#endif
74
#endif
75
85
class
IGTLCommon_EXPORT
SimpleMutexLock
86
{
87
public
:
89
typedef
SimpleMutexLock
Self
;
90
92
SimpleMutexLock
();
93
virtual
~
SimpleMutexLock
();
95
97
static
SimpleMutexLock
*New();
98
//void Delete() {delete this;}
100
102
virtual
const
char
*
GetNameOfClass
() {
return
"igtlSimpleMutexLock"
;};
103
105
void
Lock(
void
);
106
108
void
Unlock(
void
);
109
111
MutexType
& GetMutexLock()
112
{
113
return
m_MutexLock;
114
}
115
const
MutexType
GetMutexLock()
const
116
{
117
return
m_MutexLock;
118
}
120
121
protected
:
122
MutexType
m_MutexLock
;
123
};
124
134
class
IGTLCommon_EXPORT
MutexLock
:
public
Object
135
{
136
public
:
138
typedef
MutexLock
Self
;
139
typedef
Object
Superclass
;
140
typedef
SmartPointer<Self>
Pointer
;
141
typedef
SmartPointer<const Self>
ConstPointer
;
142
144
igtlNewMacro
(
Self
);
145
147
igtlTypeMacro
(
MutexLock
,
Object
);
148
150
void
Lock(
void
);
151
153
void
Unlock(
void
);
154
155
protected
:
156
MutexLock
() {}
157
~MutexLock
() {}
158
159
SimpleMutexLock
m_SimpleMutexLock
;
160
void
PrintSelf(std::ostream& os)
const
;
161
162
private
:
163
MutexLock
(
const
Self
&);
//purposely not implemented
164
void
operator=(
const
Self
&);
//purposely not implemented
165
};
166
167
168
inline
void
MutexLock::Lock
(
void
)
169
{
170
m_SimpleMutexLock
.
Lock
();
171
}
172
173
inline
void
MutexLock::Unlock
(
void
)
174
{
175
m_SimpleMutexLock
.
Unlock
();
176
}
177
178
179
}
//end igtl namespace
180
#endif
181
Generated at Thu Mar 20 2014 16:32:06 for OpenIGTLink by
1.8.1.2 written by
Dimitri van Heesch
, © 1997-2000