Alexandria
2.14.1
Please provide a description of the project.
GridContainer
GridContainer
serialize.h
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2012-2020 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
25
#ifndef GRIDCONTAINER_SERIALIZE_H
26
#define GRIDCONTAINER_SERIALIZE_H
27
28
#include <iostream>
29
#include <memory>
30
#include <boost/archive/binary_iarchive.hpp>
31
#include <boost/archive/binary_oarchive.hpp>
32
#include <boost/filesystem.hpp>
33
#include "
GridContainer/GridContainer.h
"
34
#include "
GridContainer/serialization/GridContainer.h
"
35
36
namespace
Euclid
{
37
namespace
GridContainer {
38
56
template
<
typename
GridCellManager,
typename
... AxesTypes>
57
void
gridBinaryExport
(
std::ostream
& out,
const
GridContainer<GridCellManager, AxesTypes...>
& grid) {
58
// Do NOT delete this pointer!!! It points to the actual grid
59
const
GridContainer
<GridCellManager, AxesTypes...>* ptr = &grid;
60
boost::archive::binary_oarchive boa {out};
61
boa << ptr;
62
}
63
80
template
<
typename
Gr
id
Type>
81
GridType
gridBinaryImport
(
std::istream
& in) {
82
boost::archive::binary_iarchive bia {in};
83
// Do NOT delete manually this pointer. It is wrapped with a unique_ptr later.
84
GridType* ptr;
85
bia >> ptr;
86
std::unique_ptr<GridType>
matr_ptr {ptr};
87
// We move out to the result the grid pointed by the pointer. The unique_ptr
88
// will delete the (now empty) pointed object
89
return
std::move
(*matr_ptr);
90
}
91
115
template
<
typename
GridCellManager,
typename
... AxesTypes>
116
void
gridFitsExport
(
const
boost::filesystem::path& filename,
117
const
std::string
& hdu_name,
118
const
GridContainer<GridCellManager, AxesTypes...>& grid);
119
131
template
<
typename
Gr
id
Type>
132
GridType
gridFitsImport
(
const
boost::filesystem::path& filename,
int
hdu_index);
133
134
}
// end of namespace GridContainer
135
}
// end of namespace Euclid
136
137
#include "
GridContainer/_impl/FitsSerialize.icpp
"
138
139
#endif
/* GRIDCONTAINER_SERIALIZE_H */
140
std::string
STL class.
Euclid::GridContainer::GridContainer< GridCellManager, AxesTypes... >
std::move
T move(T... args)
Euclid::GridContainer::gridFitsExport
void gridFitsExport(const boost::filesystem::path &filename, const std::string &hdu_name, const GridContainer< GridCellManager, AxesTypes... > &grid)
Exports a Grid as a FITS file.
Euclid::GridContainer::gridBinaryImport
GridType gridBinaryImport(std::istream &in)
Imports from the given stream a grid.
Definition:
serialize.h:81
FitsSerialize.icpp
std::ostream
STL class.
GridContainer.h
Euclid::GridContainer::gridFitsImport
GridType gridFitsImport(const boost::filesystem::path &filename, int hdu_index)
Imports a Grid from a FITS file.
Euclid::GridContainer::gridBinaryExport
void gridBinaryExport(std::ostream &out, const GridContainer< GridCellManager, AxesTypes... > &grid)
Exports to the given output stream the given grid.
Definition:
serialize.h:57
std::istream
STL class.
std::unique_ptr
STL class.
Euclid
Definition:
InstOrRefHolder.h:29
GridContainer.h
Generated by
1.8.17