lsst.afw  19.0.0-24-gf0e72354e+1
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>
11 #include "lsst/afw/image/Filter.h"
12 
13 namespace lsst {
14 namespace afw {
15 namespace image {
16 
26 class Color final {
27 public:
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  double getLambdaEff(Filter const &
62  ) const {
63  return 1000 * _g_r;
64  }
65 
66 private:
67  double _g_r;
68 };
69 } // namespace image
70 } // namespace afw
71 } // namespace lsst
72 
73 namespace std {
74 template <>
75 struct hash<lsst::afw::image::Color> {
78  size_t operator()(argument_type const &obj) const noexcept { return obj.hash_value(); }
79 };
80 } // namespace std
81 
82 #endif
lsst::afw::image
Backwards-compatibility support for depersisting the old Calib (FluxMag0/FluxMag0Err) objects.
Definition: imageAlgorithm.dox:1
lsst::afw::image::Color::hash_value
std::size_t hash_value() const noexcept
Return a hash of this object.
Definition: Color.h:57
lsst::afw::image::Color::~Color
~Color() noexcept=default
lsst::afw::image::Color::getLambdaEff
double getLambdaEff(Filter const &) const
Return the effective wavelength for this object in the given filter.
Definition: Color.h:61
lsst::afw::image::Color::operator=
Color & operator=(Color const &)=default
lsst::afw::image::Color::Color
Color(Color &&)=default
lsst::afw::image::Filter
Holds an integer identifier for an LSST filter.
Definition: Filter.h:141
lsst::afw::image::Color::Color
Color(double g_r=std::numeric_limits< double >::quiet_NaN())
Definition: Color.h:28
lsst::afw::image::Color::isIndeterminate
bool isIndeterminate() const noexcept
Whether the color is the special value that indicates that it is unspecified.
Definition: Color.h:37
Filter.h
lsst::afw::image::Color::Color
Color(Color const &)=default
std::isnan
T isnan(T... args)
other
ItemVariant const * other
Definition: Schema.cc:56
lsst
A base class for image defects.
lsst::afw::image::Color::operator==
bool operator==(Color const &other) const noexcept
Equality comparison for colors.
Definition: Color.h:50
std
STL namespace.
std::size_t
lsst::afw::image::Color::operator!=
bool operator!=(Color const &other) const noexcept
Definition: Color.h:53
std::numeric_limits
std::hash< lsst::afw::image::Color >::operator()
size_t operator()(argument_type const &obj) const noexcept
Definition: Color.h:78
lsst::afw::image::Color
Describe the colour of a source.
Definition: Color.h:26
lsst::afw::image::Color::operator=
Color & operator=(Color &&)=default
std::hash