VR-Vantage API Documentation
Home
Modules
Namespaces
Classes
Files
Examples
Tutorials
File List
File Members
include
vrvCore
DtSharedSettings.h
Go to the documentation of this file.
1
/*****************************************************************************
2
* Copyright (c) 2012 MAK Technologies, Inc.
3
* All rights reserved.
4
*****************************************************************************/
5
9
10
#pragma once
11
12
#include <
vrvCore/vrvCore.h
>
13
#include <
vrvUtil/DtVirtualBaseClass.h
>
14
15
#ifndef WIN32_LEAN_AND_MEAN
16
#define UNDEF_WIN32_LEAN_AND_MEAN
17
#define WIN32_LEAN_AND_MEAN
18
#endif
19
20
#include <boost/thread/shared_mutex.hpp>
21
22
#ifdef UNDEF_WIN32_LEAN_AND_MEAN
23
#undef UNDEF_WIN32_LEAN_AND_MEAN
24
#undef WIN32_LEAN_AND_MEAN
25
#endif
26
29
#include <
vrvCore/DtReadSettingsLock.h
>
30
#include <
vrvCore/DtWriteSettingsLock.h
>
31
32
namespace
makVrv
33
{
34
35
class
DtSettingsBackup;
36
45
class
DT_DLL_VRVCORE
DtSharedSettings
:
public
DtVirtualBaseClass
46
{
47
public
:
48
50
DtSharedSettings
(
const
DtSharedSettingsManager
& manager );
51
53
virtual
~
DtSharedSettings
();
54
56
inline
boost::shared_mutex&
mutex
() {
return
myMutex; }
57
61
62
// Forward declarations.
63
class
SignalSafety
;
64
friend
class
SignalSafety
;
65
68
class
DT_DLL_VRVCORE
SafetyKey
69
{
70
public
:
71
72
friend
class
DtSharedSettings
;
73
friend
class
SignalSafety
;
74
75
~
SafetyKey
();
76
77
#if _WIN32 //Windows allows the copy ctor to be private
78
private
:
79
#endif
80
81
SafetyKey
(
const
SafetyKey
& );
82
83
private
:
84
85
SafetyKey
();
86
87
SafetyKey
& operator = (
const
SafetyKey
& );
88
89
protected
:
90
91
SafetyKey
(
DtSharedSettings
* ptr );
92
93
DtSharedSettings
*
myPtr
;
94
95
};
96
97
//The signal safety class ensures that the manager for getting a
98
//Signaler is safe, as this requires unlocking the write lock, calling
99
//the signal, then re-locking the write lock when the function returns
109
class
DT_DLL_VRVCORE
SignalSafety
:
public
boost::noncopyable
110
{
111
public
:
112
115
SignalSafety
(
const
SafetyKey
& key );
116
119
~
SignalSafety
();
120
122
inline
const
DtSharedSettingsManager
& manager()
const
123
{
124
return
mySettings.myManager;
125
}
126
127
protected
:
128
129
DtSharedSettings
&
mySettings
;
130
131
};
132
133
135
SafetyKey
safeToEmitSignals()
136
{
137
return
SafetyKey
(
this
);
138
}
139
141
inline
void
setCurrentWriteLock(
142
boost::unique_lock<boost::shared_mutex>* currentWriteLock)
143
{
144
myCurrentWriteLock = currentWriteLock;
145
}
146
149
virtual
const
DtSettingsBackup
* settingsBackup()
const
;
150
153
virtual
DtSettingsBackup
* settingsBackup();
154
157
virtual
void
backup();
158
159
private
:
160
161
const
DtSharedSettingsManager
&
myManager
;
162
boost::shared_mutex
myMutex
;
163
164
//Current write lock used.
165
boost::unique_lock<boost::shared_mutex>*
myCurrentWriteLock
;
166
167
};
168
169
}
Copyright © 2005-2013 VT MÄK Inc. All Rights Reserved (
www.mak.com
)