9 #ifndef CPPCOMMON_SYSTEM_SHARED_MEMORY_H
10 #define CPPCOMMON_SYSTEM_SHARED_MEMORY_H
45 explicit operator bool()
const {
return (
ptr() !=
nullptr); }
48 const std::string&
name() const noexcept {
return _name; }
50 size_t size() const noexcept {
return _size; }
55 const void*
ptr()
const;
63 Impl& impl() noexcept {
return reinterpret_cast<Impl&
>(_storage); }
64 const Impl& impl() const noexcept {
return reinterpret_cast<Impl const&
>(_storage); }
66 static const size_t StorageSize = 64;
67 static const size_t StorageAlign = 8;
68 alignas(StorageAlign) std::byte _storage[StorageSize];
void * ptr()
Get the shared memory block pointer.
SharedMemory & operator=(const SharedMemory &)=delete
bool owner() const
Get the shared memory owner flag (true if the new one was created, false if the existing one was open...
size_t size() const noexcept
Get the shared memory block size.
SharedMemory(const std::string &name, size_t size)
Create a new or open existing block of shared memory with a given name and size.
const std::string & name() const noexcept
Get the shared memory block name.
SharedMemory & operator=(SharedMemory &&shmem)=delete
SharedMemory(SharedMemory &&shmem)=delete
SharedMemory(const SharedMemory &)=delete
C++ Common project definitions.