Ejemplo n.º 1
0
/***********************************************************************//**
 * @brief Invalid temporal model type
 *
 * @param[in] origin Method that throws the error.
 * @param[in] type Temporal model type that has been encountered.
 * @param[in] message Optional error message.
 ***************************************************************************/
GException::model_invalid_temporal::model_invalid_temporal(std::string origin,
                                                           std::string type,
                                                           std::string message)
{
    // Set origin and message
    m_origin  = origin;
    m_message = "Invalid temporal model type \""+type+"\" encountered. " +
                message;

    // Add list of valid spectral models
    GModelTemporalRegistry registry;
    if (registry.size() > 0) {
        m_message += "The following models are registered: ";
        for (int i = 0; i < registry.size(); ++i) {
            if (i > 0)
                m_message += ", ";
            m_message += "\"" + registry.name(i) + "\"";
        }
        m_message += ".";
    }
    else
        m_message += "No models are registered.";

    // Return
    return;
}
Ejemplo n.º 2
0
/***********************************************************************//**
 * @brief Return pointer to temporal model from XML element
 *
 * @param[in] temporal XML element.
 * @return Pointer to temporal model.
 *
 * Returns pointer to temporal model that is defined in an XML element.
 ***************************************************************************/
GModelTemporal* GCTAModelCubeBackground::xml_temporal(const GXmlElement& temporal) const
{
    // Get temporal model
    GModelTemporalRegistry registry;
    GModelTemporal*        ptr = registry.alloc(temporal);

    // Return pointer
    return ptr;
}
Ejemplo n.º 3
0
/***********************************************************************//**
 * @brief Construct temporal model from XML element
 *
 * @param[in] temporal XML element containing temporal model information.
 *
 * @exception GException::model_invalid_temporal
 *            Invalid temporal model type encountered.
 *
 * Returns pointer to a temporal model that is defined in an XML element.
 ***************************************************************************/
GModelTemporal* GCTAModelBackground::xml_temporal(const GXmlElement& temporal) const
{
    // Get temporal model type
    std::string type = temporal.attribute("type");

    // Get temporal model
    GModelTemporalRegistry registry;
    GModelTemporal*        ptr = registry.alloc(type);

    // If model if valid then read model from XML file
    if (ptr != NULL) {
        ptr->read(temporal);
    }

    // ... otherwise throw an exception
    else {
        throw GException::model_invalid_temporal(G_XML_TEMPORAL, type);
    }

    // Return pointer
    return ptr;
}