/** \file Base class for zone slices \author Tom Paul \version $Id$ \date 13 Aug 2004 */ #ifndef _atm_VZoneSlice_h_ #define _atm_VZoneSlice_h_ static const char CVSId_atm_VZoneSlice[] = "$Id$"; #include #include #include #include #include namespace atm { /** \class VZoneSlice \brief Base class for AttSlice and PFSlice. This base class factors out some common data and provides template methods to fetch data given appropriate database keys \author Tom Paul \version $Id$ \date 13 August 2004 \ingroup atm */ class VZoneSlice { public: /// Height of the top of the slice double GetMaxHeight() const; /// Height of the bottom of the slice double GetMinHeight() const; protected: VZoneSlice(const std::string& headerDBName, const std::string& zoneSliceId, const std::string& headerzoneIdString, const double minHeight, const double maxHeight); virtual ~VZoneSlice() { } double fMaxHeight; double fMinHeight; std::string fHeaderZoneIdString; // identifies record in aerosol_zone table std::string fZoneSliceIdString; // identifies slice in the zone std::string fHeaderDBName; // name of the header table (ie. "aerosol", "molecular", "lidar") // Helper method to do the redundant work of preparing requests for data contained // an a zone slice, sending it to the manager and reporting any errors. // The errorMsg argument is used to construct some hopefully meaningful error message if the // requested component is not found. It should have a description in some human language // of what was not located. // template void GetSliceData(T*& requestedData, const std::string& property, const std::string& component, const std::string& errorMsg) const { requestedData = new T; std::string headerZoneTableId = fHeaderDBName + "_zone_id"; det::VManager::IndexMap indexMap; indexMap[headerZoneTableId] = fHeaderZoneIdString; indexMap["zone_slices_id"] = fZoneSliceIdString; try { const det::VManager& manager = det::Detector::GetInstance().GetAManagerRegister(); const det::VManager::Status foundFlag = manager.GetData(*requestedData, property, component, indexMap); if (foundFlag == det::VManager::eFound) return; } catch (...) { delete requestedData; requestedData = 0; throw; } throw utl::DataNotFoundInDBException(errorMsg); } // Similar to GetSliceData, except that this method is intended for // data stored in attenuation_lambda and phase_func_lambda tables. // Fetching data from these tables requires first retrieving the // appropriate foreign key from the attenuation or phase_func table, // then using this in the query of the attenuation_lambda or // phase_func_lambda table. // template void GetLambdaSliceData(T*& requestedData, const std::string& zoneTable, // type of zone (eg. attenuation of phase_func) const std::string& foreignKey, // name of foreign key to lambda table (eg. attenuation_lambda_id, phase_func_lambda_id) const std::string& lambdaTable, // name of lambda table (eg. attenuation_lambda, phase_func_lambda) const std::string& column, // column in lambda table (eg att_lambda, f_lambda, ....) const std::string& errorMsg) const { requestedData = new T; det::VManager::IndexMap indexMap1; indexMap1["aerosol_zone_id"] = fHeaderZoneIdString; indexMap1["zone_slices_id"] = fZoneSliceIdString; try { const det::VManager& manager = det::Detector::GetInstance().GetAManagerRegister(); std::string lambdaIdString; const det::VManager::Status foundFlag1 = manager.GetData(lambdaIdString, zoneTable, foreignKey, indexMap1); std::string primaryKey = lambdaTable + "_id"; det::VManager::IndexMap indexMap2; indexMap2[primaryKey] = lambdaIdString; const det::VManager::Status foundFlag2 = manager.GetData(*requestedData, lambdaTable, column, indexMap2); if (foundFlag1 == det::VManager::eFound && foundFlag2 == det::VManager::eFound) return; } catch (...) { delete requestedData; requestedData = 0; throw; } throw utl::DataNotFoundInDBException(errorMsg); } }; } // atm #endif // _atm_VZoneSlice_h_ // Configure (x)emacs for this file ... // Local Variables: // mode: c++ // compile-command: "make -C .. -k" // End: