lsst.afw  18.1.0-18-gf57f4888d+1
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 
54  // Can't wrap clone(); PYBIND11_OVERLOAD chokes on unique_ptr return type
55 
56  std::string toString() const override {
57  PYBIND11_OVERLOAD_NAME(std::string, Base, "__repr__", toString, );
58  }
59 
60  std::size_t hash_value() const override {
61  PYBIND11_OVERLOAD_NAME(std::size_t, Base, "__hash__", hash_value, );
62  }
63 
64  bool equals(Base const& other) const noexcept override {
65  PYBIND11_OVERLOAD_NAME(bool, Base, "__eq__", equals, other);
66  }
67 };
68 
69 std::string declareGenericMapRestrictions(std::string const& className, std::string const& keyName);
70 
71 } // namespace typehandling
72 } // namespace afw
73 } // namespace lsst
74 
75 #endif
std::size_t hash_value() const override
Definition: python.h:60
ItemVariant const * other
Definition: Schema.cc:56
STL class.
std::string toString() const override
Definition: python.h:56
A base class for image defects.
"Trampoline" for Storable to let it be used as a base class in Python.
Definition: python.h:50
bool equals(Base const &other) const noexcept override
Definition: python.h:64
std::string declareGenericMapRestrictions(std::string const &className, std::string const &keyName)
Definition: python.cc:32