Index: src/libchcore/TSharedMemory.h =================================================================== diff -u -N -r306fbe693c70290af9de9a5779084a697de22d75 -ra4635addad389b9e117679437a3e1b64a739ea96 --- src/libchcore/TSharedMemory.h (.../TSharedMemory.h) (revision 306fbe693c70290af9de9a5779084a697de22d75) +++ src/libchcore/TSharedMemory.h (.../TSharedMemory.h) (revision a4635addad389b9e117679437a3e1b64a739ea96) @@ -1,67 +1,67 @@ -// ============================================================================ -// Copyright (C) 2001-2011 by Jozef Starosczyk -// ixen@copyhandler.com -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU Library General Public License -// (version 2) as published by the Free Software Foundation; -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Library General Public -// License along with this program; if not, write to the -// Free Software Foundation, Inc., -// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// ============================================================================ -/// @file TSharedMemory.h -/// @date 2011/05/03 -/// @brief Contains shared memory support classes. -// ============================================================================ -#ifndef __TSHAREDMEMORY_H__ -#define __TSHAREDMEMORY_H__ - -#include "TString.h" -#include "TIpcMutex.h" - -namespace chcore -{ - class LIBCHCORE_API TSharedMemory - { - public: - typedef unsigned int shm_size_t; - - public: - TSharedMemory(); - ~TSharedMemory(); - - void Create(const wchar_t* pszName, shm_size_t stSize); - void Create(const wchar_t* pszName, const TString& wstrData); - void Create(const wchar_t* pszName, const BYTE* pbyData, shm_size_t stSize); - - void Open(const wchar_t* pszName); - void Close() throw(); - - void Read(TString& wstrData) const; - void Write(const TString& wstrData); - void Write(const BYTE* pbyData, shm_size_t stSize); - - // below are the unsafe functions (i.e. not protected with mutex) - const BYTE* GetData() const; - BYTE* GetData(); - - shm_size_t GetSharedMemorySize() const; - shm_size_t GetDataSize() const; - - private: - HANDLE m_hFileMapping; - BYTE* m_pMappedMemory; - shm_size_t m_stSize; // contains full size of the allocated shared memory (in case we created the memory), size of occupied memory in case we opened the memory. - - mutable TIpcMutex m_mutex; - }; -} - -#endif +// ============================================================================ +// Copyright (C) 2001-2011 by Jozef Starosczyk +// ixen@copyhandler.com +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Library General Public License +// (version 2) as published by the Free Software Foundation; +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this program; if not, write to the +// Free Software Foundation, Inc., +// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// ============================================================================ +/// @file TSharedMemory.h +/// @date 2011/05/03 +/// @brief Contains shared memory support classes. +// ============================================================================ +#ifndef __TSHAREDMEMORY_H__ +#define __TSHAREDMEMORY_H__ + +#include "TString.h" +#include "TIpcMutex.h" + +namespace chcore +{ + class LIBCHCORE_API TSharedMemory + { + public: + typedef unsigned int shm_size_t; + + public: + TSharedMemory(); + ~TSharedMemory(); + + void Create(const wchar_t* pszName, shm_size_t stSize); + void Create(const wchar_t* pszName, const TString& wstrData); + void Create(const wchar_t* pszName, const BYTE* pbyData, shm_size_t stSize); + + void Open(const wchar_t* pszName); + void Close() throw(); + + void Read(TString& wstrData) const; + void Write(const TString& wstrData); + void Write(const BYTE* pbyData, shm_size_t stSize); + + // below are the unsafe functions (i.e. not protected with mutex) + const BYTE* GetData() const; + BYTE* GetData(); + + shm_size_t GetSharedMemorySize() const; + shm_size_t GetDataSize() const; + + private: + HANDLE m_hFileMapping; + BYTE* m_pMappedMemory; + shm_size_t m_stSize; // contains full size of the allocated shared memory (in case we created the memory), size of occupied memory in case we opened the memory. + + mutable TIpcMutex m_mutex; + }; +} + +#endif