| Line |
Branch |
Exec |
Source |
| 1 |
|
|
// Copyright (c) 2019 Max Planck Gesellschaft |
| 2 |
|
|
// Author : Vincent Berenz |
| 3 |
|
|
|
| 4 |
|
|
#pragma once |
| 5 |
|
|
|
| 6 |
|
|
// This is non public support code for shared_memory::array |
| 7 |
|
|
|
| 8 |
|
|
namespace shared_memory |
| 9 |
|
|
{ |
| 10 |
|
|
typedef std::integral_constant<int, 0> SERIALIZABLE; |
| 11 |
|
|
typedef std::integral_constant<int, 1> FUNDAMENTAL; |
| 12 |
|
|
typedef std::integral_constant<int, 2> FUNDAMENTAL_ARRAY; |
| 13 |
|
|
|
| 14 |
|
|
namespace internal |
| 15 |
|
|
{ |
| 16 |
|
|
// defining members for serializable instances, |
| 17 |
|
|
// which will be stored as char arrays |
| 18 |
|
|
template <typename T, int SIZE = 0, typename Enable = void> |
| 19 |
|
6 |
class array_members |
| 20 |
|
|
{ |
| 21 |
|
|
protected: |
| 22 |
|
|
Serializer<T> serializer_; |
| 23 |
|
|
char* shared_; |
| 24 |
|
|
std::size_t item_size_; |
| 25 |
|
|
std::size_t total_size_; |
| 26 |
|
|
SERIALIZABLE type_; |
| 27 |
|
|
}; |
| 28 |
|
|
|
| 29 |
|
|
// defining members for fundamental types |
| 30 |
|
|
// which will directly be stored |
| 31 |
|
|
template <typename T> |
| 32 |
|
|
class array_members< |
| 33 |
|
|
T, |
| 34 |
|
|
0, |
| 35 |
|
|
typename std::enable_if<std::is_fundamental<T>::value>::type> |
| 36 |
|
|
{ |
| 37 |
|
|
protected: |
| 38 |
|
|
T* shared_; |
| 39 |
|
|
FUNDAMENTAL type_; |
| 40 |
|
|
}; |
| 41 |
|
|
|
| 42 |
|
|
// defining members for array of fundamental types, |
| 43 |
|
|
// which will be directly stored |
| 44 |
|
|
template <typename T, int SIZE> |
| 45 |
|
|
class array_members< |
| 46 |
|
|
T, |
| 47 |
|
|
SIZE, |
| 48 |
|
|
typename std::enable_if<std::is_fundamental<T>::value && SIZE != 0>::type> |
| 49 |
|
|
{ |
| 50 |
|
|
protected: |
| 51 |
|
|
T* shared_; |
| 52 |
|
|
std::size_t total_size_; |
| 53 |
|
|
FUNDAMENTAL_ARRAY type_; |
| 54 |
|
|
}; |
| 55 |
|
|
|
| 56 |
|
|
} // namespace internal |
| 57 |
|
|
|
| 58 |
|
|
} // namespace shared_memory |
| 59 |
|
|
|