|
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_PARAMETERLIBRARYBASE_HPP 00033 #define SACADO_PARAMETERLIBRARYBASE_HPP 00034 00035 #include <iostream> 00036 00037 #include "Teuchos_Array.hpp" 00038 00039 #include "Sacado_ParameterFamilyBase.hpp" 00040 #include "Sacado_ParameterVectorBase.hpp" 00041 #include "Sacado_mpl_apply.hpp" 00042 00043 namespace Sacado { 00044 00045 using std::string; 00046 00051 template <typename FamilyType, typename EntryType> 00052 class ParameterLibraryBase { 00053 00054 protected: 00055 00057 typedef std::map<string, Teuchos::RCP<FamilyType> > FamilyMap; 00058 00059 public: 00060 00062 typedef typename FamilyMap::iterator iterator; 00063 00065 typedef typename FamilyMap::const_iterator const_iterator; 00066 00068 ParameterLibraryBase(); 00069 00071 virtual ~ParameterLibraryBase(); 00072 00074 bool isParameter(const std::string& name) const; 00075 00077 template <typename EvalType> 00078 bool isParameterForType(const std::string& name) const; 00079 00081 00085 bool addParameterFamily(const std::string& name, bool supports_ad, 00086 bool supports_analytic); 00087 00088 00090 00094 template <typename EvalType> 00095 bool addEntry(const std::string& name, 00096 const Teuchos::RCP< typename Sacado::mpl::apply<EntryType,EvalType>::type >& entry); 00097 00099 template <typename EvalType> 00100 Teuchos::RCP< typename Sacado::mpl::apply<EntryType,EvalType>::type > 00101 getEntry(const std::string& name); 00102 00104 template <typename EvalType> 00105 Teuchos::RCP< const typename Sacado::mpl::apply<EntryType,EvalType>::type > 00106 getEntry(const std::string& name) const; 00107 00109 unsigned int size() const { return library.size(); } 00110 00112 iterator begin() { return library.begin(); } 00113 00115 const_iterator begin() const { return library.begin(); } 00116 00118 iterator end() { return library.end(); } 00119 00121 const_iterator end() const { return library.end(); } 00122 00124 template <typename BaseValueType> 00125 void 00126 fillVector(const Teuchos::Array<std::string>& names, 00127 const Teuchos::Array<BaseValueType>& values, 00128 ParameterVectorBase<FamilyType,BaseValueType>& pv); 00129 00131 00135 void print(std::ostream& os, bool print_values = false) const; 00136 00137 private: 00138 00140 ParameterLibraryBase(const ParameterLibraryBase&); 00141 00143 ParameterLibraryBase& operator = (const ParameterLibraryBase&); 00144 00145 protected: 00146 00148 FamilyMap library; 00149 }; 00150 00151 template <typename FamilyType, typename EntryType> 00152 std::ostream& 00153 operator << (std::ostream& os, 00154 const ParameterLibraryBase<FamilyType, EntryType>& pl) 00155 { 00156 pl.print(os); 00157 return os; 00158 } 00159 } 00160 00161 // Include template definitions 00162 #include "Sacado_ParameterLibraryBaseImp.hpp" 00163 00164 #endif
1.7.4