Commit f495fd82d3598ca4fa8ebd8d30eaac9fa7b7ccb9

Authored by Michael Mayer
1 parent 1f7446fe

removed protected add_component method since not needed elsewhere

include/GModelSpectralComposite.hpp
... ... @@ -92,7 +92,6 @@ protected:
92 92 void init_members(void);
93 93 void copy_members(const GModelSpectralComposite& model);
94 94 void free_members(void);
95   - void add_component(const GXmlElement& spec);
96 95 void update_mc_cache(const GEnergy& emin, const GEnergy& emax) const;
97 96  
98 97 // Protected members
... ...
src/model/GModelSpectralComposite.cpp
... ... @@ -397,8 +397,17 @@ void GModelSpectralComposite::read(const GXmlElement& xml)
397 397 // Get spectral XML element
398 398 const GXmlElement* spec = xml.element("spectrum", i);
399 399  
400   - // Add spectral component
401   - add_component(*spec);
  400 + // Initialise a spectral registry object
  401 + GModelSpectralRegistry registry;
  402 +
  403 + // Read spectral model
  404 + GModelSpectral* ptr = registry.alloc(*spec);
  405 +
  406 + // Get component attribute from XML file
  407 + std::string component_name = spec->attribute("component");
  408 +
  409 + // Append spectral component to container
  410 + append(*ptr, component_name);
402 411  
403 412 } // endfor: loop over components
404 413  
... ... @@ -539,6 +548,7 @@ void GModelSpectralComposite::append(const GModelSpectral& spec, const std::stri
539 548 // Use model index if component name is empty
540 549 std::string component_name = !name.empty() ? name : gammalib::str(m_spectral.size());
541 550  
  551 + // Check if component name is unique, throw exception if not
542 552 if (gammalib::contains(m_components, component_name)) {
543 553 std::string msg =
544 554 "Attempt to append component with name \""+component_name+"\" to composite"
... ... @@ -716,32 +726,6 @@ void GModelSpectralComposite::free_members(void)
716 726  
717 727  
718 728 /***********************************************************************//**
719   - * @brief Add spectral component from XML element
720   - *
721   - * @param[in] spec XML element containing spectral information
722   - *
723   - * Add an XML spectral component to the model container
724   - ***************************************************************************/
725   -void GModelSpectralComposite::add_component(const GXmlElement& spec)
726   -{
727   - // Initialise a spectral registry object
728   - GModelSpectralRegistry registry;
729   -
730   - // Read spectral model
731   - GModelSpectral* ptr = registry.alloc(spec);
732   -
733   - // Get component attribute from XML file
734   - std::string component_name = spec.attribute("component");
735   -
736   - // Append spectral component to container
737   - append(*ptr, component_name);
738   -
739   - // Return
740   - return;
741   -}
742   -
743   -
744   -/***********************************************************************//**
745 729 * @brief Update Monte Carlo pre computation cache
746 730 *
747 731 * @param[in] emin Minimum photon energy.
... ...