[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: ShMem.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_SHMEM_H
|
---|
| 14 | #define DEF_PACPUS_SHMEM_H
|
---|
[3] | 15 |
|
---|
| 16 | #ifdef WIN32
|
---|
| 17 | # include "Win32ShMem.h"
|
---|
[69] | 18 | /// Defines shared memory as a Windows shared memory
|
---|
[3] | 19 | # define ShMemType Win32ShMem
|
---|
| 20 | #else
|
---|
| 21 | # include "PosixShMem.h"
|
---|
[69] | 22 | /// Defines shared memory as a POSIX shared memory
|
---|
[3] | 23 | # define ShMemType PosixShMem
|
---|
| 24 | #endif
|
---|
| 25 |
|
---|
| 26 | namespace pacpus {
|
---|
| 27 |
|
---|
[69] | 28 | /// Shared memory class.
|
---|
| 29 | ///
|
---|
| 30 | /// Inherits from Win32ShMem on Windows system and from PosixShMem on Unix-like systems.
|
---|
[3] | 31 | class ShMem
|
---|
[69] | 32 | : public ShMemType
|
---|
[3] | 33 | {
|
---|
| 34 | public:
|
---|
[69] | 35 | /// Ctor of shared memory class.
|
---|
[67] | 36 | ///
|
---|
| 37 | /// Creates a shared memory of size @b size and named @b name.
|
---|
| 38 | /// If a shared memory with the name @b name already exists, than
|
---|
| 39 | /// it will return object pointing to the same memory.
|
---|
| 40 | /// If this existing memory space has a size smaller than @b size,
|
---|
| 41 | /// a warning will be issued.
|
---|
| 42 | ///
|
---|
| 43 | /// @param name Name of the created shared memory space.
|
---|
| 44 | /// @param size Size of the created shared memory space in [bytes].
|
---|
[3] | 45 | ShMem(const char * name, int size)
|
---|
| 46 | : ShMemType(name, size)
|
---|
| 47 | {
|
---|
| 48 | }
|
---|
| 49 |
|
---|
[69] | 50 | /// Dtor of shared memory class.
|
---|
[67] | 51 | ///
|
---|
| 52 | /// Does nothing.
|
---|
[3] | 53 | ~ShMem()
|
---|
| 54 | {
|
---|
| 55 | }
|
---|
| 56 |
|
---|
| 57 | protected:
|
---|
| 58 | private:
|
---|
| 59 | };
|
---|
| 60 |
|
---|
| 61 | } // namespace pacpus
|
---|
| 62 |
|
---|
[31] | 63 | #endif // DEF_PACPUS_SHMEM_H
|
---|