 |
Belle II Software
release-05-01-25
|
12 #include <tracking/trackFindingCDC/varsets/NamedFloatTuple.h>
22 namespace TrackFindingCDC {
32 bool strequal(
char const* s1,
char const* s2)
34 return (not * s1 and not * s2) or (*s1 and * s2 and * s1 == *s2 and strequal(s1 + 1, s2 + 1));
47 template <
size_t nVars>
48 constexpr
int index(
const char*
const(&names)[nVars],
const char* name,
size_t iName = 0)
50 return ((nVars == iName) ?
52 strequal(names[iName], name) ? iName : index(names, name, iName + 1));
65 template<
size_t nVars>
67 int index(
const char* (
getName(
int)),
68 const char*
const name,
69 const size_t iName = 0)
71 return ((nVars == iName) ?
73 strequal(
getName(iName), name) ? iName : index<nVars>(getName, name, iName + 1));
84 template <
class T,
size_t N>
85 constexpr
size_t size(T (&array)[N] __attribute__((unused)))
99 template<
class ANames>
100 class FixedSizeNamedFloatTuple :
public NamedFloatTuple {
104 static const size_t nVars = ANames::nVars;
117 constexpr
static int named(
const char* name)
119 return index<nVars>(ANames::getName, name);
124 size_t size() const final
126 return ANames::nVars;
143 std::string
getName(
int iValue)
const final
147 return ANames::getName(iValue);
153 void set(Float_t value)
155 static_assert(
nVars != I,
"Requested name not found in names.");
156 assert(I < (
int)
nVars);
162 void set(
int iValue, Float_t value)
final {
163 assert(iValue < (
int)
nVars);
169 void set(
const char* name, Float_t value)
178 static_assert(
nVars != I,
"Requested name not found in names.");
179 assert(I < (
int)
nVars);
185 Float_t
get(
int iValue)
const final
187 assert(iValue < (
int)
nVars);
193 Float_t
get(
const char* name)
const
202 static_assert(
nVars != I,
"Requested name not found in names.");
203 assert(I < (
int)
nVars);
210 assert(iValue < (
int)
nVars);
TString getName(const TObject *obj)
human-readable name (e.g.
Float_t get() const
Getter for the ith value. Static index version.
std::string getName(int iValue) const final
Getter for the ith name.
void set(Float_t value)
Setter for the ith values. Static index version.
Float_t get(int iValue) const final
Getter for the ith value.
Float_t & operator[](int iValue) final
Reference getter for the ith value.
static const size_t nVars
Number of floating point values represented by this class.
Abstract base class for different kinds of events.
Float_t & var()
Reference getter for the ith value. Static index version.
size_t size() const final
Getter for number of floating point values represented by this class.
int getNameIndex(const char *name) const final
Getter for the index from a name.
Float_t m_values[nVars]
Memory for nVars floating point values.
constexpr static int named(const char *name)
Static getter for the index from the name.