1 | // This file is part of the PACPUS framework distributed under the
|
---|
2 | // CECILL-C License, Version 1.0.
|
---|
3 | //
|
---|
4 | /// @file
|
---|
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.
|
---|
12 |
|
---|
13 | #ifndef DEF_PACPUS_SHMEMBASE_H
|
---|
14 | #define DEF_PACPUS_SHMEMBASE_H
|
---|
15 |
|
---|
16 | /// Base class for shared memory objects.
|
---|
17 | class ShMemBase
|
---|
18 | {
|
---|
19 | public:
|
---|
20 | /// Ctor
|
---|
21 | ShMemBase()
|
---|
22 | {
|
---|
23 | }
|
---|
24 |
|
---|
25 | /// Dtor
|
---|
26 | virtual ~ShMemBase()
|
---|
27 | {
|
---|
28 | }
|
---|
29 |
|
---|
30 | /// Use this method to get the data of the shared memory
|
---|
31 | virtual void *read() = 0;
|
---|
32 |
|
---|
33 | /// Use this method to write data in shared memory
|
---|
34 | virtual void write(void *data, int size, unsigned long offset = 0) = 0;
|
---|
35 |
|
---|
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;
|
---|
40 |
|
---|
41 | /// To lock the access to the memory
|
---|
42 | virtual void lockMemory() = 0;
|
---|
43 |
|
---|
44 | /// To unlock the access to the memory
|
---|
45 | virtual void unlockMemory() = 0;
|
---|
46 |
|
---|
47 | #ifdef WIN32
|
---|
48 | /// Return the event handle under Windows
|
---|
49 | /// @todo ... under Linux ?
|
---|
50 | virtual void * getEventIdentifier() = 0;
|
---|
51 | #endif
|
---|
52 |
|
---|
53 | protected:
|
---|
54 | /// @todo Documentation
|
---|
55 | void * shMem_;
|
---|
56 |
|
---|
57 | private:
|
---|
58 | };
|
---|
59 |
|
---|
60 | #endif // DEF_PACPUS_SHMEMBASE_H
|
---|