|
Sacado Package Browser (Single Doxygen Collection) Version of the Day
|
00001 // $Id$ 00002 // $Source$ 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_SCALARPARAMETERENTRY_HPP 00033 #define SACADO_SCALARPARAMETERENTRY_HPP 00034 00035 #include "Sacado_Traits.hpp" 00036 #include "Sacado_mpl_apply.hpp" 00037 00038 namespace Sacado { 00039 00041 00060 struct DefaultEvalTypeTraits { 00061 template <class EvalType> struct apply { 00062 typedef EvalType type; }; 00063 }; 00064 00066 class AbstractScalarParameterEntry { 00067 public: 00068 00070 AbstractScalarParameterEntry() {} 00071 00073 virtual ~AbstractScalarParameterEntry() {} 00074 00076 virtual void setRealValue(double value) = 0; 00077 00079 virtual double getRealValue() const = 0; 00080 00082 virtual void print(std::ostream& os) const = 0; 00083 }; 00084 00088 template <typename EvalType, typename EvalTypeTraits = DefaultEvalTypeTraits> 00089 class ScalarParameterEntry : public AbstractScalarParameterEntry { 00090 00091 public: 00092 00093 typedef typename EvalTypeTraits::template apply<EvalType>::type ScalarT; 00094 00096 ScalarParameterEntry() {} 00097 00099 virtual ~ScalarParameterEntry() {} 00100 00102 00106 virtual void setValue(const ScalarT& value) = 0; 00107 00109 virtual const ScalarT& getValue() const = 0; 00110 00112 00115 virtual double getRealValue() const { 00116 return Sacado::ScalarValue<ScalarT>::eval(this->getValue()); 00117 } 00118 00120 00123 virtual void print(std::ostream& os) const { 00124 os << getValue(); 00125 } 00126 00127 }; 00128 } 00129 00130 #endif
1.7.4