[89] | 1 | // %pacpus:license{
|
---|
| 2 | // This file is part of the PACPUS framework distributed under the
|
---|
| 3 | // CECILL-C License, Version 1.0.
|
---|
| 4 | // %pacpus:license}
|
---|
| 5 | /// @file
|
---|
| 6 | /// @author Firstname Surname <firstname.surname@utc.fr>
|
---|
| 7 | /// @date Month, Year
|
---|
| 8 | /// @version $Id: ShMemBase.h 76 2013-01-10 17:05:10Z kurdejma $
|
---|
| 9 | /// @copyright Copyright (c) UTC/CNRS Heudiasyc 2006 - 2013. All rights reserved.
|
---|
| 10 | /// @brief Brief description.
|
---|
| 11 | ///
|
---|
| 12 | /// Detailed description.
|
---|
| 13 |
|
---|
| 14 | #ifndef DEF_PACPUS_SHMEMBASE_H
|
---|
| 15 | #define DEF_PACPUS_SHMEMBASE_H
|
---|
| 16 |
|
---|
[126] | 17 | #include "PacpusToolsConfig.h"
|
---|
| 18 |
|
---|
[89] | 19 | /// Base class for shared memory objects.
|
---|
[162] | 20 | class PACPUSTOOLS_API ShMemBase
|
---|
[89] | 21 | {
|
---|
| 22 | public:
|
---|
| 23 | /// Ctor
|
---|
| 24 | ShMemBase()
|
---|
| 25 | {
|
---|
| 26 | }
|
---|
| 27 |
|
---|
| 28 | /// Dtor
|
---|
| 29 | virtual ~ShMemBase()
|
---|
| 30 | {
|
---|
| 31 | }
|
---|
| 32 |
|
---|
| 33 | /// Use this method to get the data of the shared memory
|
---|
| 34 | virtual void *read() = 0;
|
---|
| 35 |
|
---|
| 36 | /// Use this method to write data in shared memory
|
---|
| 37 | virtual void write(void *data, int size, unsigned long offset = 0) = 0;
|
---|
| 38 |
|
---|
| 39 | /// Use this method to wait the incoming of new data
|
---|
| 40 | /// you can specify a timeout in ms to avoid infinite blocking or 0 (infinite)
|
---|
| 41 | /// @returns @b true if new data available before the timeout, @b false otherwise
|
---|
| 42 | virtual bool wait(unsigned long timeout = 0) = 0;
|
---|
| 43 |
|
---|
| 44 | /// To lock the access to the memory
|
---|
| 45 | virtual void lockMemory() = 0;
|
---|
| 46 |
|
---|
| 47 | /// To unlock the access to the memory
|
---|
| 48 | virtual void unlockMemory() = 0;
|
---|
| 49 |
|
---|
| 50 | #ifdef WIN32
|
---|
| 51 | /// Return the event handle under Windows
|
---|
| 52 | /// @todo ... under Linux ?
|
---|
| 53 | virtual void * getEventIdentifier() = 0;
|
---|
| 54 | #endif
|
---|
| 55 |
|
---|
| 56 | protected:
|
---|
| 57 | /// @todo Documentation
|
---|
| 58 | void * shMem_;
|
---|
| 59 |
|
---|
| 60 | private:
|
---|
| 61 | };
|
---|
| 62 |
|
---|
| 63 | #endif // DEF_PACPUS_SHMEMBASE_H
|
---|