ngc 1.4.0
 
Loading...
Searching...
No Matches
ngcdcsSHM_IPC.hpp
Go to the documentation of this file.
1
7#ifndef ngcdcsSHM_IPC_H
8#define ngcdcsSHM_IPC_H
9
10
11#ifndef __cplusplus
12#error This is a C++ include file and cannot be used from plain C
13#endif
14
15
16#include <stdio.h>
17#include <stdlib.h>
18#include <string.h>
19#include <unistd.h>
20#include <errno.h>
21#include <sys/shm.h>
22
23#include <ngc/core/ngcb.h>
24#include <ngc/core/ngcbSHM.hpp>
26
27
33 int id;
34
36 int locked;
37
39 void *mem;
40
42 ngcdcs_shm_t() {id = -1; locked = 0; mem = NULL;}
43};
44
49{
50public:
53
55 explicit ngcdcsSHM_IPC(FILE *wd);
56
58 ngcdcsSHM_IPC(FILE *wd, int n);
59
61 ngcdcsSHM_IPC(FILE *wd, const char *s);
62
64 ngcdcsSHM_IPC(FILE *wd, const char *s, int n);
65
66 // Destructor
67 virtual ~ngcdcsSHM_IPC();
68
70 void *Alloc(size_t size);
71
73 void Free();
74
76 int SetName(const char *newName);
77
78protected:
80 void InvalidateEvent();
81
83 void BufferWait(int idx);
84
86 int BufferLocked(int idx);
87
89 int BufferLock(int idx);
90
92 int BufferTryLock(int idx);
93
95 void BufferUnlock(int idx);
96
98 int Publish(int idx, const ngcdcs_finfo_t &finfo, int endian, int fullFrame);
99
100private:
102 void Init_();
103
105 ngcdcs_shm_t *shm_;
106
108 ngcbSHM *evt_;
109
111 void Free_();
112
114 int Sem_(int idx);
115
117 int WrLock_(int idx);
118
120 void WrUnlock_(int idx);
121};
122
123#endif
Definition ngcbSHM.hpp:201
void BufferUnlock(int idx)
Unlock buffer.
Definition ngcdcsSHM_IPC.cpp:444
void Free()
Release allocated resources.
Definition ngcdcsSHM_IPC.cpp:346
int BufferTryLock(int idx)
Try to lock buffer[idx].
Definition ngcdcsSHM_IPC.cpp:422
ngcdcsSHM_IPC()
Constructor.
Definition ngcdcsSHM_IPC.cpp:29
int BufferLock(int idx)
Lock buffer[idx].
Definition ngcdcsSHM_IPC.cpp:417
void * Alloc(size_t size)
Allocate shared memory area.
Definition ngcdcsSHM_IPC.cpp:127
void InvalidateEvent()
Invalidate last event.
Definition ngcdcsSHM_IPC.cpp:379
int BufferLocked(int idx)
Check if buffer[idx] is locked.
Definition ngcdcsSHM_IPC.cpp:401
int Publish(int idx, const ngcdcs_finfo_t &finfo, int endian, int fullFrame)
Publish buffer.
Definition ngcdcsSHM_IPC.cpp:449
virtual ~ngcdcsSHM_IPC()
Definition ngcdcsSHM_IPC.cpp:61
void BufferWait(int idx)
Wait for buffer[idx].
Definition ngcdcsSHM_IPC.cpp:390
int SetName(const char *newName)
Set new interface name.
Definition ngcdcsSHM_IPC.cpp:348
ngcdcsSHM()
Constructor.
Definition ngcdcsSHM.cpp:29
Definition ngcdcsFINFO.hpp:462
Definition ngcdcsSHM_IPC.hpp:31
ngcdcs_shm_t()
Constructor.
Definition ngcdcsSHM_IPC.hpp:42
void * mem
Shared memory buffer.
Definition ngcdcsSHM_IPC.hpp:39
int id
Shared memory id.
Definition ngcdcsSHM_IPC.hpp:33
int locked
Locked.
Definition ngcdcsSHM_IPC.hpp:36