8 #ifndef META_OCEAN_BASE_SHARED_MEMORY_H
9 #define META_OCEAN_BASE_SHARED_MEMORY_H
59 inline const std::wstring& name()
const;
65 inline size_t size()
const;
88 inline const void* constdata()
const;
100 explicit inline operator bool()
const;
127 static bool requestSharedMemory(
const std::wstring& name,
size_t& size,
void*& handle,
void*& data,
bool* existedAlready =
nullptr);
138 void* data_ =
nullptr;
141 void* handle_ =
nullptr;
164 inline SharedMemory::operator bool()
const
166 return data_ !=
nullptr;
This class implements a shared memory object allowing access to a shared buffer.
Definition: SharedMemory.h:23
void flush()
Flushes the shared memory.
SharedMemory()=default
Creates a new shared memory object.
size_t size_
Sized of the shared memory buffer in bytes.
Definition: SharedMemory.h:135
size_t size() const
Returns the size of the shared memory buffer in bytes.
Definition: SharedMemory.h:149
std::wstring name_
System wide unique memory name.
Definition: SharedMemory.h:132
SharedMemory(const std::wstring &name, const size_t size)
Creates a new shared memory object with specified buffer size.
SharedMemory & operator=(const SharedMemory &sharedMemory)=delete
Disabled assign operator for shared memory objects.
void * data_
Pointer to the shared memory.
Definition: SharedMemory.h:138
static bool requestSharedMemory(const std::wstring &name, size_t &size, void *&handle, void *&data, bool *existedAlready=nullptr)
Requests a shared memory buffer.
SharedMemory(const SharedMemory &sharedMemory)=delete
Disabled copy constructor for a shared memory object.
SharedMemory & operator=(SharedMemory &&sharedMemory) noexcept
Move operator for shared memory objects.
~SharedMemory()
Destructs a shared memory object.
void * data()
Returns a pointer to the shared memory buffer.
Definition: SharedMemory.h:159
void release()
Releases the shared memory buffer.
const std::wstring & name() const
Returns the system wide unique name of this shared memory.
Definition: SharedMemory.h:144
SharedMemory(SharedMemory &&sharedMemory) noexcept
Move constructor for a shared memory object.
bool resize(const size_t newSize)
Resizes the shared memory buffer.
const void * constdata() const
Returns a pointer to the shared memory buffer.
Definition: SharedMemory.h:154
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15