LSSTApplications  18.0.0+106,18.0.0+50,19.0.0,19.0.0+1,19.0.0+10,19.0.0+11,19.0.0+13,19.0.0+17,19.0.0+2,19.0.0-1-g20d9b18+6,19.0.0-1-g425ff20,19.0.0-1-g5549ca4,19.0.0-1-g580fafe+6,19.0.0-1-g6fe20d0+1,19.0.0-1-g7011481+9,19.0.0-1-g8c57eb9+6,19.0.0-1-gb5175dc+11,19.0.0-1-gdc0e4a7+9,19.0.0-1-ge272bc4+6,19.0.0-1-ge3aa853,19.0.0-10-g448f008b,19.0.0-12-g6990b2c,19.0.0-2-g0d9f9cd+11,19.0.0-2-g3d9e4fb2+11,19.0.0-2-g5037de4,19.0.0-2-gb96a1c4+3,19.0.0-2-gd955cfd+15,19.0.0-3-g2d13df8,19.0.0-3-g6f3c7dc,19.0.0-4-g725f80e+11,19.0.0-4-ga671dab3b+1,19.0.0-4-gad373c5+3,19.0.0-5-ga2acb9c+2,19.0.0-5-gfe96e6c+2,w.2020.01
LSSTDataManagementBasePackage
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
std::size_t hash_value() const noexcept
Return a hash of this object.
Definition: Color.h:57
Color & operator=(Color const &)=default
STL namespace.
size_t operator()(argument_type const &obj) const noexcept
Definition: Color.h:78
bool isIndeterminate() const noexcept
Whether the color is the special value that indicates that it is unspecified.
Definition: Color.h:37
ItemVariant const * other
Definition: Schema.cc:56
bool operator!=(Color const &other) const noexcept
Equality comparison for colors.
Definition: Color.h:53
A base class for image defects.
bool operator==(Color const &other) const noexcept
Equality comparison for colors.
Definition: Color.h:50
Color(double g_r=std::numeric_limits< double >::quiet_NaN())
Definition: Color.h:28
double getLambdaEff(Filter const &) const
Return the effective wavelength for this object in the given filter.
Definition: Color.h:61
Holds an integer identifier for an LSST filter.
Definition: Filter.h:141
T isnan(T... args)
~Color() noexcept=default
Describe the colour of a source.
Definition: Color.h:26
Backwards-compatibility support for depersisting the old Calib (FluxMag0/FluxMag0Err) objects...