mumble/plugins/link/SharedMemory.h
Robert Adam bed0fa57fa REFAC(plugins): Add SharedMemory class
This abstracts away the platform differences between Posix and Windows
systems when it comes to managing shared memory.
2021-11-18 19:25:28 +01:00

45 lines
838 B
C++

// Copyright 2021 The Mumble Developers. All rights reserved.
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file at the root of the
// Mumble source tree or at <https://www.mumble.info/LICENSE>.
#ifndef MUMBLE_PLUGINS_LINK_SHAREDMEMORY_H_
#define MUMBLE_PLUGINS_LINK_SHAREDMEMORY_H_
#include <cstddef>
#ifdef _WIN32
# ifndef NOMINMAX
# define NOMINMAX
# endif
# include "windows.h"
#else
# include <string>
#endif
class SharedMemory {
public:
explicit SharedMemory();
~SharedMemory();
std::size_t size();
void close();
int lastError() const;
void *mapMemory(const char *name, std::size_t size);
private:
void *m_data;
std::size_t m_size;
int m_error;
#ifdef _WIN32
HANDLE m_handle;
#else
std::string m_name;
#endif
};
#endif // MUMBLE_PLUGINS_LINK_SHAREDMEMORY_H_