/***********************************************************************//** * @brief Construct spectral model from XML element * * @param[in] spectral XML element containing spectral model information. * * @exception GException::model_invalid_spectral * Invalid spectral model type encountered. * * Returns pointer to a spectral model that is defined in an XML element. ***************************************************************************/ GModelSpectral* GCTAModelBackground::xml_spectral(const GXmlElement& spectral) const { // Get spectral model type std::string type = spectral.attribute("type"); // Get spectral model GModelSpectralRegistry registry; GModelSpectral* ptr = registry.alloc(type); // If model if valid then read model from XML file if (ptr != NULL) { ptr->read(spectral); } // ... otherwise throw an exception else { throw GException::model_invalid_spectral(G_XML_SPECTRAL, type); } // Return pointer return ptr; }