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