Loading [MathJax]/extensions/tex2jax.js
LSST Applications g04a91732dc+cc8870d3f5,g07dc498a13+5aa0b8792f,g0fba68d861+488cddfaa9,g1409bbee79+5aa0b8792f,g1a7e361dbc+5aa0b8792f,g1fd858c14a+f64bc332a9,g35bb328faa+fcb1d3bbc8,g4d2262a081+b1c1982739,g4d39ba7253+9633a327c1,g4e0f332c67+5d362be553,g53246c7159+fcb1d3bbc8,g60b5630c4e+9633a327c1,g668ecb457e+25d63fd678,g78460c75b0+2f9a1b4bcd,g786e29fd12+cf7ec2a62a,g7b71ed6315+fcb1d3bbc8,g8852436030+8b64ca622a,g89139ef638+5aa0b8792f,g89e1512fd8+37f975783e,g8d6b6b353c+9633a327c1,g9125e01d80+fcb1d3bbc8,g989de1cb63+5aa0b8792f,g9f33ca652e+b196626af7,ga9baa6287d+9633a327c1,gaaedd4e678+5aa0b8792f,gabe3b4be73+1e0a283bba,gb1101e3267+71e32094df,gb58c049af0+f03b321e39,gb90eeb9370+2807b1ad02,gc741bbaa4f+1ae86710ed,gcf25f946ba+8b64ca622a,gd315a588df+a39986a76f,gd6cbbdb0b4+c8606af20c,gd9a9a58781+fcb1d3bbc8,gde0f65d7ad+94dfc458f4,ge278dab8ac+932305ba37,ge82c20c137+76d20ab76d,gfe73954cf8+a1301e4c20,w.2025.11
LSST Data Management Base Package
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
tristate.h
Go to the documentation of this file.
1/*
2 * This file is part of sphgeom.
3 *
4 * Developed for the LSST Data Management System.
5 * This product includes software developed by the LSST Project
6 * (http://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 software is dual licensed under the GNU General Public License and also
11 * under a 3-clause BSD license. Recipients may choose which of these licenses
12 * to use; please see the files gpl-3.0.txt and/or bsd_license.txt,
13 * respectively. If you choose the GPL option then the following text applies
14 * (but note that there is still no warranty even if you opt for BSD instead):
15 *
16 * This program is free software: you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation, either version 3 of the License, or
19 * (at your option) any later version.
20 *
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License
27 * along with this program. If not, see <http://www.gnu.org/licenses/>.
28 */
29
30#ifndef LSST_SPHGEOM_PYTHON_TRISTATE_H_
31#define LSST_SPHGEOM_PYTHON_TRISTATE_H_
32
33#include "pybind11/pybind11.h"
34
35#include "../TriState.h"
36
37namespace pybind11 {
38namespace detail {
39
46template <>
47struct type_caster<lsst::sphgeom::TriState> {
48public:
49 // Declare a local variable `value` of type lsst::sphgeom::TriState,
50 // and describe the TriState type as an "bool | None" in pybind11-generated
51 // docstrings.
53
54 // Convert a Python object to an lsst::sphgeom::TriState.
55 bool load(handle src, bool) {
56 if (src.is_none()) {
58 } else {
59 value = lsst::sphgeom::TriState(src.cast<bool>());
60 }
61 return true;
62 }
63
64 // Convert an lsst::sphgeom::TriState to a Python integer.
65 static handle cast(lsst::sphgeom::TriState src, return_value_policy,
66 handle) {
67
68 if (src == true) {
69 Py_RETURN_TRUE;
70 } else if (src == false) {
71 Py_RETURN_FALSE;
72 }
73 Py_RETURN_NONE;
74 }
75};
76
77} // detail
78} // pybind11
79
80#endif // LSST_SPHGEOM_PYTHON_TRISTATE_H_
This file declares a class for representing tri-state values.
TriState represents a boolean value with additional unknown state.
Definition TriState.h:46
static handle cast(lsst::sphgeom::TriState src, return_value_policy, handle)
Definition tristate.h:65
PYBIND11_TYPE_CASTER(lsst::sphgeom::TriState, _("bool | None"))