3 * @brief Class holding flags.
4 * @author Gianluca Petrillo (petrillo@fnal.gov)
5 * @date January 25, 2017
10 #ifndef LARDATAOBJ_UTILITIES_FLAGSET_TCC
11 #define LARDATAOBJ_UTILITIES_FLAGSET_TCC
13 #ifndef LARDATAOBJ_UTILITIES_FLAGSET_H
14 #error "Do not include FlagSet.tcc directly: include FlagSet.h instead."
15 #endif // !LARDATAOBJ_UTILITIES_FLAGSET_H
19 //------------------------------------------------------------------------------
23 //------------------------------------------------------------------------------
24 template <unsigned int NFlags, typename Storage>
25 constexpr bool util::flags::FlagSet<NFlags, Storage>::isFlag(FlagIndex_t flagIndex) const
27 return flagIndex < This_t::size();
30 //------------------------------------------------------------------------------
31 template <unsigned int NFlags, typename Storage>
32 constexpr bool util::flags::FlagSet<NFlags, Storage>::isFlag(Flag_t flag) const
34 return isFlag(flag.index());
37 //------------------------------------------------------------------------------
38 template <unsigned int NFlags, typename Storage>
39 bool util::flags::FlagSet<NFlags, Storage>::test(FlagIndex_t index) const
42 throw OutOfRangeError("Invalid flag index was tested: #" + std::to_string(index));
44 return This_t::testImpl(index);
45 } // util::flags::FlagSet<>::test()
47 //------------------------------------------------------------------------------
48 template <unsigned int NFlags, typename Storage>
49 bool util::flags::FlagSet<NFlags, Storage>::test(Flag_t flag) const
52 throw OutOfRangeError("Invalid flag was tested: #" + util::flags::to_string(flag));
54 return testImpl(flag);
55 } // util::flags::FlagSet<>::test()
57 //------------------------------------------------------------------------------
58 template <unsigned int NFlags, typename Storage>
59 bool util::flags::FlagSet<NFlags, Storage>::testImpl(Flag_t flag) const
61 if (!This_t::isDefined(flag)) {
62 throw FlagNotDefinedError("Undefined flag was tested: #" + util::flags::to_string(flag));
64 return This_t::get(flag);
65 } // util::flags::FlagSet<>::testImpl()
67 //------------------------------------------------------------------------------
69 #endif // LARDATAOBJ_UTILITIES_FLAGSET_TCC