PandaRoot
PndParameterRegister.h
Go to the documentation of this file.
1 #ifndef PNDPARAMETERREGISTER_HH
2 #define PNDPARAMETERREGISTER_HH
3 
4 #include <algorithm>
5 #include <map>
6 #include <string>
7 #include <vector>
8 
9 #include "FairLogger.h"
10 #include "FairParGenericSet.h"
11 #include "FairParSet.h"
12 
19  public:
25  void AddRequest(const std::string &t_request)
26  {
27  if (std::find(std::begin(fRequests), std::end(fRequests), t_request) == std::end(fRequests)) {
28  fRequests.push_back(t_request);
29  }
30  }
31 
37  void AddRequestList(const std::vector<std::string> &t_requests)
38  {
39  for (const std::string &request : t_requests) {
40  AddRequest(request);
41  }
42  }
43 
50  FairParSet *GetParameter(const std::string &t_name) const
51  {
52  if (fRegister.find(t_name) != fRegister.end()) {
53  return fRegister.at(t_name);
54  }
55  return nullptr;
56  }
57 
64  void SetParameter(const std::string &t_name, FairParSet *t_parameter)
65  {
66  if (fRegister.find(t_name) != fRegister.end()) {
67  return;
68  } else {
69  fRegister[t_name] = t_parameter;
70  }
71  }
72 
78  const std::vector<std::string> &GetRequestList() const { return fRequests; }
79 
80  private:
81  std::vector<std::string> fRequests{};
82  std::map<std::string, FairParSet *> fRegister{};
83 };
84 
85 #endif /*PNDPARAMETERREGISTER_HH*/
FairParSet * GetParameter(const std::string &t_name) const
Access the parameter via the name.
void SetParameter(const std::string &t_name, FairParSet *t_parameter)
Set the parameter pointer t_parameter for the parameter t_name.
void AddRequestList(const std::vector< std::string > &t_requests)
Add a list of parameter names to the list of requested parameters.
const std::vector< std::string > & GetRequestList() const
Get the list of requested parameter names.
Helper class to indirect the Parameter fetching via the FairRuntimeDb.
void AddRequest(const std::string &t_request)
Add a parameter name to the list of requested parameters.