rllib  1
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  unsigned long size();
60  int status;
61  char *name;
62 private:
63  int id;
64  int shmkey;
65  char *base_adr;
66  char *user_adr;
67  unsigned long _size;
69 #ifdef RLWIN32
70  HANDLE hSharedFile;
71  OVERLAPPED overlapped;
72 #elif defined(RLUNIX)
73  int fdlock;
74 #endif
75 };
76 
77 #endif
int read(unsigned long offset, void *buf, int len)
unsigned long _size
pthread_mutex_t * mutex
virtual ~rlSharedMemory()
rlSharedMemory(const char *name, unsigned long size, int rwmode=0600)
float readFloat(unsigned long offset, int index)
int writeInt(unsigned long offset, int index, int val)
HANDLE pthread_mutex_t
Definition: rlwthread.h:70
unsigned long size()
int readShort(unsigned long offset, int index)
int writeShort(unsigned long offset, int index, int val)
int writeFloat(unsigned long offset, int index, float val)
OVERLAPPED overlapped
int readByte(unsigned long offset, int index)
int write(unsigned long offset, const void *buf, int len)
int writeByte(unsigned long offset, int index, unsigned char val)
int readInt(unsigned long offset, int index)