Teuchos - Trilinos Tools Package Version of the Day
Loading...
Searching...
No Matches
Teuchos_ReductionOpHelpers.hpp
1// @HEADER
2// *****************************************************************************
3// Teuchos: Common Tools Package
4//
5// Copyright 2004 NTESS and the Teuchos contributors.
6// SPDX-License-Identifier: BSD-3-Clause
7// *****************************************************************************
8// @HEADER
9
10#ifndef TEUCHOS_REDUCTION_OP_HELPERS_HPP
11#define TEUCHOS_REDUCTION_OP_HELPERS_HPP
12
13#include "Teuchos_ReductionOp.hpp"
14#include "Teuchos_SerializationTraitsHelpers.hpp"
15#include "Teuchos_SerializerHelpers.hpp"
16
17namespace Teuchos {
18
25template<typename Ordinal, typename T, typename Serializer>
27{
28public:
33 );
35 void reduce(
36 const Ordinal charCount
37 ,const char charInBuffer[]
38 ,char charInoutBuffer[]
39 ) const;
40private:
42 RCP<const Serializer> serializer_;
43 // Not defined and not to be called!
47};
48
55template<typename Ordinal, typename T,
68
78template<typename Ordinal, typename T>
79class CharToValueTypeReductionOp<Ordinal,T,typename DefaultSerializer<Ordinal,T>::DefaultSerializerType> :
80 public CharToValueTypeReductionOpImp<Ordinal,T,typename DefaultSerializer<Ordinal,T>::DefaultSerializerType>
81{
82public:
83 typedef DefaultSerializer<Ordinal,T> DS; // work around for parsing bug in gcc 4.1-4.2
84 typedef typename DS::DefaultSerializerType Serializer;
89 const RCP<const Serializer>& serializer = DS::getDefaultSerializerRCP()
90 ) : Base(reductOp, serializer) {}
91};
92
99template<typename Ordinal, typename T>
101{
102public:
107 );
109 void reduce(
110 const Ordinal charCount
111 ,const char charInBuffer[]
112 ,char charInoutBuffer[]
113 ) const;
114private:
117 // Not defined and not to be called!
121};
122
123// /////////////////////////////////////
124// Template implementations
125
126//
127// CharToValueTypeReductionOpImp
128//
129
130template<typename Ordinal, typename T, typename Serializer>
137
138template<typename Ordinal, typename T, typename Serializer>
140 const Ordinal charCount
141 ,const char charInBuffer[]
142 ,char charInoutBuffer[]
143 ) const
144{
146 inBuffer(charCount,charInBuffer,serializer_);
149 reductOp_->reduce(
150 inBuffer.getCount(),inBuffer.getBuffer(),inoutBuffer.getBuffer()
151 );
152}
153
154//
155// CharToReferenceTypeReductionOp
156//
157
158template<typename Ordinal, typename T>
165
166template<typename Ordinal, typename T>
168 const Ordinal charCount
169 ,const char charInBuffer[]
170 ,char charInoutBuffer[]
171 ) const
172{
174 inBuffer(*serializer_,charCount,charInBuffer);
177 reductOp_->reduce(
178 inBuffer.getCount(),inBuffer.getBuffer(),inoutBuffer.getBuffer()
179 );
180}
181
182} // namespace Teuchos
183
184#endif // TEUCHOS_REDUCTION_OP_HELPERS_HPP
Decorator class that uses a strategy object to convert to and from char[] to typed buffers for object...
void reduce(const Ordinal charCount, const char charInBuffer[], char charInoutBuffer[]) const
Decorator class that uses traits to convert to and from char[] to typed buffers for objects that use ...
void reduce(const Ordinal charCount, const char charInBuffer[], char charInoutBuffer[]) const
CharToValueTypeReductionOpImp(const RCP< const ValueTypeReductionOp< Ordinal, T > > &reductOp, const RCP< const Serializer > &serializer)
CharToValueTypeReductionOp(const RCP< const ValueTypeReductionOp< Ordinal, T > > &reductOp, const RCP< const Serializer > &serializer=DS::getDefaultSerializerRCP())
Decorator class that uses traits to convert to and from char[] to typed buffers for objects that use ...
CharToValueTypeReductionOp(const RCP< const ValueTypeReductionOp< Ordinal, T > > &reductOp, const RCP< const Serializer > &serializer)
A class for instantiating a default serialization object.
Smart reference counting pointer class for automatic garbage collection.
Strategy interface for the indirect serializing and deserializing objects of a given type handled usi...
Base interface class for user-defined reduction operations for objects that use value semantics.
The Teuchos namespace contains all of the classes, structs and enums used by Teuchos,...