LSSTApplications  18.1.0
LSSTDataManagementBasePackage
slots.cc
Go to the documentation of this file.
1 /*
2  * LSST Data Management System
3  * Copyright 2008-2016 AURA/LSST.
4  *
5  * This product includes software developed by the
6  * LSST Project (http://www.lsst.org/).
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 LSST License Statement and
19  * the GNU General Public License along with this program. If not,
20  * see <https://www.lsstcorp.org/LegalNotices/>.
21  */
22 
23 #include "pybind11/pybind11.h"
24 #include "pybind11/eigen.h"
25 
26 #include "lsst/afw/table/slots.h"
27 
28 namespace py = pybind11;
29 using namespace pybind11::literals;
30 
31 namespace lsst {
32 namespace afw {
33 namespace table {
34 namespace {
35 
36 // tiny classes only used in afw::table: no need for shared_ptr.
37 using PySlotDefinition = py::class_<SlotDefinition>;
38 
39 void declareSlotDefinition(py::module &mod) {
40  PySlotDefinition cls(mod, "SlotDefinition");
41  cls.def("getName", &SlotDefinition::getName);
42  cls.def("getAlias", &SlotDefinition::getAlias);
43 }
44 
45 /*
46 Declare standard methods for subclasses of SlotDefinition (but not SlotDefinition itself).
47 */
48 template <typename Class>
49 void declareSlotDefinitionSubclass(py::module &mod, std::string const &name) {
50  py::class_<Class, SlotDefinition> cls(mod, name.c_str());
51  cls.def(py::init<std::string const &>(), "name"_a);
52  cls.def("isValid", &Class::isValid);
53  cls.def("getMeasKey", &Class::getMeasKey);
54  cls.def("getErrKey", &Class::getErrKey);
55  cls.def("getFlagKey", &Class::getFlagKey);
56  cls.def("setKeys", &Class::setKeys, "alias"_a, "schema"_a);
57 }
58 
59 PYBIND11_MODULE(slots, mod) {
60  py::module::import("lsst.afw.table.aggregates");
61 
62  declareSlotDefinition(mod);
63  declareSlotDefinitionSubclass<FluxSlotDefinition>(mod, "Flux");
64  declareSlotDefinitionSubclass<CentroidSlotDefinition>(mod, "Centroid");
65  declareSlotDefinitionSubclass<ShapeSlotDefinition>(mod, "Shape");
66 }
67 }
68 }
69 }
70 } // namespace lsst::afw::table::<anonymous>
PYBIND11_MODULE(camera, mod)
Definition: camera.cc:34
STL class.
A base class for image defects.
bool isValid
Definition: fits.cc:380
T c_str(T... args)