RSimulationStationListManager.h
Go to the documentation of this file.
1 #ifndef _rdet_RSimulationStationListManager_h_
2 #define _rdet_RSimulationStationListManager_h_
3 
4 #include <utl/ErrorLogger.h>
5 #include <utl/config.h>
6 
7 #include <det/VManager.h>
8 #include <det/Detector.h>
9 #include <rdet/RDetector.h>
10 
11 #include <rdet/RStationListManager.h>
12 
13 #ifdef AUGER_SQLITE_ENABLED
14 # include <det/VSQLManager_SQLite.h>
15 #else
16 # include <det/VSQLManager_MySQL.h>
17 #endif
18 
19 
20 namespace rdet {
21 
43 
44  public:
46 
47  virtual void Init(const std::string& configLink);
48 
51  VMANAGER_GETDATA_CALL(GetStationListData, std::string)
53  VMANAGER_GETDATA_CALL(GetStationListData, std::vector<std::vector<int>>)
54 
55  //VMANAGER_GETDATA_NOTFOUND(unsigned long long int)
56  VMANAGER_GETDATA_NOTFOUND(std::vector<bool>)
57  VMANAGER_GETDATA_NOTFOUND(std::list<int>)
58  VMANAGER_GETDATA_NOTFOUND(std::list<std::pair<int, int> >)
59  VMANAGER_GETDATA_NOTFOUND(std::vector<double>)
60  VMANAGER_GETDATA_NOTFOUND(std::vector<std::string>)
61  VMANAGER_GETDATA_NOTFOUND(std::list<double>)
62  VMANAGER_GETDATA_NOTFOUND(std::list<std::string>)
63  VMANAGER_GETDATA_NOTFOUND(std::map<int, utl::TabulatedFunction>)
64  VMANAGER_GETDATA_NOTFOUND(std::map<std::string, double>)
65  VMANAGER_GETDATA_NOTFOUND(utl::TabulatedFunction)
66  VMANAGER_GETDATA_NOTFOUND(utl::TabulatedFunctionComplexLgAmpPhase)
67 
69  { return fStationManager; }
70 
71  void Update() const;
72 
73  // void AddGenericStations() const;
75 
76  bool HasStationData(const int id) const;
77 
78  // Function is used in radio managers to determine if the requested information
79  // for a particular station is suppose to be provided by this manager
80  static std::string
81  GetSourceType(const std::string stationIdstring)
82  {
83  const det::VManager& manager =
84  det::Detector::GetInstance().GetRManagerRegister();
85 
86  det::VManager::IndexMap indexMap;
87  indexMap["stationId"] = stationIdstring;
88 
89  // The detector description for RD stations is always supposed to come from XML
90  // This can not besided on a "higher" level because 1) the station list information
91  // which includes "source" for RD stations should come from the SD manager and not the
92  // radio manager. 2) When this function is called for the first time the rdet::Station
93  // does not exist yet.
94  if (boost::lexical_cast<int>(stationIdstring) > det::Detector::GetInstance().GetRDetector().GetRdSdStationIdLink())
95  return "XML";
96 
97  std::string source_string;
98  manager.GetData(source_string, "source", "stationList", indexMap);
99 
100  if (source_string != "SQL" && source_string != "XML")
101  ERROR("Station description source is set to an invalid value!");
102 
103  return source_string;
104  }
105 
106  private:
107  std::string Utf8To7Bit(const std::string& str) const;
108 
109  template<typename T>
111  GetData(T& returnData,
112  const std::string& componentProperty,
113  const det::VManager::IndexMap& componentIndex) const;
114 
115  template<typename T>
116  Status
117  GetStationListData(T& returnData,
118  const std::string& componentProperty,
119  const std::string& componentName,
120  const IndexMap& componentIndex)
121  const
122  {
123  if (componentName != "stationList")
124  return eNotFound;
125 
127  Update();
128 
129  return fStationManager.GetData(returnData, componentProperty, componentIndex);
130  }
131 
132  Status
133  GetStationListDataVectorInt(std::vector<int>& returnData, const std::string& componentProperty,
134  const std::string& componentName, const IndexMap& componentIndex)
135  const
136  {
137  // special case
138  if (componentName == "RChannel" && componentProperty == "listOfChannelIds") {
139  // returns eNotFound if the station description is not suppose to be from SQL
140  if (GetSourceType(componentIndex.find("station")->second) == "XML")
141  return GetListOfChannelIds(returnData, componentProperty, componentIndex);
142  }
143 
144  // we only match componentProperty
145  if (componentName != "stationList")
146  return eNotFound;
147 
149  Update();
150 
151  return fStationManager.GetData(returnData, componentProperty, componentIndex);
152  }
153 
154 
155  det::VManager::Status GetListOfChannelIds(std::vector<int>& returnData,
156  const std::string& componentProperty,
157  const det::VManager::IndexMap& componentIndex) const;
158 
160 
163 
166 
167  };
168 
169 }
170 
171 #endif
172 
Time interval defined by two TimeStamps.
Definition: TimeRange.h:23
Status GetStationListDataVectorInt(std::vector< int > &returnData, const std::string &componentProperty, const std::string &componentName, const IndexMap &componentIndex) const
Status const
Fetch first item from first row and optionally free query result.
det::VManager::Status GetListOfChannelIds(std::vector< int > &returnData, const std::string &componentProperty, const det::VManager::IndexMap &componentIndex) const
Interface for detector managers.
Definition: VManager.h:115
#define VMANAGER_GETDATA_CALL(_GetData_, _T_...)
Definition: VManager.h:59
const RStationListManager & GetStationListManager() const
virtual void Init(const std::string &configLink)
Manager Initialization. configLink is the CentralConfig hook for the configuration file...
det::VManager::Status GetData(T &returnData, const std::string &componentProperty, const det::VManager::IndexMap &componentIndex) const
Interface for detector managers that use MySQL.
virtual Status GetData(double &returnData, const std::string &componentProperty, const std::string &componentName, const IndexMap &componentIndex) const =0
void AddVirtualStation(RStationListManager::StationData &station)
#define VMANAGER_GETDATA_HANDLE_DENIED
Definition: VManager.h:75
det::VManager::Status GetData(T &returnData, const std::string &componentProperty, const det::VManager::IndexMap &componentIndex) const
Manager for RD description in SQL or XML station lists.
Status GetStationListData(T &returnData, const std::string &componentProperty, const std::string &componentName, const IndexMap &componentIndex) const
std::map< std::string, std::string > IndexMap
Definition: VManager.h:133
Common implementation of the station list manager.
std::string Utf8To7Bit(const std::string &str) const
VMANAGER_GETDATA_HANDLE_DENIED RStationListManager fStationManager
#define VMANAGER_GETDATA_NOTFOUND(_T_...)
Definition: VManager.h:41
Status
Specifies success or (eventually) various possible failure modes.
Definition: VManager.h:127
static std::string GetSourceType(const std::string stationIdstring)

, generated on Tue Sep 26 2023.