25 #include "boost/functional/hash.hpp" 28 namespace lsst {
namespace afw {
namespace image {
namespace detail {
43 _allMaskDicts.insert(dict);
46 return _defaultMaskDict;
52 _allMaskDicts.insert(result);
57 return _defaultMaskDict;
66 _defaultMaskDict =
copy(*_defaultMaskDict);
67 return _defaultMaskDict;
70 template <
typename Functor>
74 for (
auto const &
ptr : _allMaskDicts) {
82 _allMaskDicts.insert(_defaultMaskDict);
83 _defaultMaskDict->_addInitialMaskPlanes();
97 for (
auto iter = _allMaskDicts.begin(); iter != _allMaskDicts.end(); ) {
98 if (iter->expired()) {
99 iter = _allMaskDicts.erase(iter);
132 [bitId](
auto const & item) {
return item.second == bitId; }
134 if (found == dict.
end()) {
136 if (dict.
find(name) == dict.
end()) {
137 dict.
add(name, bitId);
157 [](
auto const &
a,
auto const &
b) {
return a.second <
b.second; }
159 assert(maxIter !=
end());
160 int id = maxIter->second + 1;
162 for (
int i = 0; i <
id; ++i) {
166 [i](
auto const & item) {
return item.second == i; }
168 if (sameIter ==
end()) {
177 auto iter =
find(name);
178 return (iter ==
end()) ? -1 : iter->second;
182 for (
auto const & item : *
this) {
188 return this == &rhs || (_hash == rhs._hash && _dict == rhs._dict);
193 _hash = boost::hash<MaskPlaneDict>()(_dict);
198 _hash = boost::hash<MaskPlaneDict>()(_dict);
206 void MaskDict::_addInitialMaskPlanes() {
210 _dict[
"INTRP"] = ++i;
213 _dict[
"DETECTED"] = ++i;
214 _dict[
"DETECTED_NEGATIVE"] = ++i;
215 _dict[
"SUSPECT"] = ++i;
216 _dict[
"NO_DATA"] = ++i;
217 _hash = boost::hash<MaskPlaneDict>()(_dict);
220 MaskDict::MaskDict() : _dict(), _hash(0x0) {}
222 MaskDict::MaskDict(
MaskPlaneDict const & dict) : _dict(dict), _hash(boost::hash<MaskPlaneDict>()(_dict)) {}
static std::shared_ptr< MaskDict > getDefault()
void add(std::string const &name, int bitId)
std::shared_ptr< MaskDict > copyOrGetDefault(MaskPlaneDict const &mpd)
static void setDefault(std::shared_ptr< MaskDict > dict)
static GlobalState & get()
static std::shared_ptr< MaskDict > detachDefault()
int getMaskPlane(std::string const &name) const
int getUnusedPlane() const
static void addAllMasksPlane(std::string const &name, int bitId)
void setDefault(std::shared_ptr< MaskDict > dict)
std::shared_ptr< MaskDict > getDefault() const noexcept
const_iterator begin() const noexcept
void erase(std::string const &name)
void forEachMaskDict(Functor functor)
const_iterator end() const noexcept
A base class for image defects.
const_iterator find(std::string const &name) const
bool empty() const noexcept
static std::shared_ptr< MaskDict > copyOrGetDefault(MaskPlaneDict const &dict)
std::shared_ptr< MaskDict > clone() const
std::shared_ptr< MaskDict > copy(MaskDict const &dict)
bool operator==(MaskDict const &rhs) const
Backwards-compatibility support for depersisting the old Calib (FluxMag0/FluxMag0Err) objects...
std::shared_ptr< MaskDict > detachDefault()