// @HEADER // ***************************************************************************** // Sacado Package // // Copyright 2006 NTESS and the Sacado contributors. // SPDX-License-Identifier: LGPL-2.1-or-later // ***************************************************************************** // @HEADER #ifndef SACADO_SCALARPARAMETERFAMILY_HPP #define SACADO_SCALARPARAMETERFAMILY_HPP #include "Sacado_ParameterFamilyBase.hpp" #include "Sacado_ScalarParameterEntry.hpp" namespace Sacado { using namespace mpl::placeholders; //! Specialization of Sacado::ParameterFamilyBase for scalar parameters template class ScalarParameterFamily : public Sacado::ParameterFamilyBase > { //! Typename synonym of base class typedef Sacado::ParameterFamilyBase > BaseT; public: //! Constructor ScalarParameterFamily(const std::string& name_, bool supports_ad_, bool supports_analytic_) : BaseT(name_, supports_ad_, supports_analytic_) {} //! Destructor virtual ~ScalarParameterFamily() {} //! Set paramter value using a real number void setRealValueForAllTypes(double value) { for (typename BaseT::iterator it = this->family.begin(); it != this->family.end(); ++it) (*it).second->setRealValue(value); } //! Set real parameter value template void setRealValue(double value) { this->template getEntry()->setRealValue(value); } //! Set parameter to value \em value treating parameter as a constant template void setValue(const typename EvalTypeTraits::template apply::type& value) { this->template getEntry()->setValue(value); } //! Get real parameter value template double getRealValue() const { return this->template getEntry()->getRealValue(); } //! Get parameter value template const typename EvalTypeTraits::template apply::type& getValue() const { return this->template getEntry()->getValue(); } //! Add a new parameter using custom entry /*! * Returns true if successful in adding entry to library, false * otherwise. */ private: //! Private to prohibit copying ScalarParameterFamily(const ScalarParameterFamily&); //! Private to prohibit copying ScalarParameterFamily& operator = (const ScalarParameterFamily&); }; /** \brief Get the value. * * \relates ScalarParameterFamily */ template typename Sacado::ScalarParameterEntry::ScalarT getValue(const ScalarParameterFamily& spf) { return spf.template getValue(); } } // namespace Sacado #endif