[76] | 1 | // %pacpus:license{
|
---|
[62] | 2 | // This file is part of the PACPUS framework distributed under the
|
---|
| 3 | // CECILL-C License, Version 1.0.
|
---|
[76] | 4 | // %pacpus:license}
|
---|
[66] | 5 | /// @file
|
---|
[62] | 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.
|
---|
[3] | 13 |
|
---|
[31] | 14 | #ifndef DEF_PACPUS_SHMEMBASE_H
|
---|
| 15 | #define DEF_PACPUS_SHMEMBASE_H
|
---|
[3] | 16 |
|
---|
[69] | 17 | /// Base class for shared memory objects.
|
---|
[3] | 18 | class ShMemBase
|
---|
| 19 | {
|
---|
| 20 | public:
|
---|
[69] | 21 | /// Ctor
|
---|
| 22 | ShMemBase()
|
---|
| 23 | {
|
---|
| 24 | }
|
---|
[3] | 25 |
|
---|
[69] | 26 | /// Dtor
|
---|
| 27 | virtual ~ShMemBase()
|
---|
| 28 | {
|
---|
| 29 | }
|
---|
[3] | 30 |
|
---|
[69] | 31 | /// Use this method to get the data of the shared memory
|
---|
| 32 | virtual void *read() = 0;
|
---|
[3] | 33 |
|
---|
[69] | 34 | /// Use this method to write data in shared memory
|
---|
| 35 | virtual void write(void *data, int size, unsigned long offset = 0) = 0;
|
---|
[3] | 36 |
|
---|
[69] | 37 | /// Use this method to wait the incoming of new data
|
---|
| 38 | /// you can specify a timeout in ms to avoid infinite blocking or 0 (infinite)
|
---|
| 39 | /// @returns @b true if new data available before the timeout, @b false otherwise
|
---|
| 40 | virtual bool wait(unsigned long timeout = 0) = 0;
|
---|
[3] | 41 |
|
---|
[69] | 42 | /// To lock the access to the memory
|
---|
| 43 | virtual void lockMemory() = 0;
|
---|
[3] | 44 |
|
---|
[69] | 45 | /// To unlock the access to the memory
|
---|
| 46 | virtual void unlockMemory() = 0;
|
---|
[3] | 47 |
|
---|
| 48 | #ifdef WIN32
|
---|
[69] | 49 | /// Return the event handle under Windows
|
---|
| 50 | /// @todo ... under Linux ?
|
---|
| 51 | virtual void * getEventIdentifier() = 0;
|
---|
[3] | 52 | #endif
|
---|
| 53 |
|
---|
| 54 | protected:
|
---|
[69] | 55 | /// @todo Documentation
|
---|
| 56 | void * shMem_;
|
---|
| 57 |
|
---|
[3] | 58 | private:
|
---|
| 59 | };
|
---|
| 60 |
|
---|
[31] | 61 | #endif // DEF_PACPUS_SHMEMBASE_H
|
---|