lsst.afw g8f2ba02de7+e31e6a4341
Color.h
Go to the documentation of this file.
1// -*- lsst-c++ -*-
2/*
3 * Capture the colour of an object
4 */
5
6#ifndef LSST_AFW_IMAGE_COLOR_H
7#define LSST_AFW_IMAGE_COLOR_H
8
9#include <cmath>
10#include <limits>
12
13namespace lsst {
14namespace afw {
15namespace image {
16
26class Color final {
27public:
28 explicit Color(double g_r = std::numeric_limits<double>::quiet_NaN()) : _g_r(g_r) {}
29
30 Color(Color const &) = default;
31 Color(Color &&) = default;
32 Color &operator=(Color const &) = default;
33 Color &operator=(Color &&) = default;
34 ~Color() noexcept = default;
35
37 bool isIndeterminate() const noexcept { return std::isnan(_g_r); }
38
40
50 bool operator==(Color const &other) const noexcept {
51 return (isIndeterminate() && other.isIndeterminate()) || other._g_r == _g_r;
52 }
53 bool operator!=(Color const &other) const noexcept { return !operator==(other); }
55
57 std::size_t hash_value() const noexcept { return isIndeterminate() ? 42 : std::hash<double>()(_g_r); }
58
61 [
62 [deprecated("Removed with no replacement (but see lsst::afw::image::TransmissionCurve). Will be "
63 "removed after v22.")]] double
65 ) const {
66 return 1000 * _g_r;
67 }
68
69private:
70 double _g_r;
71};
72} // namespace image
73} // namespace afw
74} // namespace lsst
75
76namespace std {
77template <>
78struct hash<lsst::afw::image::Color> {
81 size_t operator()(argument_type const &obj) const noexcept { return obj.hash_value(); }
82};
83} // namespace std
84
85#endif
Describe the colour of a source.
Definition: Color.h:26
bool operator==(Color const &other) const noexcept
Equality comparison for colors.
Definition: Color.h:50
Color(Color &&)=default
~Color() noexcept=default
Color(double g_r=std::numeric_limits< double >::quiet_NaN())
Definition: Color.h:28
Color & operator=(Color const &)=default
Color(Color const &)=default
std::size_t hash_value() const noexcept
Return a hash of this object.
Definition: Color.h:57
bool isIndeterminate() const noexcept
Whether the color is the special value that indicates that it is unspecified.
Definition: Color.h:37
double getLambdaEff(Filter const &) const
Return the effective wavelength for this object in the given filter.
Definition: Color.h:64
bool operator!=(Color const &other) const noexcept
Definition: Color.h:53
Color & operator=(Color &&)=default
T isnan(T... args)
Backwards-compatibility support for depersisting the old Calib (FluxMag0/FluxMag0Err) objects.
class[[deprecated("Removed with no replacement (but see lsst::afw::image::TransmissionCurve). Will be " "removed after v22.")]] FilterProperty final
Describe the properties of a Filter (e.g.
Definition: Filter.h:53
A base class for image defects.
STL namespace.
size_t operator()(argument_type const &obj) const noexcept
Definition: Color.h:81