Alexandria 2.31.0
SDC-CH common library for the Euclid project
Loading...
Searching...
No Matches
GridCellManagerVectorOfVectors.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2022 Euclid Science Ground Segment
3 *
4 * This library is free software; you can redistribute it and/or modify it under
5 * the terms of the GNU Lesser General Public License as published by the Free
6 * Software Foundation; either version 3.0 of the License, or (at your option)
7 * any later version.
8 *
9 * This library is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12 * details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this library; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19#ifndef GRIDCONTAINER_SERIALIZATION_GRIDCONTAINER_H
20#define GRIDCONTAINER_SERIALIZATION_GRIDCONTAINER_H
21
23#include <boost/serialization/array.hpp>
24#include <boost/serialization/collection_traits.hpp>
25#include <boost/serialization/nvp.hpp>
26#include <boost/serialization/serialization.hpp>
27
28namespace boost {
29namespace serialization {
30
31template <class Archive, typename T>
32void save(Archive& ar, const Euclid::GridContainer::VectorValueProxy<T>& value_proxy, const unsigned int) {
33 size_t count = value_proxy.size();
34 ar << BOOST_SERIALIZATION_NVP(count);
35 if (count > 0) {
36 ar << make_array<const T>(static_cast<const T*>(&value_proxy[0]), count);
37 }
38}
39
40template <class Archive, typename T>
41void load(Archive& ar, Euclid::GridContainer::VectorValueProxy<T>& value_proxy, const unsigned int) {
42 size_t count;
43 ar >> BOOST_SERIALIZATION_NVP(count);
44 assert(count == value_proxy.size());
45 T* ptr = &value_proxy[0];
46 while (count-- > 0) {
47 ar >> boost::serialization::make_nvp("item", *ptr++);
48 }
49}
50
51template <class Archive, typename T>
52void serialize(Archive& ar, Euclid::GridContainer::VectorValueProxy<T>& value_proxy, const unsigned int version) {
53 split_free(ar, value_proxy, version);
54}
55
56} // namespace serialization
57} // namespace boost
58
59BOOST_SERIALIZATION_COLLECTION_TRAITS(Euclid::GridContainer::VectorValueProxy)
60
61#endif // GRIDCONTAINER_SERIALIZATION_GRIDCONTAINER_H
void serialize(Archive &archive, std::array< CellType, ND > &array, const unsigned int)
Definition array.h:37
void load(Archive &ar, Euclid::GridContainer::VectorValueProxy< T > &value_proxy, const unsigned int)
void save(Archive &ar, const Euclid::GridContainer::VectorValueProxy< T > &value_proxy, const unsigned int)
Definition array.h:33