[89] | 1 | // %pacpus:license{
|
---|
| 2 | // This file is part of the PACPUS framework distributed under the
|
---|
| 3 | // CECILL-C License, Version 1.0.
|
---|
| 4 | // %pacpus:license}
|
---|
| 5 | /// @file
|
---|
[162] | 6 | /// @author Gerald Dherbomez <firstname.surname@utc.fr>
|
---|
| 7 | /// @date January, 2007
|
---|
[89] | 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.
|
---|
| 13 |
|
---|
| 14 | #ifndef DEF_PACPUS_SHMEM_H
|
---|
| 15 | #define DEF_PACPUS_SHMEM_H
|
---|
| 16 |
|
---|
[126] | 17 | #include "PacpusToolsConfig.h"
|
---|
| 18 |
|
---|
[89] | 19 | #ifdef WIN32
|
---|
| 20 | # include "Win32ShMem.h"
|
---|
| 21 | /// Defines shared memory as a Windows shared memory
|
---|
| 22 | # define ShMemType Win32ShMem
|
---|
| 23 | #else
|
---|
| 24 | # include "PosixShMem.h"
|
---|
| 25 | /// Defines shared memory as a POSIX shared memory
|
---|
| 26 | # define ShMemType PosixShMem
|
---|
| 27 | #endif
|
---|
| 28 |
|
---|
| 29 | namespace pacpus {
|
---|
| 30 |
|
---|
| 31 | /// Shared memory class.
|
---|
| 32 | ///
|
---|
| 33 | /// Inherits from Win32ShMem on Windows system and from PosixShMem on Unix-like systems.
|
---|
[162] | 34 | class /*PACPUSTOOLS_API*/ ShMem
|
---|
[89] | 35 | : public ShMemType
|
---|
| 36 | {
|
---|
| 37 | public:
|
---|
| 38 | /// Ctor of shared memory class.
|
---|
| 39 | ///
|
---|
| 40 | /// Creates a shared memory of size @b size and named @b name.
|
---|
| 41 | /// If a shared memory with the name @b name already exists, than
|
---|
| 42 | /// it will return object pointing to the same memory.
|
---|
| 43 | /// If this existing memory space has a size smaller than @b size,
|
---|
| 44 | /// a warning will be issued.
|
---|
| 45 | ///
|
---|
| 46 | /// @param name Name of the created shared memory space.
|
---|
| 47 | /// @param size Size of the created shared memory space in [bytes].
|
---|
| 48 | ShMem(const char * name, int size)
|
---|
| 49 | : ShMemType(name, size)
|
---|
| 50 | {
|
---|
| 51 | }
|
---|
| 52 |
|
---|
| 53 | /// Dtor of shared memory class.
|
---|
| 54 | ///
|
---|
| 55 | /// Does nothing.
|
---|
| 56 | ~ShMem()
|
---|
| 57 | {
|
---|
| 58 | }
|
---|
| 59 |
|
---|
| 60 | protected:
|
---|
| 61 | private:
|
---|
| 62 | };
|
---|
| 63 |
|
---|
| 64 | } // namespace pacpus
|
---|
| 65 |
|
---|
| 66 | #endif // DEF_PACPUS_SHMEM_H
|
---|