aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/poco/Foundation/src/SharedMemory.cpp
blob: da43a421c02cdeab81b0e40d303d334d0b1e89c0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
//
// SharedMemory.cpp
//
// Library: Foundation
// Package: Processes
// Module:  SharedMemory
//
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier:	BSL-1.0
//


#include "Poco/SharedMemory.h"
#include "Poco/Exception.h"
#if defined(POCO_NO_SHAREDMEMORY)
#include "SharedMemory_DUMMY.cpp"
#elif defined(POCO_OS_FAMILY_WINDOWS)
#include "SharedMemory_WIN32.cpp"
#elif defined(POCO_OS_FAMILY_UNIX)
#include "SharedMemory_POSIX.cpp"
#else
#include "SharedMemory_DUMMY.cpp"
#endif


namespace Poco {


SharedMemory::SharedMemory():
	_pImpl(0)
{
}


SharedMemory::SharedMemory(const std::string& name, std::size_t size, AccessMode mode, const void* addrHint, bool server):
	_pImpl(new SharedMemoryImpl(name, size, mode, addrHint, server))
{
}


SharedMemory::SharedMemory(const Poco::File& file, AccessMode mode, const void* addrHint):
	_pImpl(new SharedMemoryImpl(file, mode, addrHint))
{
}


SharedMemory::SharedMemory(const SharedMemory& other):
	_pImpl(other._pImpl)
{
	if (_pImpl)
		_pImpl->duplicate();
}


SharedMemory::~SharedMemory()
{
	if (_pImpl)
		_pImpl->release();
}


SharedMemory& SharedMemory::operator = (const SharedMemory& other)
{
	SharedMemory tmp(other);
	swap(tmp);
	return *this;
}


char* SharedMemory::begin() const
{
	if (_pImpl)
		return _pImpl->begin();
	else
		return 0;
}


char* SharedMemory::end() const
{
	if (_pImpl)
		return _pImpl->end();
	else
		return 0;
}


} // namespace Poco