lsst.afw  13.0-92-g8ecf155+1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
25 #include "lsst/afw/table/slots.h"
26 
27 namespace py = pybind11;
28 using namespace pybind11::literals;
29 
30 namespace lsst {
31 namespace afw {
32 namespace table {
33 namespace {
34 
35 // tiny classes only used in afw::table: no need for shared_ptr.
36 using PySlotDefinition = py::class_<SlotDefinition>;
37 
38 void declareSlotDefinition(py::module &mod) {
39  PySlotDefinition cls(mod, "SlotDefinition");
40  cls.def("getName", &SlotDefinition::getName);
41  cls.def("getAlias", &SlotDefinition::getAlias);
42 }
43 
44 /*
45 Declare standard methods for subclasses of SlotDefinition (but not SlotDefinition itself).
46 */
47 template <typename Class>
48 void declareSlotDefinitionSubclass(py::module &mod, std::string const &name) {
49  py::class_<Class, SlotDefinition> cls(mod, name.c_str());
50  cls.def(py::init<std::string const &>(), "name"_a);
51  cls.def("isValid", &Class::isValid);
52  cls.def("getMeasKey", &Class::getMeasKey);
53  cls.def("getErrKey", &Class::getErrKey);
54  cls.def("getFlagKey", &Class::getFlagKey);
55  cls.def("setKeys", &Class::setKeys, "alias"_a, "schema"_a);
56 }
57 
58 PYBIND11_PLUGIN(slots) {
59  py::module mod("slots");
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  return mod.ptr();
68 }
69 }
70 }
71 }
72 } // namespace lsst::afw::table::<anonymous>
PYBIND11_PLUGIN(_cameraPoint)
Definition: cameraPoint.cc:35
table::Key< std::string > name
Definition: ApCorrMap.cc:71
double const _a
Definition: RandomImage.cc:77