mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
changed: handle pairs as tuples in eclmpiserializer
This commit is contained in:
parent
fdb2743ca9
commit
3c389d5ece
@ -89,12 +89,10 @@ public:
|
|||||||
{
|
{
|
||||||
if constexpr (is_ptr<T>::value) {
|
if constexpr (is_ptr<T>::value) {
|
||||||
ptr(data);
|
ptr(data);
|
||||||
} else if constexpr (is_pair<T>::value) {
|
} else if constexpr (is_pair_or_tuple<T>::value) {
|
||||||
pair(data);
|
tuple(data);
|
||||||
} else if constexpr (is_variant<T>::value) {
|
} else if constexpr (is_variant<T>::value) {
|
||||||
variant(data);
|
variant(data);
|
||||||
} else if constexpr (is_tuple<T>::value) {
|
|
||||||
tuple(data);
|
|
||||||
} else if constexpr (is_optional<T>::value) {
|
} else if constexpr (is_optional<T>::value) {
|
||||||
optional(data);
|
optional(data);
|
||||||
} else if constexpr (is_vector<T>::value) {
|
} else if constexpr (is_vector<T>::value) {
|
||||||
@ -126,8 +124,8 @@ public:
|
|||||||
auto handle = [&](auto& d)
|
auto handle = [&](auto& d)
|
||||||
{
|
{
|
||||||
for (auto& it : d) {
|
for (auto& it : d) {
|
||||||
if constexpr (is_pair<T>::value)
|
if constexpr (is_pair_or_tuple<T>::value)
|
||||||
pair(it);
|
tuple(it);
|
||||||
else if constexpr (is_ptr<T>::value)
|
else if constexpr (is_ptr<T>::value)
|
||||||
ptr(it);
|
ptr(it);
|
||||||
else if constexpr (is_vector<T>::value)
|
else if constexpr (is_vector<T>::value)
|
||||||
@ -188,8 +186,8 @@ public:
|
|||||||
|
|
||||||
auto handle = [&](auto& d) {
|
auto handle = [&](auto& d) {
|
||||||
for (auto& it : d) {
|
for (auto& it : d) {
|
||||||
if constexpr (is_pair<T>::value)
|
if constexpr (is_pair_or_tuple<T>::value)
|
||||||
pair(it);
|
tuple(it);
|
||||||
else if constexpr (is_ptr<T>::value)
|
else if constexpr (is_ptr<T>::value)
|
||||||
ptr(it);
|
ptr(it);
|
||||||
else if constexpr (has_serializeOp<T>::value)
|
else if constexpr (has_serializeOp<T>::value)
|
||||||
@ -268,22 +266,10 @@ public:
|
|||||||
|
|
||||||
//! \brief Handler for std::tuple.
|
//! \brief Handler for std::tuple.
|
||||||
//! \param data The tuple to (de-)serialize
|
//! \param data The tuple to (de-)serialize
|
||||||
template<class... Args>
|
template<class Tuple>
|
||||||
void tuple(const std::tuple<Args...>& data)
|
void tuple(const Tuple& data)
|
||||||
{
|
{
|
||||||
if (m_op == Operation::PACKSIZE) {
|
tuple_call(data);
|
||||||
m_op = Operation::PACKSIZE;
|
|
||||||
m_packSize = 0;
|
|
||||||
tuple_call(data);
|
|
||||||
} else if (m_op == Operation::PACK) {
|
|
||||||
m_position = 0;
|
|
||||||
m_buffer.resize(m_packSize);
|
|
||||||
tuple_call(data);
|
|
||||||
} else if (m_op == Operation::UNPACK) {
|
|
||||||
m_position = 0;
|
|
||||||
m_op = Operation::UNPACK;
|
|
||||||
tuple_call(data);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//! \brief Handler for maps.
|
//! \brief Handler for maps.
|
||||||
@ -311,8 +297,8 @@ public:
|
|||||||
|
|
||||||
auto keyHandle = [&](auto& d)
|
auto keyHandle = [&](auto& d)
|
||||||
{
|
{
|
||||||
if constexpr (is_pair<Key>::value)
|
if constexpr (is_pair_or_tuple<Key>::value)
|
||||||
pair(d);
|
tuple(d);
|
||||||
else if constexpr (has_serializeOp<Key>::value)
|
else if constexpr (has_serializeOp<Key>::value)
|
||||||
d.serializeOp(*this);
|
d.serializeOp(*this);
|
||||||
else
|
else
|
||||||
@ -545,17 +531,6 @@ protected:
|
|||||||
UNPACK //!< Performing de-serialization
|
UNPACK //!< Performing de-serialization
|
||||||
};
|
};
|
||||||
|
|
||||||
//! \brief Predicate for detecting pairs.
|
|
||||||
template<class T>
|
|
||||||
struct is_pair {
|
|
||||||
constexpr static bool value = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<class T1, class T2>
|
|
||||||
struct is_pair<std::pair<T1,T2>> {
|
|
||||||
constexpr static bool value = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
//! \brief Predicate for detecting vectors.
|
//! \brief Predicate for detecting vectors.
|
||||||
template<class T>
|
template<class T>
|
||||||
struct is_vector {
|
struct is_vector {
|
||||||
@ -578,14 +553,19 @@ protected:
|
|||||||
constexpr static bool value = true;
|
constexpr static bool value = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
//! \brief Predicate for detecting tuples.
|
//! \brief Predicate for detecting pairs and tuples.
|
||||||
template<class T>
|
template<class T>
|
||||||
struct is_tuple {
|
struct is_pair_or_tuple {
|
||||||
constexpr static bool value = false;
|
constexpr static bool value = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class... Ts>
|
template<class... Ts>
|
||||||
struct is_tuple<std::tuple<Ts...>> {
|
struct is_pair_or_tuple<std::tuple<Ts...>> {
|
||||||
|
constexpr static bool value = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class T1, class T2>
|
||||||
|
struct is_pair_or_tuple<std::pair<T1,T2>> {
|
||||||
constexpr static bool value = true;
|
constexpr static bool value = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -674,21 +654,6 @@ protected:
|
|||||||
T, std::void_t<decltype(std::declval<T>().serializeOp(std::declval<EclMpiSerializer&>()))>
|
T, std::void_t<decltype(std::declval<T>().serializeOp(std::declval<EclMpiSerializer&>()))>
|
||||||
> : public std::true_type {};
|
> : public std::true_type {};
|
||||||
|
|
||||||
//! \brief Handler for pairs.
|
|
||||||
template<class T1, class T2>
|
|
||||||
void pair(const std::pair<T1,T2>& data)
|
|
||||||
{
|
|
||||||
if constexpr (has_serializeOp<T1>::value)
|
|
||||||
const_cast<T1&>(data.first).serializeOp(*this);
|
|
||||||
else
|
|
||||||
(*this)(data.first);
|
|
||||||
|
|
||||||
if constexpr (has_serializeOp<T2>::value)
|
|
||||||
const_cast<T2&>(data.second).serializeOp(*this);
|
|
||||||
else
|
|
||||||
(*this)(data.second);
|
|
||||||
}
|
|
||||||
|
|
||||||
//! \brief Handler for smart pointers.
|
//! \brief Handler for smart pointers.
|
||||||
template<class PtrType>
|
template<class PtrType>
|
||||||
void ptr(const PtrType& data)
|
void ptr(const PtrType& data)
|
||||||
|
Loading…
Reference in New Issue
Block a user