LSSTApplications  18.0.0+67,19.0.0+5,19.0.0+54,19.0.0+57,19.0.0+63,19.0.0+9,19.0.0-1-g20d9b18+23,19.0.0-1-g49a97f9+3,19.0.0-1-g5549ca4+4,19.0.0-1-g8c57eb9+23,19.0.0-1-g8e6e14c+13,19.0.0-1-ga72da6b+3,19.0.0-1-gbfe0924+50,19.0.0-1-ge272bc4+23,19.0.0-1-gefe1d0d+36,19.0.0-11-g57ef05f+1,19.0.0-13-g8db0348+4,19.0.0-14-g706b86db4+1,19.0.0-14-ge428dae,19.0.0-15-g557baf8+8,19.0.0-16-gdc8ce7c+1,19.0.0-2-g0d9f9cd+59,19.0.0-2-g260436e+40,19.0.0-2-g9675b69+3,19.0.0-2-g9b11441+48,19.0.0-2-gde8e5e3+3,19.0.0-2-gf01c5b1+1,19.0.0-2-gff6972b+7,19.0.0-3-g27e4659+25,19.0.0-3-g6513920+52,19.0.0-4-gac56cce+1,19.0.0-41-g13db8fbc+1,19.0.0-43-gbcf6a3c,19.0.0-6-gdd6eb13,19.0.0-7-g686a884+4,19.0.0-9-gce87a591+7,w.2020.14
LSSTDataManagementBasePackage
python.h
Go to the documentation of this file.
1 /*
2  * This file is part of afw.
3  *
4  * Developed for the LSST Data Management System.
5  * This product includes software developed by the LSST Project
6  * (https://www.lsst.org).
7  * See the COPYRIGHT file at the top-level directory of this distribution
8  * for details of code ownership.
9  *
10  * This program is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation, either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program. If not, see <https://www.gnu.org/licenses/>.
22  */
23 
24 #ifndef LSST_AFW_TYPEHANDLING_PYTHON_H
25 #define LSST_AFW_TYPEHANDLING_PYTHON_H
26 
27 #include "pybind11/pybind11.h"
28 
29 #include <string>
30 
32 
33 namespace lsst {
34 namespace afw {
35 namespace typehandling {
36 
49 template <class Base = Storable>
50 class StorableHelper : public Base {
51 public:
52  using Base::Base;
53 
55  /* __deepcopy__ takes an optional dict, but PYBIND11_OVERLOAD_* won't
56  * compile unless you give it arguments that work for the C++ method
57  */
58  PYBIND11_OVERLOAD_NAME(std::shared_ptr<Storable>, Base, "__deepcopy__", cloneStorable, );
59  }
60 
61  std::string toString() const override {
62  PYBIND11_OVERLOAD_NAME(std::string, Base, "__repr__", toString, );
63  }
64 
65  std::size_t hash_value() const override {
66  PYBIND11_OVERLOAD_NAME(std::size_t, Base, "__hash__", hash_value, );
67  }
68 
69  bool equals(Storable const& other) const noexcept override {
70  PYBIND11_OVERLOAD_NAME(bool, Base, "__eq__", equals, other);
71  }
72 };
73 
74 std::string declareGenericMapRestrictions(std::string const& className, std::string const& keyName);
75 
76 } // namespace typehandling
77 } // namespace afw
78 } // namespace lsst
79 
80 #endif
bool equals(Storable const &other) const noexcept override
Definition: python.h:69
std::size_t hash_value() const override
Definition: python.h:65
Interface supporting iteration over heterogenous containers.
Definition: Storable.h:58
ItemVariant const * other
Definition: Schema.cc:56
STL class.
std::shared_ptr< Storable > cloneStorable() const override
Definition: python.h:54
std::string toString() const override
Definition: python.h:61
A base class for image defects.
"Trampoline" for Storable to let it be used as a base class in Python.
Definition: python.h:50
std::string declareGenericMapRestrictions(std::string const &className, std::string const &keyName)
Definition: python.cc:32