blob: e1e50b2db042d0d139136b88dec6d2b8ec8bf1be (
plain)
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
|
// stdout_shared_memory.h
#pragma once
#include "stdout_shared_layout.h"
#include <string>
#include <stdexcept>
#include <cstddef>
class StdoutSharedMemory
{
public:
StdoutSharedMemory(const std::wstring &mappingName,
std::size_t totalBytes);
~StdoutSharedMemory();
StdoutSharedMemory(const StdoutSharedMemory&) = delete;
StdoutSharedMemory& operator=(const StdoutSharedMemory&) = delete;
StdoutSharedMemory(StdoutSharedMemory&& other) noexcept;
StdoutSharedMemory& operator=(StdoutSharedMemory&& other) noexcept;
StdoutSharedRegion* getRegion()
{
return static_cast<StdoutSharedRegion*>(view_);
}
const StdoutSharedRegion* getRegion() const
{
return static_cast<const StdoutSharedRegion*>(view_);
}
void* getBufferPtr()
{
return getRegion()->buffer;
}
std::size_t getBufferSize() const
{
return sizeBytes_ - sizeof(StdoutSharedHeader);
}
void* getHandle() const { return handle_; }
private:
void* handle_; // HANDLE on Windows, fd on Linux
void* view_; // mapped region
std::size_t sizeBytes_;
};
|