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 | // created: 2014/02/10
|
---|
6 | // filename: SharedMem.cpp
|
---|
7 | //
|
---|
8 | // author: Guillaume Sanahuja
|
---|
9 | // Copyright Heudiasyc UMR UTC/CNRS 7253
|
---|
10 | //
|
---|
11 | // version: $Id: $
|
---|
12 | //
|
---|
13 | // purpose: Class defining a shared memory
|
---|
14 | //
|
---|
15 | //
|
---|
16 | /*********************************************************************/
|
---|
17 |
|
---|
18 | #include "SharedMem.h"
|
---|
19 | #include "SharedMem_impl.h"
|
---|
20 |
|
---|
21 | using std::string;
|
---|
22 |
|
---|
23 | namespace flair {
|
---|
24 | namespace core {
|
---|
25 |
|
---|
26 | SharedMem::SharedMem(const Object *parent, string name, size_t size, Type type)
|
---|
27 | : Object(parent, name, "shmem"), type(type) {
|
---|
28 | pimpl_ = new SharedMem_impl(this, name, size, type);
|
---|
29 | }
|
---|
30 |
|
---|
31 | SharedMem::~SharedMem() { delete pimpl_; }
|
---|
32 |
|
---|
33 | void SharedMem::Write(const char *buf, size_t size) {
|
---|
34 | pimpl_->Write(buf, size);
|
---|
35 | }
|
---|
36 |
|
---|
37 | bool SharedMem::Read(char *buf, size_t size, Time nsTimeout) const {
|
---|
38 | return pimpl_->Read(buf, size, nsTimeout);
|
---|
39 | }
|
---|
40 |
|
---|
41 | void SharedMem::ReaderReady() {
|
---|
42 | if (type==Type::producerConsumer) pimpl_->ReaderReady();
|
---|
43 | else Warn("Function called for a non producerConsumer\n");
|
---|
44 | }
|
---|
45 |
|
---|
46 | } // end namespace core
|
---|
47 | } // end namespace flair
|
---|