RChannelSQLManager.h
Go to the documentation of this file.
1 #ifndef _rdet_RChannelSQLManager_h_
2 #define _rdet_RChannelSQLManager_h_
3 
4 #include <map>
5 #include <string>
6 #include <algorithm>
7 
8 #include <det/VManager.h>
9 #include <utl/ErrorLogger.h>
10 #include <utl/config.h>
11 #include <utl/ResponseMap.h>
12 #include <boost/lexical_cast.hpp>
13 
14 #include <det/Detector.h>
15 #include <rdet/RDetector.h>
16 #include <rdet/Station.h>
17 #include <rdet/RSimulationStationListManager.h>
18 
19 #ifdef AUGER_SQLITE_ENABLED
20 # include <det/VSQLManager_SQLite.h>
21 #else
22 # include <det/VSQLManager_MySQL.h>
23 #endif
24 
25 
26 namespace utl {
27  class TabulatedFunction;
28  class TabulatedFunctionComplexLgAmpPhase;
29 }
30 
31 namespace rdet {
32 
55 
56  struct ChannelIdList {
57  std::vector<int> fChannelIds;
58  unsigned long int fGpsSecondComission;
59  unsigned long int fGpsSecondDecomission;
60  };
61 
62  public:
63  virtual ~RChannelSQLManager() { }
64 
65  void Init(const std::string& configLink);
66 
69  VMANAGER_GETDATA_CALL(InternalGetData, std::string)
71  VMANAGER_GETDATA_CALL(GetTFCLAPData, utl::TabulatedFunctionComplexLgAmpPhase)
72  VMANAGER_GETDATA_CALL(GetDataMap, std::map<std::string, double>)
73 
74  //VMANAGER_GETDATA_NOTFOUND(unsigned long long int)
75  VMANAGER_GETDATA_NOTFOUND(std::vector<double>)
76  VMANAGER_GETDATA_NOTFOUND(std::vector<std::string>)
77  VMANAGER_GETDATA_NOTFOUND(std::list<double>)
78  VMANAGER_GETDATA_NOTFOUND(std::list<int>)
79  VMANAGER_GETDATA_NOTFOUND(std::list<std::string>)
80  VMANAGER_GETDATA_NOTFOUND(std::vector<bool>)
81  VMANAGER_GETDATA_NOTFOUND(std::vector<std::vector<int> >)
82  VMANAGER_GETDATA_NOTFOUND(std::list<std::pair<int, int> >)
83  VMANAGER_GETDATA_NOTFOUND(std::map<int, utl::TabulatedFunction>)
84  VMANAGER_GETDATA_NOTFOUND(utl::TabulatedFunction)
85 
86  Status GetChannelListFromBuffer(std::vector<int>& returnData,
87  const std::string& componentProperty,
88  const std::string& componentName,
89  const IndexMap& componentIndex) const;
90 
91  Status GetTFCLAPData(utl::TabulatedFunctionComplexLgAmpPhase& returnData,
92  const std::string& componentProperty,
93  const std::string& componentName,
94  const IndexMap& componentIndex) const;
95 
96  Status GetDataMap(std::map<std::string,double>& returnData,
97  const std::string& componentProperty,
98  const std::string& componentName,
99  const IndexMap& componentIndex) const;
100 
102 
103  private:
104  typedef std::map<std::string, std::string> ComponentMap;
105  typedef std::pair<std::string, std::string> Index;
106 
107  template<typename T>
108  Status
109  InternalGetData(T& returnData,
110  const std::string& componentProperty,
111  const std::string& componentName,
112  const IndexMap& componentIndex)
113  const
114  {
115  if (componentProperty == "addSStationList") {
116  returnData = boost::lexical_cast<T>(0);
117  return eFound;
118  }
119 
120  if (componentName != "RChannel" && componentName != "RADC" && componentName != "RResponseMapList")
121  return eNotFound;
122 
123  // if ComponentMap is not filled for this Station/Channel given by IndexMap
124  Index currentComponent(componentIndex.find("station")->second,
125  componentIndex.find("channel")->second);
126 
127  // returns eNotFound if the station description is not suppose to be from SQL
128  if (RSimulationStationListManager::GetSourceType(currentComponent.first) != "SQL")
129  return eNotFound;
130 
131  // std::cout << "ChannelSQL InternalGetData: " << componentProperty << " " << componentName << std::endl;
132 
133  std::string temp = "";
134  Status resultStatus = GetComponentFromBuffer(temp, currentComponent, componentProperty);
135  if (resultStatus == eFound) {
136  returnData = boost::lexical_cast<T>(temp);
137  return eFound;
138  }
139  return eNotFound;
140  }
141 
142  void FillComponentMap(const IndexMap& componentIndex) const;
143 
144  void BufferComponentMap() const;
145 
146  VManager::Status GetComponentFromBuffer(std::string& returnData,
147  const Index& componentIndex,
148  const std::string& componentProperty) const;
149 
150  void BufferChannelList() const;
151 
153  mutable IndexMap fIndexMap;
154  mutable std::map<Index, ComponentMap> fBuffer; // buffer for channel data
155 
156  mutable std::map<int, ChannelIdList> fBufferChannelIdLists;
157 
158  };
159 
160 }
161 
162 
163 #endif
std::pair< std::string, std::string > Index
Status const
Fetch first item from first row and optionally free query result.
Status GetDataMap(std::map< std::string, double > &returnData, const std::string &componentProperty, const std::string &componentName, const IndexMap &componentIndex) const
std::map< Index, ComponentMap > fBuffer
locally store IndexMap for which the ComponentMap is filled
#define VMANAGER_GETDATA_CALL(_GetData_, _T_...)
Definition: VManager.h:59
Interface for detector managers that use MySQL.
Status
Return code for seek operation.
Definition: IoCodes.h:24
VManager::Status GetComponentFromBuffer(std::string &returnData, const Index &componentIndex, const std::string &componentProperty) const
void Init(const std::string &configLink)
Manager Initialization. configLink is the CentralConfig hook for the configuration file...
Status GetTFCLAPData(utl::TabulatedFunctionComplexLgAmpPhase &returnData, const std::string &componentProperty, const std::string &componentName, const IndexMap &componentIndex) const
#define VMANAGER_GETDATA_HANDLE_DENIED
Definition: VManager.h:75
std::map< int, ChannelIdList > fBufferChannelIdLists
std::map< std::string, std::string > ComponentMap
void FillComponentMap(const IndexMap &componentIndex) const
Status InternalGetData(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
IndexMap fIndexMap
map to store internally the sql-result
Status GetChannelListFromBuffer(std::vector< int > &returnData, const std::string &componentProperty, const std::string &componentName, const IndexMap &componentIndex) const
Manager for RD description of Station-Channels in SQL DB.
#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.