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

Last change on this file since 2 was 2, checked in by Sanahuja Guillaume, 8 years ago

flaircore

File size: 1.2 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
26{
27 namespace core
28 {
29 class SharedMem;
30 }
31}
32
33/*! \class SharedMem_impl
34* \brief Class defining a shared memory
35*
36*/
37
38class SharedMem_impl
39{
40 public:
41 SharedMem_impl(const flair::core::SharedMem* self,std::string name,size_t size);
42 ~SharedMem_impl();
43
44 void Write(const char* buf,size_t size);
45 void Read(char* buf,size_t size);
46
47 private:
48 const flair::core::SharedMem* self;
49 size_t size;
50 char *mem_segment;
51#ifdef __XENO__
52 RT_HEAP heap;
53 RT_MUTEX mutex;
54 bool heap_binded;
55 bool mutex_binded;
56#else
57 int fd;
58 sem_t *sem;
59 std::string sem_name,shm_name;
60#endif
61};
62
63#endif // SHAREDMEM_IMPL_H
Note: See TracBrowser for help on using the repository browser.