Belle II Software development
NamedFloatTuple.h
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8#pragma once
9
10#include <RtypesCore.h>
11
12#include <tracking/trackFindingCDC/utilities/Named.h>
13#include <tracking/trackFindingCDC/utilities/MayBePtr.h>
14
15#include <vector>
16#include <map>
17#include <string>
18
19namespace Belle2 {
24 namespace TrackFindingCDC {
25
28
29 public:
32
34 virtual size_t size() const = 0;
35
44 virtual int getNameIndex(const char* name) const = 0;
45
47 virtual std::string getName(int iValue) const = 0;
48
50 virtual void set(int iValue, Float_t value) = 0;
51
53 void set(const char* const name, Float_t value)
54 {
55 set(getNameIndex(name), value);
56 }
57
59 virtual Float_t get(int iValue) const = 0;
60
62 Float_t get(const char* const name) const
63 {
64 return get(getNameIndex(name));
65 }
66
71 virtual MayBePtr<Float_t> find(std::string name)
72 {
73 size_t nameindex = getNameIndex(name.c_str());
74 return (nameindex < size()) ? &(operator[](nameindex)) : nullptr;
75 }
76
78 virtual Float_t& operator[](int iValue) = 0;
79
81 Float_t& operator[](const char* const name)
82 {
83 return operator[](getNameIndex(name));
84 }
85
87 std::map<std::string, Float_t> getNamedValues(std::string prefix = "") const;
88
90 std::vector<Named<Float_t*>> getNamedVariables(std::string prefix = "");
91 };
92 }
94}
An abstract tuple of float value where each value has an associated name.
virtual int getNameIndex(const char *name) const =0
Getter for the index from a name.
Float_t & operator[](const char *const name)
Reference getter for the value with the given name.
Float_t get(const char *const name) const
Getter for the value with the given name.
std::vector< Named< Float_t * > > getNamedVariables(std::string prefix="")
Getter for named references to the variables in this tuple.
virtual MayBePtr< Float_t > find(std::string name)
Getter for a pointer to the value with the given name.
virtual Float_t get(int iValue) const =0
Getter for the value of the ith part.
void set(const char *const name, Float_t value)
Setter for the value with the given name.
virtual Float_t & operator[](int iValue)=0
Reference getter for the value of the ith part.
virtual void set(int iValue, Float_t value)=0
Setter for the value of the ith part.
virtual size_t size() const =0
Getter for the number of parts.
virtual std::string getName(int iValue) const =0
Getter for the ith name.
virtual ~NamedFloatTuple()
Marking the destructor virtual since we are using virtual functions.
std::map< std::string, Float_t > getNamedValues(std::string prefix="") const
Getter for a map of all name and value pairs in this tuple.
Abstract base class for different kinds of events.