對Windows下的File Mapping一個簡單的封裝
阿新 • • 發佈:2018-12-27
{
AM_READ =0, ///< 讀
AM_WRITE ///< 寫
};
public:
SharedMemory(const std::string& name, std::size_t size, AccessMode mode, constvoid* addrHint =0, bool server =true);
SharedMemory(const std::string& fileName, SharedMemory::AccessMode mode, constvoid* addrHint =0);
~SharedMemory();
public:
/// 共享記憶體的起始指標
char* begin() const;
/// 共享記憶體的尾部指標
char* end() const;
/// 共享記憶體的名字
std::string name() const;
protected:
void map();
void unmap();
void close();
private:
SharedMemory();
SharedMemory(const SharedMemory&);
SharedMemory&operator = (const SharedMemory&);
std::string m_name;
HANDLE m_memHandle;
HANDLE m_fileHandle;
DWORD m_size;
DWORD m_mode;
char* m_address;
}
AM_READ =0, ///< 讀
AM_WRITE ///< 寫
};
public:
SharedMemory(const std::string& name, std::size_t size, AccessMode mode, constvoid* addrHint =0, bool server =true);
SharedMemory(const std::string& fileName, SharedMemory::AccessMode mode, constvoid* addrHint =0);
public:
/// 共享記憶體的起始指標
char* begin() const;
/// 共享記憶體的尾部指標
char* end() const;
/// 共享記憶體的名字
std::string name() const;
protected:
void map();
void unmap();
void close();
private:
SharedMemory();
SharedMemory(const SharedMemory&);
SharedMemory&operator
std::string m_name;
HANDLE m_memHandle;
HANDLE m_fileHandle;
DWORD m_size;
DWORD m_mode;
char* m_address;
}