|
Teuchos Package Browser (Single Doxygen Collection) Version of the Day
|
00001 // @HEADER 00002 // *********************************************************************** 00003 // 00004 // Teuchos: Common Tools Package 00005 // Copyright (2004) Sandia Corporation 00006 // 00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive 00008 // license for use of this work by or on behalf of the U.S. Government. 00009 // 00010 // This library is free software; you can redistribute it and/or modify 00011 // it under the terms of the GNU Lesser General Public License as 00012 // published by the Free Software Foundation; either version 2.1 of the 00013 // License, or (at your option) any later version. 00014 // 00015 // This library is distributed in the hope that it will be useful, but 00016 // WITHOUT ANY WARRANTY; without even the implied warranty of 00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00018 // Lesser General Public License for more details. 00019 // 00020 // You should have received a copy of the GNU Lesser General Public 00021 // License along with this library; if not, write to the Free Software 00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 00023 // USA 00024 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 00025 // 00026 // *********************************************************************** 00027 // @HEADER 00028 00029 #ifndef TEUCHOS_REDUCTION_OP_HELPERS_HPP 00030 #define TEUCHOS_REDUCTION_OP_HELPERS_HPP 00031 00032 #include "Teuchos_ReductionOp.hpp" 00033 #include "Teuchos_SerializationTraitsHelpers.hpp" 00034 #include "Teuchos_SerializerHelpers.hpp" 00035 00036 namespace Teuchos { 00037 00044 template<typename Ordinal, typename T> 00045 class CharToValueTypeReductionOp : public ValueTypeReductionOp<Ordinal,char> 00046 { 00047 public: 00049 CharToValueTypeReductionOp( 00050 const RCP<const ValueTypeReductionOp<Ordinal,T> > &reductOp 00051 ); 00053 void reduce( 00054 const Ordinal charCount 00055 ,const char charInBuffer[] 00056 ,char charInoutBuffer[] 00057 ) const; 00058 private: 00059 RCP<const ValueTypeReductionOp<Ordinal,T> > reductOp_; 00060 // Not defined and not to be called! 00061 CharToValueTypeReductionOp(); 00062 CharToValueTypeReductionOp(const CharToValueTypeReductionOp&); 00063 CharToValueTypeReductionOp& operator=(const CharToValueTypeReductionOp&); 00064 }; 00065 00072 template<typename Ordinal, typename T> 00073 class CharToReferenceTypeReductionOp : public ValueTypeReductionOp<Ordinal,char> 00074 { 00075 public: 00077 CharToReferenceTypeReductionOp( 00078 const RCP<const Serializer<Ordinal,T> > &serializer 00079 ,const RCP<const ReferenceTypeReductionOp<Ordinal,T> > &reductOp 00080 ); 00082 void reduce( 00083 const Ordinal charCount 00084 ,const char charInBuffer[] 00085 ,char charInoutBuffer[] 00086 ) const; 00087 private: 00088 RCP<const Serializer<Ordinal,T> > serializer_; 00089 RCP<const ReferenceTypeReductionOp<Ordinal,T> > reductOp_; 00090 // Not defined and not to be called! 00091 CharToReferenceTypeReductionOp(); 00092 CharToReferenceTypeReductionOp(const CharToReferenceTypeReductionOp&); 00093 CharToReferenceTypeReductionOp& operator=(const CharToReferenceTypeReductionOp&); 00094 }; 00095 00096 // ///////////////////////////////////// 00097 // Template implementations 00098 00099 // 00100 // CharToValueTypeReductionOp 00101 // 00102 00103 template<typename Ordinal, typename T> 00104 CharToValueTypeReductionOp<Ordinal,T>::CharToValueTypeReductionOp( 00105 const RCP<const ValueTypeReductionOp<Ordinal,T> > &reductOp 00106 ) 00107 :reductOp_(reductOp) 00108 {} 00109 00110 template<typename Ordinal, typename T> 00111 void CharToValueTypeReductionOp<Ordinal,T>::reduce( 00112 const Ordinal charCount 00113 ,const char charInBuffer[] 00114 ,char charInoutBuffer[] 00115 ) const 00116 { 00117 ConstValueTypeDeserializationBuffer<Ordinal,T> 00118 inBuffer(charCount,charInBuffer); 00119 ValueTypeDeserializationBuffer<Ordinal,T> 00120 inoutBuffer(charCount,charInoutBuffer); 00121 reductOp_->reduce( 00122 inBuffer.getCount(),inBuffer.getBuffer(),inoutBuffer.getBuffer() 00123 ); 00124 } 00125 00126 // 00127 // CharToReferenceTypeReductionOp 00128 // 00129 00130 template<typename Ordinal, typename T> 00131 CharToReferenceTypeReductionOp<Ordinal,T>::CharToReferenceTypeReductionOp( 00132 const RCP<const Serializer<Ordinal,T> > &serializer 00133 ,const RCP<const ReferenceTypeReductionOp<Ordinal,T> > &reductOp 00134 ) 00135 :serializer_(serializer), reductOp_(reductOp) 00136 {} 00137 00138 template<typename Ordinal, typename T> 00139 void CharToReferenceTypeReductionOp<Ordinal,T>::reduce( 00140 const Ordinal charCount 00141 ,const char charInBuffer[] 00142 ,char charInoutBuffer[] 00143 ) const 00144 { 00145 ConstReferenceTypeDeserializationBuffer<Ordinal,T> 00146 inBuffer(*serializer_,charCount,charInBuffer); 00147 ReferenceTypeDeserializationBuffer<Ordinal,T> 00148 inoutBuffer(*serializer_,charCount,charInoutBuffer); 00149 reductOp_->reduce( 00150 inBuffer.getCount(),inBuffer.getBuffer(),inoutBuffer.getBuffer() 00151 ); 00152 } 00153 00154 } // namespace Teuchos 00155 00156 #endif // TEUCHOS_REDUCTION_OP_HELPERS_HPP
1.7.4