From f495fd82d3598ca4fa8ebd8d30eaac9fa7b7ccb9 Mon Sep 17 00:00:00 2001 From: Michael Mayer Date: Thu, 6 Oct 2016 14:16:35 +0200 Subject: [PATCH] removed protected add_component method since not needed elsewhere --- include/GModelSpectralComposite.hpp | 1 - src/model/GModelSpectralComposite.cpp | 40 ++++++++++++---------------------------- 2 files changed, 12 insertions(+), 29 deletions(-) diff --git a/include/GModelSpectralComposite.hpp b/include/GModelSpectralComposite.hpp index 87b2af1..b9f7d57 100644 --- a/include/GModelSpectralComposite.hpp +++ b/include/GModelSpectralComposite.hpp @@ -92,7 +92,6 @@ protected: void init_members(void); void copy_members(const GModelSpectralComposite& model); void free_members(void); - void add_component(const GXmlElement& spec); void update_mc_cache(const GEnergy& emin, const GEnergy& emax) const; // Protected members diff --git a/src/model/GModelSpectralComposite.cpp b/src/model/GModelSpectralComposite.cpp index bd86f95..b0a7336 100644 --- a/src/model/GModelSpectralComposite.cpp +++ b/src/model/GModelSpectralComposite.cpp @@ -397,8 +397,17 @@ void GModelSpectralComposite::read(const GXmlElement& xml) // Get spectral XML element const GXmlElement* spec = xml.element("spectrum", i); - // Add spectral component - add_component(*spec); + // Initialise a spectral registry object + GModelSpectralRegistry registry; + + // Read spectral model + GModelSpectral* ptr = registry.alloc(*spec); + + // Get component attribute from XML file + std::string component_name = spec->attribute("component"); + + // Append spectral component to container + append(*ptr, component_name); } // endfor: loop over components @@ -539,6 +548,7 @@ void GModelSpectralComposite::append(const GModelSpectral& spec, const std::stri // Use model index if component name is empty std::string component_name = !name.empty() ? name : gammalib::str(m_spectral.size()); + // Check if component name is unique, throw exception if not if (gammalib::contains(m_components, component_name)) { std::string msg = "Attempt to append component with name \""+component_name+"\" to composite" @@ -716,32 +726,6 @@ void GModelSpectralComposite::free_members(void) /***********************************************************************//** - * @brief Add spectral component from XML element - * - * @param[in] spec XML element containing spectral information - * - * Add an XML spectral component to the model container - ***************************************************************************/ -void GModelSpectralComposite::add_component(const GXmlElement& spec) -{ - // Initialise a spectral registry object - GModelSpectralRegistry registry; - - // Read spectral model - GModelSpectral* ptr = registry.alloc(spec); - - // Get component attribute from XML file - std::string component_name = spec.attribute("component"); - - // Append spectral component to container - append(*ptr, component_name); - - // Return - return; -} - - -/***********************************************************************//** * @brief Update Monte Carlo pre computation cache * * @param[in] emin Minimum photon energy. -- libgit2 0.21.4