source: flair-src/trunk/lib/FlairCore/src/unexported/SharedMem_impl.h @ 15

Last change on this file since 15 was 15, checked in by Bayard Gildas, 5 years ago

sources reformatted with flair-format-dir script

File size: 1.1 KB
Line 
1// %flair:license{
2// This file is part of the Flair framework distributed under the
3// CECILL-C License, Version 1.0.
4// %flair:license}
5/*!
6 * \file SharedMem_impl.h
7 * \brief Class defining a shared memory
8 * \author Guillaume Sanahuja, Copyright Heudiasyc UMR UTC/CNRS 7253
9 * \date 2014/02/10
10 * \version 4.0
11 */
12
13#ifndef SHAREDMEM_IMPL_H
14#define SHAREDMEM_IMPL_H
15
16#include <string>
17
18#ifdef __XENO__
19#include <native/heap.h>
20#include <native/mutex.h>
21#else
22#include <semaphore.h>
23#endif
24
25namespace flair {
26namespace core {
27class SharedMem;
28}
29}
30
31/*! \class SharedMem_impl
32* \brief Class defining a shared memory
33*
34*/
35
36class SharedMem_impl {
37public:
38  SharedMem_impl(const flair::core::SharedMem *self, std::string name,
39                 size_t size);
40  ~SharedMem_impl();
41
42  void Write(const char *buf, size_t size);
43  void Read(char *buf, size_t size);
44
45private:
46  const flair::core::SharedMem *self;
47  size_t size;
48  char *mem_segment;
49#ifdef __XENO__
50  RT_HEAP heap;
51  RT_MUTEX mutex;
52  bool heap_binded;
53  bool mutex_binded;
54#else
55  int fd;
56  sem_t *sem;
57  std::string sem_name, shm_name;
58#endif
59};
60
61#endif // SHAREDMEM_IMPL_H
Note: See TracBrowser for help on using the repository browser.