mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2024-11-08 16:57:16 +01:00
4a6bfc086c
Switched to POCO library for unified platform/library interface. Deprecated the external module API. It was creating more problems than solving. Removed most built-in libraries in favor of system libraries for easier maintenance. Cleaned and secured code with help from static analyzers.
91 lines
1.5 KiB
C++
91 lines
1.5 KiB
C++
//
|
|
// 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
|