Flair
Framework Libre Air
SharedMem.h
Go to the documentation of this file.
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}
13 #ifndef SHAREDMEM_H
14 #define SHAREDMEM_H
15 
16 #include <Object.h>
17 #include <semaphore.h>
18 
19 class SharedMem_impl;
20 
21 namespace flair {
22 namespace core {
23 
32 class SharedMem : public Object {
33 public:
34  enum class Type { mutex, producerConsumer };
45  SharedMem(const Object *parent, std::string name, size_t size, Type type=Type::mutex);
46 
51  ~SharedMem();
52 
59  void Write(const char *buf, size_t size);
60 
67  bool Read(char *buf, size_t size, Time nsTimeout=TIME_INFINITE) const;
68 
69 
73  void ReaderReady();
74 private:
75  SharedMem_impl *pimpl_;
76  Type type;
77 };
78 
79 } // end namespace core
80 } // end namespace flair
81 
82 #endif // SHAREDMEM_H
Base class for all Framework's classes.
Definition: Object.h:77
namespace of the flair Framework
Definition: Ahrs.h:19
void ReaderReady()
This function should be called when reader is ready (in case of a SharedMem of type producerConsumer)...
SharedMem(const Object *parent, std::string name, size_t size, Type type=Type::mutex)
Constructor.
unsigned long long Time
Time definition, in ns.
Definition: Object.h:49
bool Read(char *buf, size_t size, Time nsTimeout=TIME_INFINITE) const
Read.
Class defining a shared memory.
Definition: SharedMem.h:32
Base class for all Framework's classes.
~SharedMem()
Destructor.
void Write(const char *buf, size_t size)
Write.