SourceXtractorPlusPlus
0.15
Please provide a description of the project.
SEFramework
SEFramework
Source
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
52
const
std::map<Flags, std::string>
FlagsStr
= {
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
88
inline
std::vector<int64_t>
flags2long
(
const
std::vector<Flags>
&v) {
89
std::vector<int64_t>
vl;
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) {
97
std::underlying_type<Flags>::type
i;
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_
std::ostream
std::vector::emplace_back
T emplace_back(T... args)
std::int64_t
std::map
SourceXtractor
Definition:
Aperture.h:30
SourceXtractor::Flags
Flags
Flagging of bad sources.
Definition:
SourceFlags.h:37
SourceXtractor::Flags::NEIGHBORS
@ NEIGHBORS
The object has neighbors, bright and close enough.
SourceXtractor::Flags::BLENDED
@ BLENDED
The object was originally blended with another one.
SourceXtractor::Flags::SATURATED
@ SATURATED
At least one pixel of the object is saturated.
SourceXtractor::Flags::OUTSIDE
@ OUTSIDE
The object is completely outside of the measurement frame.
SourceXtractor::Flags::BOUNDARY
@ BOUNDARY
The object is truncated (too close to an image boundary)
SourceXtractor::Flags::NONE
@ NONE
No flag is set.
SourceXtractor::Flags::ERROR
@ ERROR
Error flag: something bad happened during the measurement, model fitting, etc.
SourceXtractor::Flags::SENTINEL
@ SENTINEL
Used to find the boundary of possible values.
SourceXtractor::Flags::BIASED
@ BIASED
The object has bad pixels.
SourceXtractor::Flags::INSUFFICIENT_DATA
@ INSUFFICIENT_DATA
There are not enough good pixels to fit the parameters.
SourceXtractor::Flags::PARTIAL_FIT
@ PARTIAL_FIT
Some/all of the model parameters could not be fitted.
SourceXtractor::operator|
constexpr Flags operator|(const Flags &a, const Flags &b)
Definition:
SourceFlags.h:65
SourceXtractor::operator|=
Flags & operator|=(Flags &a, const Flags &b)
Definition:
SourceFlags.h:79
SourceXtractor::flags2long
constexpr int64_t flags2long(const Flags &a)
Definition:
SourceFlags.h:84
SourceXtractor::FlagsStr
const std::map< Flags, std::string > FlagsStr
String representation of the flags.
Definition:
SourceFlags.h:52
SourceXtractor::operator*
constexpr Flags operator*(const Flags &a, const bool b)
Definition:
SourceFlags.h:75
SourceXtractor::operator<<
std::ostream & operator<<(std::ostream &out, const TileKey &tk)
Definition:
TileManager.h:51
SourceXtractor::operator&
constexpr Flags operator&(const Flags &a, const Flags &b)
Definition:
SourceFlags.h:70
std::underlying_type
std::vector
Generated by
1.9.1