added: handler for vectors in eclmpiserializer

this shall be used by users when they have a vector of types
with a serializeOp template. it cannot (at least not right now)
be part of the regular operator() as some vectors should go
directly to the underlying serializer (trivial types).

we can possibly find some traits magic for this later.
This commit is contained in:
Arne Morten Kvarving
2020-03-10 14:28:00 +01:00
parent 1d2b24f54f
commit 91e9d952d8

View File

@@ -48,6 +48,31 @@ public:
Mpi::unpack(const_cast<T&>(data), m_buffer, m_position, m_comm);
}
template<class T>
void vector(std::vector<T>& data)
{
static_assert(!std::is_pod<T>::value, "Do not call this for POD vectors");
auto handle = [&](auto& d)
{
for (auto& it : d) {
it.serializeOp(*this);
}
};
if (m_op == Operation::PACKSIZE) {
m_packSize += Mpi::packSize(data.size(), m_comm);
handle(data);
} else if (m_op == Operation::PACK) {
Mpi::pack(data.size(), m_buffer, m_position, m_comm);
handle(data);
} else if (m_op == Operation::UNPACK) {
size_t size;
Mpi::unpack(size, m_buffer, m_position, m_comm);
data.resize(size);
handle(data);
}
}
template<class T>
void pack(T& data)
{