Sacado_ScalarParameterLibrary.hpp

Go to the documentation of this file.
00001 // $Id: Sacado_ScalarParameterLibrary.hpp,v 1.2 2007/06/23 00:46:31 etphipp Exp $ 
00002 // $Source: /space/CVS/Trilinos/packages/sacado/src/parameter/Sacado_ScalarParameterLibrary.hpp,v $ 
00003 // @HEADER
00004 // ***********************************************************************
00005 // 
00006 //                           Sacado Package
00007 //                 Copyright (2006) Sandia Corporation
00008 // 
00009 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
00010 // the U.S. Government retains certain rights in this software.
00011 // 
00012 // This library is free software; you can redistribute it and/or modify
00013 // it under the terms of the GNU Lesser General Public License as
00014 // published by the Free Software Foundation; either version 2.1 of the
00015 // License, or (at your option) any later version.
00016 //  
00017 // This library is distributed in the hope that it will be useful, but
00018 // WITHOUT ANY WARRANTY; without even the implied warranty of
00019 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00020 // Lesser General Public License for more details.
00021 //  
00022 // You should have received a copy of the GNU Lesser General Public
00023 // License along with this library; if not, write to the Free Software
00024 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00025 // USA
00026 // Questions? Contact David M. Gay (dmgay@sandia.gov) or Eric T. Phipps
00027 // (etphipp@sandia.gov).
00028 // 
00029 // ***********************************************************************
00030 // @HEADER
00031 
00032 #ifndef SACADO_SCALARPARAMETERLIBRARY_HPP
00033 #define SACADO_SCALARPARAMETERLIBRARY_HPP
00034 
00035 #include "Sacado_ParameterLibraryBase.hpp"
00036 #include "Sacado_ScalarParameterFamily.hpp"
00037 #include "Sacado_ScalarParameterVector.hpp"
00038 
00039 #include "Teuchos_TestForException.hpp"
00040 
00041 namespace Sacado {
00042 
00047   class ScalarParameterLibrary : 
00048     public ParameterLibraryBase<ScalarParameterFamily, ScalarParameterEntry> {
00049 
00050   public:
00051   
00053     ScalarParameterLibrary() {}
00054 
00056     virtual ~ScalarParameterLibrary() {}
00057 
00059     void setRealValueForAllTypes(const std::string& name, double value);
00060 
00062 
00065     template <class ValueType>
00066     void setValueAsConstant(const std::string& name, 
00067           const ValueType& value);
00068 
00070 
00073     template <class ValueType>
00074     void setValueAsIndependent(const std::string& name, 
00075              const ValueType& value);
00076 
00078     template <class ValueType>
00079     const ValueType& getValue(const std::string& name) const;
00080 
00082     static ScalarParameterLibrary& getInstance() {
00083       static ScalarParameterLibrary instance;
00084       return instance;
00085     }
00086 
00088 
00091     void
00092     fillVector(const Teuchos::Array<std::string>& names,
00093          ScalarParameterVector& pv);
00094 
00095   private:
00096 
00098     ScalarParameterLibrary(const ScalarParameterLibrary&);
00099 
00101     ScalarParameterLibrary& operator = (const ScalarParameterLibrary&);
00102 
00103   };
00104   
00105 }
00106 
00107 template <class ValueType>
00108 void
00109 Sacado::ScalarParameterLibrary::
00110 setValueAsConstant(const std::string& name, const ValueType& value)
00111 {
00112   FamilyMap::iterator it = library.find(name);
00113   TEST_FOR_EXCEPTION(
00114    it == library.end(), 
00115    std::logic_error,
00116    std::string("Sacado::ScalarParameterLibrary::setValueAsConstant():  ")
00117    + "Invalid parameter family " + name);
00118   (*it).second->setValueAsConstant(value);
00119 }
00120 
00121 template <class ValueType>
00122 void
00123 Sacado::ScalarParameterLibrary::
00124 setValueAsIndependent(const std::string& name, const ValueType& value)
00125 {
00126   FamilyMap::iterator it = library.find(name);
00127   TEST_FOR_EXCEPTION(
00128       it == library.end(), 
00129       std::logic_error,
00130       std::string("Sacado::ScalarParameterLibrary::setValueAsIndependent():  ")
00131       + "Invalid parameter family " + name);
00132   (*it).second->setValueAsIndependent(value);
00133 }
00134 
00135 template <class ValueType>
00136 const ValueType&
00137 Sacado::ScalarParameterLibrary::
00138 getValue(const std::string& name) const
00139 {
00140   FamilyMap::const_iterator it = library.find(name);
00141   TEST_FOR_EXCEPTION(
00142      it == library.end(), 
00143      std::logic_error,
00144      std::string("Sacado::ScalarParameterLibrary::getValue():  ")
00145      + "Invalid parameter family " + name);
00146   return (*it).second->getValue<ValueType>();
00147 }
00148 
00149 #endif

Generated on Wed May 12 21:59:05 2010 for Sacado Package Browser (Single Doxygen Collection) by  doxygen 1.4.7