00001
00002
00003 #ifndef BASE_SHAREDMEMORY_H
00004 #define BASE_SHAREDMEMORY_H
00005
00006 #ifdef _WIN32
00007 #define WIN32_LEAN_AND_MEAN
00008 #include <windows.h>
00009 #endif
00010 #include <cstdlib>
00011
00012 namespace base {
00014
00018 class PPBASE_EXPORT SharedMemory {
00019 public:
00021 enum openFlags {
00022 ofCreate = 0x01,
00023 ofExclusive = 0x02
00024 };
00025
00027 SharedMemory();
00028
00030 ~SharedMemory();
00031
00033 void close();
00034
00036
00041 void destroy();
00042
00044
00047 void *getAddr() const;
00048
00050
00055 void *map(bool rw = true, void *addr = NULL);
00056
00058
00063 void open(const char *name, unsigned size, int flags = 0);
00064
00066 void unmap();
00067
00068 private:
00069 void *_addr;
00070 #ifdef _WIN32
00071 HANDLE _shmem;
00072 #else
00073 int _shmid;
00074 #endif
00075 };
00076 }
00077
00078 #endif