rllib  1
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros
rlsharedmemory.h
Go to the documentation of this file.
1 /***************************************************************************
2  rlsharedmemory.h - description
3  -------------------
4  begin : Tue Jan 02 2001
5  copyright : (C) 2001 by R. Lehrig
6  email : lehrig@t-online.de
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This library is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE as *
13  * published by the Free Software Foundation *
14  * *
15  ***************************************************************************/
16 #ifndef _RL_SHARED_MEMORY_H_
17 #define _RL_SHARED_MEMORY_H_
18 
19 #include "rldefine.h"
20 #include "rlwthread.h"
21 
31 {
32 public:
34  {
35  OK = 0,
40  };
41 
43  rlSharedMemory(const char *name, unsigned long size, int rwmode=0600);
44  virtual ~rlSharedMemory();
45  int deleteSharedMemory();
46  int write(unsigned long offset, const void *buf, int len);
47  int read (unsigned long offset, void *buf, int len);
48  int readInt(unsigned long offset, int index);
49  int readShort(unsigned long offset, int index);
50  int readByte(unsigned long offset, int index);
51  float readFloat(unsigned long offset, int index);
52  int writeInt(unsigned long offset, int index, int val);
53  int writeShort(unsigned long offset, int index, int val);
54  int writeByte(unsigned long offset, int index, unsigned char val);
55  int writeFloat(unsigned long offset, int index, float val);
56  void *getUserAdr();
57  int shmKey();
58  int shmId();
59  int status;
60  char *name;
61 private:
62  int id;
63  int shmkey;
64  char *base_adr;
65  char *user_adr;
66  unsigned long size;
68 #ifdef RLWIN32
69  HANDLE hSharedFile;
70  OVERLAPPED overlapped;
71 #elif defined(RLUNIX)
72  int fdlock;
73 #endif
74 };
75 
76 #endif