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::vector
STL class.
SourceXtractor::Flags::ERROR
@ ERROR
Error flag: something bad happened during the measurement, model fitting, etc.
SourceXtractor::Flags
Flags
Flagging of bad sources.
Definition:
SourceFlags.h:37
std::underlying_type
SourceXtractor
Definition:
Aperture.h:30
std::ostream
STL class.
SourceXtractor::operator|=
Flags & operator|=(Flags &a, const Flags &b)
Definition:
SourceFlags.h:79
SourceXtractor::operator*
constexpr Flags operator*(const Flags &a, const bool b)
Definition:
SourceFlags.h:75
std::int64_t
std::map
STL class.
SourceXtractor::Flags::NONE
@ NONE
No flag is set.
std::vector::emplace_back
T emplace_back(T... args)
SourceXtractor::FlagsStr
const std::map< Flags, std::string > FlagsStr
String representation of the flags.
Definition:
SourceFlags.h:52
SourceXtractor::operator<<
std::ostream & operator<<(std::ostream &out, const TileKey &tk)
Definition:
TileManager.h:51
SourceXtractor::flags2long
constexpr int64_t flags2long(const Flags &a)
Definition:
SourceFlags.h:84
SourceXtractor::operator&
constexpr Flags operator&(const Flags &a, const Flags &b)
Definition:
SourceFlags.h:70
SourceXtractor::operator|
constexpr Flags operator|(const Flags &a, const Flags &b)
Definition:
SourceFlags.h:65
Generated by
1.8.20