LSSTApplications  20.0.0
LSSTDataManagementBasePackage
_persistable.cc
Go to the documentation of this file.
1 /*
2  * Developed for the LSST Data Management System.
3  * This product includes software developed by the LSST Project
4  * (https://www.lsst.org).
5  * See the COPYRIGHT file at the top-level directory of this distribution
6  * for details of code ownership.
7  *
8  * This program is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <https://www.gnu.org/licenses/>.
20  */
21 
22 #include "pybind11/pybind11.h"
23 
24 #include "lsst/utils/python.h"
25 
27 #include "lsst/afw/fits.h"
28 
29 namespace py = pybind11;
30 using namespace py::literals;
31 
32 namespace lsst {
33 namespace afw {
34 namespace table {
35 namespace io {
36 
37 using PyPersistable = py::class_<Persistable, std::shared_ptr<Persistable>>;
38 
40  // TODO: uncomment once afw.fits uses WrapperCollection
41  // wrappers.addSignatureDependency("lsst.afw.fits");
42 
43  wrappers.wrapType(PyPersistable(wrappers.module, "Persistable"), [](auto &mod, auto &cls) {
44  cls.def("writeFits",
45  (void (Persistable::*)(std::string const &, std::string const &) const) &
46  Persistable::writeFits,
47  "fileName"_a, "mode"_a = "w");
48  cls.def("writeFits",
49  (void (Persistable::*)(fits::MemFileManager &, std::string const &) const) &
50  Persistable::writeFits,
51  "manager"_a, "mode"_a = "w");
52  cls.def("isPersistable", &Persistable::isPersistable);
53  });
54 }
55 
56 } // namespace io
57 } // namespace table
58 } // namespace afw
59 } // namespace lsst
fits.h
lsst::afw
Definition: imageAlgorithm.dox:1
lsst::afw::geom.transform.transformContinued.cls
cls
Definition: transformContinued.py:33
lsst::afw::table::io::PyPersistable
py::class_< Persistable, std::shared_ptr< Persistable > > PyPersistable
Definition: _persistable.cc:37
lsst::utils::python::WrapperCollection::wrapType
PyType wrapType(PyType cls, ClassWrapperCallback function, bool setModuleName=true)
Add a type (class or enum) wrapper, deferring method and other attribute definitions until finish() i...
Definition: python.h:391
lsst::utils::python::WrapperCollection
A helper class for subdividing pybind11 module across multiple translation units (i....
Definition: python.h:242
lsst
A base class for image defects.
Definition: imageAlgorithm.dox:1
python.h
Persistable.h
pybind11
Definition: _GenericMap.cc:40
lsst::utils::python::WrapperCollection::module
pybind11::module module
The module object passed to the PYBIND11_MODULE block that contains this WrapperCollection.
Definition: python.h:448
lsst::afw::table::io::wrapPersistable
void wrapPersistable(WrapperCollection &)
Definition: _persistable.cc:39