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
26 (FlagIndex_t flagIndex) const
27 { return flagIndex < This_t::size(); }
29 //------------------------------------------------------------------------------
30 template <unsigned int NFlags, typename Storage>
31 constexpr bool util::flags::FlagSet<NFlags, Storage>::isFlag(Flag_t flag) const
32 { return isFlag(flag.index()); }
34 //------------------------------------------------------------------------------
35 template <unsigned int NFlags, typename Storage>
36 bool util::flags::FlagSet<NFlags, Storage>::test(FlagIndex_t index) const {
39 ("Invalid flag index was tested: #" + std::to_string(index));
41 return This_t::testImpl(index);
42 } // util::flags::FlagSet<>::test()
44 //------------------------------------------------------------------------------
45 template <unsigned int NFlags, typename Storage>
46 bool util::flags::FlagSet<NFlags, Storage>::test(Flag_t flag) const {
49 ("Invalid flag was tested: #" + util::flags::to_string(flag));
51 return testImpl(flag);
52 } // util::flags::FlagSet<>::test()
55 //------------------------------------------------------------------------------
56 template <unsigned int NFlags, typename Storage>
57 bool util::flags::FlagSet<NFlags, Storage>::testImpl(Flag_t flag) const {
58 if (!This_t::isDefined(flag)) {
59 throw FlagNotDefinedError
60 ("Undefined flag was tested: #" + util::flags::to_string(flag));
62 return This_t::get(flag);
63 } // util::flags::FlagSet<>::testImpl()
65 //------------------------------------------------------------------------------
68 #endif // LARDATAOBJ_UTILITIES_FLAGSET_TCC