ngc 1.5.0
 
Loading...
Searching...
No Matches
ngcdcsSHM_IPC.hpp
Go to the documentation of this file.
1
8#ifndef ngcdcsSHM_IPC_H
9#define ngcdcsSHM_IPC_H
10
11
12#ifndef __cplusplus
13#error This is a C++ include file and cannot be used from plain C
14#endif
15
16
17#include <stdio.h>
18#include <stdlib.h>
19#include <string.h>
20#include <unistd.h>
21#include <errno.h>
22#include <sys/shm.h>
23
24#include <ngc/core/ngcb.h>
25#include <ngc/core/ngcbSHM.hpp>
27
28
34 int id;
35
37 int locked;
38
40 void *mem;
41
43 ngcdcs_shm_t() {id = -1; locked = 0; mem = NULL;}
44};
45
50{
51public:
54
56 explicit ngcdcsSHM_IPC(FILE *wd);
57
59 ngcdcsSHM_IPC(FILE *wd, int n);
60
62 ngcdcsSHM_IPC(FILE *wd, const char *s);
63
65 ngcdcsSHM_IPC(FILE *wd, const char *s, int n);
66
67 // Destructor
68 virtual ~ngcdcsSHM_IPC();
69
71 void *Alloc(size_t size);
72
74 void Free();
75
77 int SetName(const char *newName);
78
79protected:
81 void InvalidateEvent();
82
84 void BufferWait(int idx);
85
87 int BufferLocked(int idx);
88
90 int BufferLock(int idx);
91
93 int BufferTryLock(int idx);
94
96 void BufferUnlock(int idx);
97
99 int Publish(int idx, const ngcdcs_finfo_t &finfo, int endian, int fullFrame);
100
101private:
103 void Init_();
104
106 ngcdcs_shm_t *shm_;
107
109 ngcbSHM *evt_;
110
112 void Free_();
113
115 int Sem_(int idx);
116
118 int WrLock_(int idx);
119
121 void WrUnlock_(int idx);
122};
123
124#endif
Definition ngcbSHM.hpp:202
void BufferUnlock(int idx)
Unlock buffer.
Definition ngcdcsSHM_IPC.cpp:445
void Free()
Release allocated resources.
Definition ngcdcsSHM_IPC.cpp:347
int BufferTryLock(int idx)
Try to lock buffer[idx].
Definition ngcdcsSHM_IPC.cpp:423
ngcdcsSHM_IPC()
Constructor.
Definition ngcdcsSHM_IPC.cpp:30
int BufferLock(int idx)
Lock buffer[idx].
Definition ngcdcsSHM_IPC.cpp:418
void * Alloc(size_t size)
Allocate shared memory area.
Definition ngcdcsSHM_IPC.cpp:128
void InvalidateEvent()
Invalidate last event.
Definition ngcdcsSHM_IPC.cpp:380
int BufferLocked(int idx)
Check if buffer[idx] is locked.
Definition ngcdcsSHM_IPC.cpp:402
int Publish(int idx, const ngcdcs_finfo_t &finfo, int endian, int fullFrame)
Publish buffer.
Definition ngcdcsSHM_IPC.cpp:450
virtual ~ngcdcsSHM_IPC()
Definition ngcdcsSHM_IPC.cpp:62
void BufferWait(int idx)
Wait for buffer[idx].
Definition ngcdcsSHM_IPC.cpp:391
int SetName(const char *newName)
Set new interface name.
Definition ngcdcsSHM_IPC.cpp:349
ngcdcsSHM()
Constructor.
Definition ngcdcsSHM.cpp:30
Definition ngcdcsFINFO.hpp:468
Definition ngcdcsSHM_IPC.hpp:32
ngcdcs_shm_t()
Constructor.
Definition ngcdcsSHM_IPC.hpp:43
void * mem
Shared memory buffer.
Definition ngcdcsSHM_IPC.hpp:40
int id
Shared memory id.
Definition ngcdcsSHM_IPC.hpp:34
int locked
Locked.
Definition ngcdcsSHM_IPC.hpp:37