Sacado_ParameterRegistration.hpp

Go to the documentation of this file.
00001 // $Source$ 
00002 // @HEADER
00003 // ***********************************************************************
00004 // 
00005 //                           Sacado Package
00006 //                 Copyright (2006) Sandia Corporation
00007 // 
00008 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
00009 // the U.S. Government retains certain rights in this software.
00010 // 
00011 // This library is free software; you can redistribute it and/or modify
00012 // it under the terms of the GNU Lesser General Public License as
00013 // published by the Free Software Foundation; either version 2.1 of the
00014 // License, or (at your option) any later version.
00015 //  
00016 // This library is distributed in the hope that it will be useful, but
00017 // WITHOUT ANY WARRANTY; without even the implied warranty of
00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00019 // Lesser General Public License for more details.
00020 //  
00021 // You should have received a copy of the GNU Lesser General Public
00022 // License along with this library; if not, write to the Free Software
00023 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00024 // USA
00025 // Questions? Contact David M. Gay (dmgay@sandia.gov) or Eric T. Phipps
00026 // (etphipp@sandia.gov).
00027 // 
00028 // ***********************************************************************
00029 // @HEADER
00030 
00031 #ifndef SACADO_PARAMETERREGISTRATION_HPP
00032 #define SACADO_PARAMETERREGISTRATION_HPP
00033 
00034 #include <sstream>
00035 #include "Sacado_ParameterAccessor.hpp"
00036 #include "Sacado_Traits.hpp"
00037 
00038 
00039 namespace Sacado {
00045   template <typename EvalType, typename EvalTypeTraits = DefaultEvalTypeTraits>
00046   class ParameterRegistration : 
00047     public Sacado::ScalarParameterEntry<EvalType, EvalTypeTraits > {
00048 
00050     typedef typename EvalTypeTraits::template apply<EvalType>::type ScalarT;
00051 
00052 
00053   public:
00054 
00056     ParameterRegistration(const std::string &name_, ParameterAccessor<EvalType, EvalTypeTraits>* access_,
00057                             Teuchos::RCP<ParamLib> paramLib)
00058       : access(access_), name(name_) {
00059 
00060       if (paramLib != Teuchos::null) {
00061         if (!paramLib->isParameter(name))
00062           paramLib->addParameterFamily(name, true, false);
00063         if (!paramLib->template isParameterForType<EvalType>(name)) {
00064           paramLib->template addEntry<EvalType>(name, Teuchos::rcp(this,false));
00065         }
00066       }
00067     }
00068 
00070     virtual ~ParameterRegistration() {}
00071 
00073     virtual void setRealValue(double value) { 
00074       setValue(ScalarT(value)); }
00075 
00077     virtual void setValue(const ScalarT& value) { 
00078       access->getValue(name) =  value; }
00079     
00081     virtual const ScalarT& getValue() const { 
00082       return access->getValue(name); 
00083      }
00084     
00085   protected:  
00086     
00088      ParameterAccessor<EvalType, EvalTypeTraits>* access;
00089      const std::string name;
00090 
00091   };
00092 }
00093 
00094 #endif // SACADO_PARAMETERREGISTRATION_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Generated on Wed Apr 13 10:19:34 2011 for Sacado Package Browser (Single Doxygen Collection) by  doxygen 1.6.3