FDsimG4XMLManager.hh
Go to the documentation of this file.
1 #ifndef _TelescopeSimulatorLX_XMLManager_h_
2 #define _TelescopeSimulatorLX_XMLManager_h_
3 
4 #include <string>
5 #include <utl/Branch.h>
6 #include <utl/ErrorLogger.h>
7 #include <utl/AugerException.h>
8 #include <utl/Reader.h>
9 #include <utl/TabulatedFunction.h>
10 
11 namespace utl {
12  class Reader;
13  class Branch;
14  class TabulatedFunction;
15 }
16 
17 
18 namespace TelescopeSimulatorLX {
19 
37 
38  public:
40 
41  FDsimG4XMLManager(const std::string& name)
42  : fIsInitialized(false), fReportingErrors(false), fName(name) { }
43 
44 
45  virtual ~FDsimG4XMLManager() { }
46 
47  void Init(const std::string& configLink);
48  bool IsInitialized() const { return fIsInitialized; }
49 
50  enum Status {
51  eFound=1,
53  };
54 
56 
67  public:
68 
69 
70 // // Implement generic getters with template
71 
72  template<typename T>
73  Status GetData(T& returnData,
74  const std::string& componentProperty,
75  const std::string& componentName) const;
76 
77 // // Tabulated data has a special getter to do the tabulation
78 
80  const std::string& componentProperty,
81  const std::string& componentName) const;
82 
83  // Find Branch where the requested data resides
84  utl::Branch FindBranch(const std::string& property,
85  const std::string& component) const;
86 
87  protected:
89  void FindConfig(const std::string& configLink);
90 
91  bool IsReportingErrors() const { return fReportingErrors; }
92 
93  // Flag the Manager as initialized. (It is initialized if
94  // it successfully found its data source.)
96 
98 
99  // Configuration file reader
100  // do not delete in dtor
102 
103 
104  private:
105  std::string fName;
106 
107  };
108 
109  // Function definition in header file to avoid "undefined reference errors". Vide ManagerRegister.h
110  template<typename T>
113  const std::string& componentProperty,
114  const std::string& componentName)
115  const
116  {
117  // Find where requested data resides in DOM
118  utl::Branch dataBranch =
119  FindBranch(componentProperty, componentName);
120 
121  if (!dataBranch)
122  return eNotFound;
123 
124  // Extract data from the branch
125  dataBranch.GetData(returnData);
126 
127  // Found the data. To be returned as type T
128  return eFound;
129  }
130 
131 }
132 
133 
134 #endif // _TelescopeSimulatorLX_XMLManager_h_
135 
136 
137 // Configure (x)emacs for this file ...
138 // Local Variables:
139 // mode: c++
140 // compile-command: "make -C .. FDetector/FDsimG4XMLManager.o -k"
141 // End:
Class to hold collection (x,y) points and provide interpolation between them.
Class representing a document branch.
Definition: Branch.h:107
Status GetData(T &returnData, const std::string &componentProperty, const std::string &componentName) const
Return data as a TabulatedFunction.
void GetData(bool &b) const
Overloads of the GetData member template function.
Definition: Branch.cc:644
Manager for specific FD description parameters in XML file.
utl::Branch FindBranch(const std::string &property, const std::string &component) const
void FindConfig(const std::string &configLink)
Locate the configuration file in CentralConfig and make a Reader for it.
void Init(const std::string &configLink)
FDsimG4XMLManager(const std::string &name)

, generated on Tue Sep 26 2023.