SourceXtractorPlusPlus  0.13
Please provide a description of the project.
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 <type_traits>
28 #include <vector>
29 #include <stdint.h>
30 
31 namespace SourceXtractor {
32 
34 enum class Flags : int64_t {
35  NONE = 0,
36  BIASED = 1ll << 0,
37  BLENDED = 1ll << 1,
38  SATURATED = 1ll << 2,
39  BOUNDARY = 1ll << 3,
40  NEIGHBORS = 1ll << 4,
41  OUTSIDE = 1ll << 5,
42  PARTIAL_FIT = 1ll << 6,
43  INSUFFICIENT_DATA = 1ll << 7,
44  ERROR = 1ll << 10,
45 };
46 
47 
48 constexpr inline Flags operator|(const Flags &a, const Flags &b) {
49  typedef typename std::underlying_type<Flags>::type base_int_t;
50  return static_cast<Flags>(static_cast<base_int_t>(a) | static_cast<base_int_t>(b));
51 }
52 
53 constexpr inline Flags operator&(const Flags &a, const Flags &b) {
54  typedef typename std::underlying_type<Flags>::type base_int_t;
55  return static_cast<Flags>(static_cast<base_int_t>(a) & static_cast<base_int_t>(b));
56 }
57 
58 constexpr Flags operator*(const Flags &a, const bool b) {
59  return b ? a : Flags::NONE;
60 }
61 
62 inline Flags &operator|=(Flags &a, const Flags &b) {
63  a = a | b;
64  return a;
65 }
66 
67 constexpr inline int64_t flags2long(const Flags &a) {
68  return static_cast<int64_t>(a);
69 }
70 
73  for (auto a : v) {
74  vl.emplace_back(flags2long(a));
75  }
76  return vl;
77 }
78 
79 } // end SourceXtractor
80 
81 #endif // _SEFRAMEWORK_SOURCE_SOURCEFLAGS_H_
std::vector
STL class.
SourceXtractor::Flags
Flags
Flagging of bad sources.
Definition: SourceFlags.h:34
std::underlying_type
SourceXtractor
Definition: Aperture.h:30
SourceXtractor::operator|=
Flags & operator|=(Flags &a, const Flags &b)
Definition: SourceFlags.h:62
SourceXtractor::operator*
constexpr Flags operator*(const Flags &a, const bool b)
Definition: SourceFlags.h:58
std::int64_t
SourceXtractor::Flags::NONE
@ NONE
No flag is set.
std::vector::emplace_back
T emplace_back(T... args)
SourceXtractor::flags2long
constexpr int64_t flags2long(const Flags &a)
Definition: SourceFlags.h:67
SourceXtractor::operator&
constexpr Flags operator&(const Flags &a, const Flags &b)
Definition: SourceFlags.h:53
SourceXtractor::operator|
constexpr Flags operator|(const Flags &a, const Flags &b)
Definition: SourceFlags.h:48