00001 // @HEADER 00002 // ************************************************************************ 00003 // 00004 // Phalanx: A Partial Differential Equation Field Evaluation 00005 // Kernel for Flexible Management of Complex Dependency Chains 00006 // Copyright (2008) 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 // 00026 // Questions? Contact Roger Pawlowski (rppawlo@sandia.gov), Sandia 00027 // National Laboratories. 00028 // 00029 // ************************************************************************ 00030 // @HEADER 00031 00032 #ifndef PHX_FIELDTAG_TAG_DEF_HPP 00033 #define PHX_FIELDTAG_TAG_DEF_HPP 00034 00035 #include <sstream> 00036 #include "Phalanx_TypeStrings.hpp" 00037 #include "Teuchos_TestForException.hpp" 00038 00039 //********************************************************************** 00040 template<typename DataT> 00041 PHX::Tag<DataT>::Tag(const std::string& name, 00042 const Teuchos::RCP<PHX::DataLayout>& dl) : 00043 m_name(name), 00044 m_data_layout(dl) 00045 { } 00046 00047 //********************************************************************** 00048 template<typename DataT> 00049 PHX::Tag<DataT>::~Tag() 00050 { } 00051 00052 //********************************************************************** 00053 template<typename DataT> 00054 Teuchos::RCP<PHX::FieldTag> PHX::Tag<DataT>::clone() const 00055 { 00056 Teuchos::RCP<PHX::FieldTag> tag = 00057 Teuchos::rcp(new PHX::Tag<DataT>(m_name, m_data_layout)); 00058 return (tag); 00059 } 00060 00061 //********************************************************************** 00062 template<typename DataT> 00063 void PHX::Tag<DataT>::operator=(const PHX::Tag<DataT>& t) 00064 { 00065 m_name = t.m_name; 00066 m_data_layout = t.m_data_layout; 00067 } 00068 00069 //********************************************************************** 00070 template<typename DataT> 00071 bool PHX::Tag<DataT>::operator==(const PHX::FieldTag& t) const 00072 { 00073 return ( (this->name() == t.name()) && 00074 (this->dataLayout() == t.dataLayout()) && 00075 (this->dataTypeInfo() == t.dataTypeInfo()) ); 00076 } 00077 00078 //********************************************************************** 00079 template<typename DataT> 00080 const std::string& PHX::Tag<DataT>::name() const 00081 { return m_name; } 00082 00083 //********************************************************************** 00084 template<typename DataT> 00085 const PHX::DataLayout& PHX::Tag<DataT>::dataLayout() const 00086 { return *m_data_layout; } 00087 00088 //********************************************************************** 00089 template<typename DataT> 00090 const std::type_info& PHX::Tag<DataT>::dataTypeInfo() const 00091 { 00092 DataT tmp; 00093 return typeid(tmp); 00094 } 00095 00096 //********************************************************************** 00097 template<typename DataT> 00098 const std::string PHX::Tag<DataT>::identifier() const 00099 { 00100 std::ostringstream ost; 00101 00102 ost << this->name() 00103 << this->dataTypeInfo().name() 00104 << this->dataLayout().identifier(); 00105 return ost.str(); 00106 } 00107 00108 //********************************************************************** 00109 template<typename DataT> 00110 void PHX::Tag<DataT>::print(std::ostream& os) const 00111 { 00112 // DataT tmp; 00113 // os << "Tag: " << m_name << ", " << typeid(tmp).name() 00114 // << ", DataLayout: " << *m_data_layout; 00115 os << "Tag: " << m_name << ", " << PHX::typeAsString<DataT>() 00116 << ", DataLayout: " << *m_data_layout; 00117 00118 } 00119 00120 //********************************************************************** 00121 template<typename DataT> 00122 std::ostream& PHX::operator<<(std::ostream& os, const PHX::Tag<DataT>& v) 00123 { 00124 v.print(os); 00125 return os; 00126 } 00127 00128 //********************************************************************** 00129 00130 #endif