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