SourceXtractorPlusPlus 0.21
SourceXtractor++, the next generation SExtractor
Loading...
Searching...
No Matches
SourceFlags.h
Go to the documentation of this file.
1
17/*
18 * SourceFlags.h
19 *
20 * Created on: Oct 19, 2018
21 * Author: Alejandro Alvarez Ayllon
22 */
23
24#ifndef _SEFRAMEWORK_SOURCE_SOURCEFLAGS_H_
25#define _SEFRAMEWORK_SOURCE_SOURCEFLAGS_H_
26
27#include <stdint.h>
28#include <iostream>
29#include <map>
30#include <string>
31#include <vector>
32#include <type_traits>
33
34namespace SourceXtractor {
35
37enum class Flags : int64_t {
38 NONE = 0,
39 BIASED = 1ll << 0,
40 BLENDED = 1ll << 1,
41 SATURATED = 1ll << 2,
42 BOUNDARY = 1ll << 3,
43 NEIGHBORS = 1ll << 4,
44 OUTSIDE = 1ll << 5,
45 PARTIAL_FIT = 1ll << 6,
46 INSUFFICIENT_DATA = 1ll << 7,
47 ERROR = 1ll << 10,
48 MEMORY = 1ll << 11,
49 BAD_PROJECTION = 1ll << 12,
50 DOWNSAMPLED = 1ll << 13,
51 SENTINEL = 1ll << 14,
52};
53
56 {Flags::NONE, "NONE"},
57 {Flags::BIASED, "BIASED"},
58 {Flags::BLENDED, "BLENDED"},
59 {Flags::BOUNDARY, "BOUNDARY"},
60 {Flags::NEIGHBORS, "NEIGHBORS"},
61 {Flags::OUTSIDE, "OUTSIDE"},
62 {Flags::PARTIAL_FIT, "PARTIAL_FIT"},
63 {Flags::INSUFFICIENT_DATA, "INSUFFICIENT_DATA"},
64 {Flags::ERROR, "ERROR"},
65 {Flags::MEMORY, "MEMORY"},
66 {Flags::BAD_PROJECTION, "BAD_PROJECTION"},
67 {Flags::DOWNSAMPLED, "DOWNSAMPLED"}
68};
69
70
71constexpr inline Flags operator|(const Flags &a, const Flags &b) {
73 return static_cast<Flags>(static_cast<base_int_t>(a) | static_cast<base_int_t>(b));
74}
75
76constexpr inline Flags operator&(const Flags &a, const Flags &b) {
78 return static_cast<Flags>(static_cast<base_int_t>(a) & static_cast<base_int_t>(b));
79}
80
81constexpr Flags operator*(const Flags &a, const bool b) {
82 return b ? a : Flags::NONE;
83}
84
85inline Flags &operator|=(Flags &a, const Flags &b) {
86 a = a | b;
87 return a;
88}
89
90constexpr inline int64_t flags2long(const Flags &a) {
91 return static_cast<int64_t>(a);
92}
93
96 for (auto a : v) {
97 vl.emplace_back(flags2long(a));
98 }
99 return vl;
100}
101
104 bool some_printed = false;
105 for (i = static_cast<decltype(i)>(Flags::BIASED);
107 if ((flags & static_cast<Flags>(i)) != Flags::NONE) {
108 if (some_printed)
109 out << " | ";
110 else
111 out << "(";
112 out << FlagsStr.at(static_cast<Flags>(i));
113 some_printed = true;
114 }
115 }
116 if (some_printed)
117 out << ")";
118 else
119 out << "NONE";
120 return out;
121}
122
123} // end SourceXtractor
124
125#endif // _SEFRAMEWORK_SOURCE_SOURCEFLAGS_H_
std::ostream & operator<<(std::ostream &s, const cell_stream_adaptor &cell)
Flags
Flagging of bad sources.
Definition SourceFlags.h:37
@ NEIGHBORS
The object has neighbors, bright and close enough.
@ DOWNSAMPLED
The fit was done on a downsampled image due to exceeding max size.
@ BLENDED
The object was originally blended with another one.
@ SATURATED
At least one pixel of the object is saturated.
@ MEMORY
Failed to allocate an object, buffer, etc.
@ OUTSIDE
The object is completely outside of the measurement frame.
@ BAD_PROJECTION
Failed to project some of the coordinates into one of the measurement frames.
@ BOUNDARY
The object is truncated (too close to an image boundary)
@ NONE
No flag is set.
@ ERROR
Error flag: something bad happened during the measurement, model fitting, etc.
@ SENTINEL
Used to find the boundary of possible values.
@ BIASED
The object has bad pixels.
@ INSUFFICIENT_DATA
There are not enough good pixels to fit the parameters.
@ PARTIAL_FIT
Some/all of the model parameters could not be fitted.
constexpr Flags operator|(const Flags &a, const Flags &b)
Definition SourceFlags.h:71
constexpr int64_t flags2long(const Flags &a)
Definition SourceFlags.h:90
Flags & operator|=(Flags &a, const Flags &b)
Definition SourceFlags.h:85
const std::map< Flags, std::string > FlagsStr
String representation of the flags.
Definition SourceFlags.h:55
constexpr Flags operator*(const Flags &a, const bool b)
Definition SourceFlags.h:81
constexpr Flags operator&(const Flags &a, const Flags &b)
Definition SourceFlags.h:76