10 #ifndef __SHM_BASE_LIB_H__
11 #define __SHM_BASE_LIB_H__
26 #include <sys/types.h>
67 const PERM DEFAULT_PERM =
static_cast<PERM
>(PERM_USER_READ | PERM_USER_WRITE | PERM_GROUP_READ | PERM_GROUP_WRITE | PERM_OTHER_READ | PERM_OTHER_WRITE);
75 int disconnectMemory(std::string name);
76 int disconnectMemory(
int id);
90 virtual bool connect(
size_t size = 0) = 0;
91 virtual int disconnect() = 0;
92 size_t getSize()
const;
93 unsigned char* getPtr();
95 virtual bool isDisconnected()
const = 0;
102 unsigned char *shm_ptr;
118 virtual bool connect(
size_t size = 0);
119 virtual int disconnect();
121 virtual bool isDisconnected()
const;
124 std::string shm_name;
138 static size_t getSize(
size_t element_size,
int buffer_num);
140 RingBuffer(
unsigned char* first_ptr,
size_t size = 0,
int buffer_num = 0);
145 int getNewestBufferNum();
146 int getOldestBufferNum();
147 size_t getElementSize()
const;
148 unsigned char* getDataList();
150 bool waitFor(uint64_t timeout_usec);
152 void setDataExpiryTime_us(uint64_t time_us);
155 void initializeExclusiveAccess();
157 unsigned char *memory_ptr;
159 pthread_mutex_t *mutex;
160 pthread_cond_t *condition;
161 size_t *element_size;
163 uint64_t *timestamp_list;
164 unsigned char *data_list;
166 uint64_t timestamp_us;
167 uint64_t data_expiry_time_us;