#ifndef _rdet_RChannelSQLManager_h_ #define _rdet_RChannelSQLManager_h_ #include #include #include #include #include #include #include #include #ifdef AUGER_SQLITE_ENABLED # include #else # include #endif namespace utl { class TabulatedFunction; class TabulatedFunctionComplexLgAmpPhase; } namespace rdet { /** \class RChannelSQLManager \brief Manager for RD description of Station-Channels in SQL DB This Manager retrieves the detector-configuration for channels of a given station. Unlike the XML-manager and the SD we abandon here the use of models for stations. In the SQL-DB for each channel and each station an association of ADC,Channel and ResponseMap is filled in RHardWareAssociation. Data is then taken from the according tables RChannel, RADC, as well as RResponse via the ResponseMapList. The data for one station/channel is retrieved on initialisation and stored in a map. This asures only one sql-query for each channel. If the componentIndex agrees with the fIndexMap the data for this chanel is valid and only the map-contens is returned without further sql-query. \author J. Rautenberg \version $Id$ \date 30 May 2012 \ingroup managers */ class RChannelSQLManager : public det::VSQLManager { struct ChannelIdList { std::vector fChannelIds; unsigned long int fGpsSecondComission; unsigned long int fGpsSecondDecomission; }; public: virtual ~RChannelSQLManager() { } void Init(const std::string& configLink); VMANAGER_GETDATA_CALL(InternalGetData, double) VMANAGER_GETDATA_CALL(InternalGetData, int) //VMANAGER_GETDATA_NOTFOUND(unsigned long long int) VMANAGER_GETDATA_CALL(InternalGetData, std::string) VMANAGER_GETDATA_CALL(GetChannelListFromBuffer, std::vector) Status GetChannelListFromBuffer(std::vector& returnData, const std::string& componentProperty, const std::string& componentName, const IndexMap& componentIndex) const; VMANAGER_GETDATA_NOTFOUND(std::vector) VMANAGER_GETDATA_NOTFOUND(std::vector) VMANAGER_GETDATA_NOTFOUND(std::list) VMANAGER_GETDATA_NOTFOUND(std::list) VMANAGER_GETDATA_NOTFOUND(std::list) VMANAGER_GETDATA_CALL(GetTFCLAPData, utl::TabulatedFunctionComplexLgAmpPhase) VMANAGER_GETDATA_CALL(GetDataMap, std::map) Status GetTFCLAPData(utl::TabulatedFunctionComplexLgAmpPhase& returnData, const std::string& componentProperty, const std::string& componentName, const IndexMap& componentIndex) const; Status GetDataMap(std::map& returnData, const std::string& componentProperty, const std::string& componentName, const IndexMap& componentIndex) const; VMANAGER_GETDATA_NOTFOUND(std::vector) VMANAGER_GETDATA_NOTFOUND(std::vector >) VMANAGER_GETDATA_NOTFOUND(std::list >) VMANAGER_GETDATA_NOTFOUND(std::map) VMANAGER_GETDATA_NOTFOUND(utl::TabulatedFunction) VMANAGER_GETDATA_HANDLE_DENIED private: typedef std::map ComponentMap; typedef std::pair Index; template Status InternalGetData(T& returnData, const std::string& componentProperty, const std::string& componentName, const IndexMap& componentIndex) const { if (componentName != "RChannel" && componentName != "RADC" && componentName != "RResponseMapList") return eNotFound; // if ComponentMap is not filled for this Station/Channel given by IndexMap Index currentComponent(componentIndex.find("station")->second, componentIndex.find("channel")->second); //std::cout << "RChannelSQLManager got a request for component property = " << componentProperty // << " of station " << currentComponent.first << " and channel " << currentComponent.second << std::endl; std::string temp = ""; VManager::Status resultStatus = GetComponentFromBuffer(temp,currentComponent, componentProperty); if (resultStatus == eFound) { returnData = boost::lexical_cast(temp); return eFound; } return eNotFound; } void FillComponentMap(const IndexMap& componentIndex) const; void BufferComponentMap() const; VManager::Status GetComponentFromBuffer(std::string& returnData, const Index& componentIndex, const std::string& componentProperty) const; void BufferChannelList() const; mutable ComponentMap fComponentMap; //! map to store internally the sql-result mutable IndexMap fIndexMap; //! locally store IndexMap for which the ComponentMap is filled mutable std::map fBuffer; // buffer for channel data mutable std::map fBufferChannelIdLists; }; } #endif