Belle II Software  release-08-01-10
VariadicUnionVarSet.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 <tracking/trackFindingCDC/varsets/BaseVarSet.h>
11 #include <tracking/trackFindingCDC/varsets/UnionVarSet.h>
12 
13 #include <tracking/trackFindingCDC/utilities/EvalVariadic.h>
14 #include <tracking/trackFindingCDC/utilities/Named.h>
15 #include <tracking/trackFindingCDC/utilities/MayBePtr.h>
16 
17 #include <cassert>
18 #include <memory>
19 #include <string>
20 #include <vector>
21 
22 namespace Belle2 {
27  namespace TrackFindingCDC {
28 
36  template <class... AVarSets>
37  class VariadicUnionVarSet : public BaseVarSet<typename FirstType<AVarSets...>::Object> {
38 
39  private:
41  using Super = BaseVarSet<typename FirstType<AVarSets...>::Object>;
42 
43  public:
45  using Object = typename Super::Object;
46 
47  private:
50 
51  public:
54  {
55  EvalVariadic{(m_multiVarSet.push_back(std::make_unique<AVarSets>()), std::ignore)...};
56  assert(m_multiVarSet.size() == sizeof...(AVarSets));
57  }
58 
59  public:
60  using Super::extract;
61 
63  void initialize() final
64  {
67  }
68 
73  bool extract(const Object* obj) final
74  {
75  return m_multiVarSet.extract(obj);
76  }
77 
78  // Importing name from the base class.
80 
85  std::vector<Named<Float_t*>> getNamedVariables(const std::string& prefix) override
86  {
87  return m_multiVarSet.getNamedVariables(prefix);
88  }
89 
94  MayBePtr<Float_t> find(const std::string& varName) override
95  {
96  return m_multiVarSet.find(varName);
97  }
98 
99  private:
102  };
103  }
105 }
Generic class that generates some named float values from a given object.
Definition: BaseVarSet.h:33
AObject Object
Object type from which variables shall be extracted.
Definition: BaseVarSet.h:37
virtual bool extract(const Object *obj)
Main method that extracts the variable values from the complex object.
Definition: BaseVarSet.h:50
std::vector< Named< Float_t * > > getNamedVariables()
Getter for the named references to the individual variables.
Definition: BaseVarSet.h:73
void initialize() override
Receive and dispatch signal before the start of the event processing.
void addProcessingSignalListener(ProcessingSignalListener *psl)
Register a processing signal listener to be notified.
Interface for an algorithm part that needs to receive the module processing signals.
MayBePtr< Float_t > find(const std::string &varName) override
Pointer to the variable with the given name.
Definition: UnionVarSet.h:85
size_t size() const
Return the number of currently contained variable sets.
Definition: UnionVarSet.h:109
bool extract(const Object *obj) final
Main method that extracts the variable values from the complex object.
Definition: UnionVarSet.h:58
void push_back(std::unique_ptr< ContainedVarSet > varSet)
Add a variable set to the contained variable sets.
Definition: UnionVarSet.h:95
std::vector< Named< Float_t * > > getNamedVariables(const std::string &prefix) override
Getter for the named references to the individual variables Base implementaton returns empty vector.
Definition: UnionVarSet.h:71
Class that accomodates many variable sets and presents them as on set of variables.
MayBePtr< Float_t > find(const std::string &varName) override
Pointer to the variable with the given name.
typename Super::Object Object
Object type from which variables shall be extracted.
void initialize() final
Initialize all contained variable set before event processing.
bool extract(const Object *obj) final
Main method that extracts the variable values from the complex object.
VariadicUnionVarSet()
Create the union variable set.
std::vector< Named< Float_t * > > getNamedVariables(const std::string &prefix) override
Getter for the named references to the individual variables Base implementaton returns empty vector.
UnionVarSet< Object > m_multiVarSet
Container for the multiple variable sets.
Abstract base class for different kinds of events.
Structure to serve as a placeholder for a variadic initializer list of statements to be evaluated.
Definition: EvalVariadic.h:37