NorMIT-nav
22.09
An IGT application
cxSharedMemory.h
Go to the documentation of this file.
1
/*=========================================================================
2
This file is part of CustusX, an Image Guided Therapy Application.
3
4
Copyright (c) SINTEF Department of Medical Technology.
5
All rights reserved.
6
7
CustusX is released under a BSD 3-Clause license.
8
9
See Lisence.txt (https://github.com/SINTEFMedtek/CustusX/blob/master/License.txt) for details.
10
=========================================================================*/
11
12
#ifndef CXSHAREDMEMORY_H_
13
#define CXSHAREDMEMORY_H_
14
15
#include "cxResourceExport.h"
16
17
#include <QSharedMemory>
18
#include <QDateTime>
19
20
namespace
cx
21
{
22
28
40
class
cxResource_EXPORT
SharedMemoryServer
41
{
42
private
:
43
QSharedMemory mBuffer;
44
int
mSize;
45
int
mBuffers;
46
int
mCurrentBuffer;
47
QDateTime mLastTimestamp;
48
49
public
:
59
SharedMemoryServer
(QString key,
int
buffers,
int
sizeEach, QObject *parent = 0);
60
~
SharedMemoryServer
();
61
int
size
() {
return
mSize; }
62
int
buffers
() {
return
mBuffers; }
63
QString
key
() {
return
mBuffer.key(); }
64
void
*buffer();
65
void
release();
66
69
QDateTime
lastTimestamp
() {
return
mLastTimestamp; }
73
bool
hasBuffer
() {
return
mCurrentBuffer != -1; }
74
private
:
75
void
internalRelease(
bool
lock);
76
};
77
84
class
cxResource_EXPORT
SharedMemoryClient
85
{
86
private
:
87
QSharedMemory mBuffer;
88
int
mSize;
89
int
mBuffers;
90
int
mCurrentBuffer;
91
QDateTime mTimestamp;
92
93
public
:
94
SharedMemoryClient
(QObject *parent = 0);
95
~
SharedMemoryClient
();
96
bool
attach(
const
QString &key);
97
bool
detach();
98
int
size
() {
return
mSize; }
99
int
buffers
() {
return
mBuffers; }
100
QString
key
() {
return
mBuffer.key(); }
101
const
void
*buffer(
bool
onlyNew=
false
);
102
void
release();
103
const
void
*isNew();
104
QDateTime
timestamp
() {
return
mTimestamp; }
105
};
106
107
}
108
109
#endif
cx::SharedMemoryServer::lastTimestamp
QDateTime lastTimestamp()
Definition:
cxSharedMemory.h:69
cx
Namespace for all CustusX production code.
Definition:
cx_dev_group_definitions.h:13
cx::SharedMemoryServer::buffers
int buffers()
Definition:
cxSharedMemory.h:62
cx::SharedMemoryClient
Shared Memory Client.
Definition:
cxSharedMemory.h:84
cx::SharedMemoryClient::size
int size()
Definition:
cxSharedMemory.h:98
cx::SharedMemoryServer::key
QString key()
Definition:
cxSharedMemory.h:63
cx::SharedMemoryServer
Shared Memory Server.
Definition:
cxSharedMemory.h:40
cx::SharedMemoryServer::size
int size()
Definition:
cxSharedMemory.h:61
cx::SharedMemoryServer::hasBuffer
bool hasBuffer()
Definition:
cxSharedMemory.h:73
cx::SharedMemoryClient::key
QString key()
Definition:
cxSharedMemory.h:100
cx::SharedMemoryClient::timestamp
QDateTime timestamp()
Definition:
cxSharedMemory.h:104
cx::SharedMemoryClient::buffers
int buffers()
Definition:
cxSharedMemory.h:99
CX
source
resource
core
utilities
cxSharedMemory.h
Generated on Tue Sep 13 2022 11:06:16 for NorMIT-nav by
1.8.17