SourceXtractorPlusPlus  0.15
Please provide a description of the project.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 
34 namespace SourceXtractor {
35 
37 enum 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  SENTINEL = 1ll << 11,
49 };
50 
53  {Flags::NONE, "NONE"},
54  {Flags::BIASED, "BIASED"},
55  {Flags::BLENDED, "BLENDED"},
56  {Flags::BOUNDARY, "BOUNDARY"},
57  {Flags::NEIGHBORS, "NEIGHBORS"},
58  {Flags::OUTSIDE, "OUTSIDE"},
59  {Flags::PARTIAL_FIT, "PARTIAL_FIT"},
60  {Flags::INSUFFICIENT_DATA, "INSUFFICIENT_DATA"},
61  {Flags::ERROR, "ERROR"}
62 };
63 
64 
65 constexpr inline Flags operator|(const Flags &a, const Flags &b) {
66  typedef typename std::underlying_type<Flags>::type base_int_t;
67  return static_cast<Flags>(static_cast<base_int_t>(a) | static_cast<base_int_t>(b));
68 }
69 
70 constexpr inline Flags operator&(const Flags &a, const Flags &b) {
71  typedef typename std::underlying_type<Flags>::type base_int_t;
72  return static_cast<Flags>(static_cast<base_int_t>(a) & static_cast<base_int_t>(b));
73 }
74 
75 constexpr Flags operator*(const Flags &a, const bool b) {
76  return b ? a : Flags::NONE;
77 }
78 
79 inline Flags &operator|=(Flags &a, const Flags &b) {
80  a = a | b;
81  return a;
82 }
83 
84 constexpr inline int64_t flags2long(const Flags &a) {
85  return static_cast<int64_t>(a);
86 }
87 
90  for (auto a : v) {
91  vl.emplace_back(flags2long(a));
92  }
93  return vl;
94 }
95 
96 inline std::ostream& operator<<(std::ostream& out, Flags flags) {
98  bool some_printed = false;
99  for (i = static_cast<decltype(i)>(Flags::BIASED);
100  i < static_cast<decltype(i)>(Flags::SENTINEL); i <<= 1) {
101  if ((flags & static_cast<Flags>(i)) != Flags::NONE) {
102  if (some_printed)
103  out << " | ";
104  else
105  out << "(";
106  out << FlagsStr.at(static_cast<Flags>(i));
107  some_printed = true;
108  }
109  }
110  if (some_printed)
111  out << ")";
112  else
113  out << "NONE";
114  return out;
115 }
116 
117 } // end SourceXtractor
118 
119 #endif // _SEFRAMEWORK_SOURCE_SOURCEFLAGS_H_
The object has neighbors, bright and close enough.
constexpr int64_t flags2long(const Flags &a)
Definition: SourceFlags.h:84
The object is completely outside of the measurement frame.
constexpr Flags operator|(const Flags &a, const Flags &b)
Definition: SourceFlags.h:65
Used to find the boundary of possible values.
STL class.
const std::map< Flags, std::string > FlagsStr
String representation of the flags.
Definition: SourceFlags.h:52
The object is truncated (too close to an image boundary)
constexpr Flags operator&(const Flags &a, const Flags &b)
Definition: SourceFlags.h:70
The object has bad pixels.
std::ostream & operator<<(std::ostream &out, const TileKey &tk)
Definition: TileManager.h:51
STL class.
There are not enough good pixels to fit the parameters.
constexpr Flags operator*(const Flags &a, const bool b)
Definition: SourceFlags.h:75
At least one pixel of the object is saturated.
Some/all of the model parameters could not be fitted.
Flags
Flagging of bad sources.
Definition: SourceFlags.h:37
Flags & operator|=(Flags &a, const Flags &b)
Definition: SourceFlags.h:79
The object was originally blended with another one.
STL class.
Error flag: something bad happened during the measurement, model fitting, etc.
T emplace_back(T...args)