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 };
46  SharedMem(const Object *parent, std::string name, size_t size, Type type=Type::mutex);
47 
52  ~SharedMem();
53 
60  void Write(const char *buf, size_t size);
61 
68  bool Read(char *buf, size_t size, Time nsTimeout=TIME_INFINITE) const;
69 
70 
74  void ReaderReady();
75 private:
76  SharedMem_impl *pimpl_;
77  Type type;
78 };
79 
80 } // end namespace core
81 } // end namespace flair
82 
83 #endif // SHAREDMEM_H
Base class for all Framework's classes.
Definition: Object.h:83
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:55
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.