Teuchos - Trilinos Tools Package
Version of the Day
Toggle main menu visibility
Loading...
Searching...
No Matches
comm
src
Teuchos_ReductionOpHelpers.hpp
1
// @HEADER
2
// ***********************************************************************
3
//
4
// Teuchos: Common Tools Package
5
// Copyright (2004) Sandia Corporation
6
//
7
// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8
// license for use of this work by or on behalf of the U.S. Government.
9
//
10
// Redistribution and use in source and binary forms, with or without
11
// modification, are permitted provided that the following conditions are
12
// met:
13
//
14
// 1. Redistributions of source code must retain the above copyright
15
// notice, this list of conditions and the following disclaimer.
16
//
17
// 2. Redistributions in binary form must reproduce the above copyright
18
// notice, this list of conditions and the following disclaimer in the
19
// documentation and/or other materials provided with the distribution.
20
//
21
// 3. Neither the name of the Corporation nor the names of the
22
// contributors may be used to endorse or promote products derived from
23
// this software without specific prior written permission.
24
//
25
// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36
//
37
// Questions? Contact Michael A. Heroux (maherou@sandia.gov)
38
//
39
// ***********************************************************************
40
// @HEADER
41
42
#ifndef TEUCHOS_REDUCTION_OP_HELPERS_HPP
43
#define TEUCHOS_REDUCTION_OP_HELPERS_HPP
44
45
#include "Teuchos_ReductionOp.hpp"
46
#include "Teuchos_SerializationTraitsHelpers.hpp"
47
#include "Teuchos_SerializerHelpers.hpp"
48
49
namespace
Teuchos
{
50
57
template
<
typename
Ordinal,
typename
T,
typename
Serializer>
58
class
CharToValueTypeReductionOpImp
:
public
ValueTypeReductionOp
<Ordinal,char>
59
{
60
public
:
62
CharToValueTypeReductionOpImp
(
63
const
RCP
<
const
ValueTypeReductionOp<Ordinal,T>
> &reductOp,
64
const
RCP<const Serializer>
& serializer
65
);
67
void
reduce
(
68
const
Ordinal charCount
69
,
const
char
charInBuffer[]
70
,
char
charInoutBuffer[]
71
)
const
;
72
private
:
73
RCP<const ValueTypeReductionOp<Ordinal,T>
> reductOp_;
74
RCP<const Serializer>
serializer_;
75
// Not defined and not to be called!
76
CharToValueTypeReductionOpImp
();
77
CharToValueTypeReductionOpImp
(
const
CharToValueTypeReductionOpImp
&);
78
CharToValueTypeReductionOpImp
& operator=(
const
CharToValueTypeReductionOpImp
&);
79
};
80
87
template
<
typename
Ordinal,
typename
T,
88
typename
Serializer
=
typename
DefaultSerializer<Ordinal,T>::DefaultSerializerType
>
89
class
CharToValueTypeReductionOp
:
90
public
CharToValueTypeReductionOpImp
<Ordinal,T,Serializer>
91
{
92
public
:
93
typedef
CharToValueTypeReductionOpImp<Ordinal,T,Serializer>
Base;
95
CharToValueTypeReductionOp
(
96
const
RCP
<
const
ValueTypeReductionOp<Ordinal,T>
> &reductOp,
97
const
RCP<const Serializer>
& serializer
98
) : Base(reductOp, serializer) {}
99
};
100
110
template
<
typename
Ordinal,
typename
T>
111
class
CharToValueTypeReductionOp
<Ordinal,T,typename
DefaultSerializer
<Ordinal,T>::DefaultSerializerType> :
112
public
CharToValueTypeReductionOpImp
<Ordinal,T,typename DefaultSerializer<Ordinal,T>::DefaultSerializerType>
113
{
114
public
:
115
typedef
DefaultSerializer<Ordinal,T>
DS;
// work around for parsing bug in gcc 4.1-4.2
116
typedef
typename
DS::DefaultSerializerType
Serializer;
117
typedef
CharToValueTypeReductionOpImp<Ordinal,T,Serializer>
Base;
119
CharToValueTypeReductionOp
(
120
const
RCP
<
const
ValueTypeReductionOp<Ordinal,T>
> &reductOp,
121
const
RCP<const Serializer>
& serializer =
DS::getDefaultSerializerRCP
()
122
) : Base(reductOp, serializer) {}
123
};
124
131
template
<
typename
Ordinal,
typename
T>
132
class
CharToReferenceTypeReductionOp
:
public
ValueTypeReductionOp
<Ordinal,char>
133
{
134
public
:
136
CharToReferenceTypeReductionOp
(
137
const
RCP
<
const
Serializer<Ordinal,T>
> &serializer
138
,
const
RCP
<
const
ReferenceTypeReductionOp<Ordinal,T>
> &reductOp
139
);
141
void
reduce
(
142
const
Ordinal charCount
143
,
const
char
charInBuffer[]
144
,
char
charInoutBuffer[]
145
)
const
;
146
private
:
147
RCP<const Serializer<Ordinal,T>
> serializer_;
148
RCP<const ReferenceTypeReductionOp<Ordinal,T>
> reductOp_;
149
// Not defined and not to be called!
150
CharToReferenceTypeReductionOp
();
151
CharToReferenceTypeReductionOp
(
const
CharToReferenceTypeReductionOp
&);
152
CharToReferenceTypeReductionOp
& operator=(
const
CharToReferenceTypeReductionOp
&);
153
};
154
155
// /////////////////////////////////////
156
// Template implementations
157
158
//
159
// CharToValueTypeReductionOpImp
160
//
161
162
template
<
typename
Ordinal,
typename
T,
typename
Serializer>
163
CharToValueTypeReductionOpImp<Ordinal,T,Serializer>::CharToValueTypeReductionOpImp
(
164
const
RCP
<
const
ValueTypeReductionOp<Ordinal,T>
> &reductOp,
165
const
RCP<const Serializer>
& serializer
166
)
167
:reductOp_(reductOp), serializer_(serializer)
168
{}
169
170
template
<
typename
Ordinal,
typename
T,
typename
Serializer>
171
void
CharToValueTypeReductionOpImp<Ordinal,T,Serializer>::reduce
(
172
const
Ordinal charCount
173
,
const
char
charInBuffer[]
174
,
char
charInoutBuffer[]
175
)
const
176
{
177
ConstValueTypeDeserializationBuffer<Ordinal,T,Serializer>
178
inBuffer(charCount,charInBuffer,serializer_);
179
ValueTypeDeserializationBuffer<Ordinal,T,Serializer>
180
inoutBuffer(charCount,charInoutBuffer,serializer_);
181
reductOp_->reduce(
182
inBuffer.getCount(),inBuffer.getBuffer(),inoutBuffer.getBuffer()
183
);
184
}
185
186
//
187
// CharToReferenceTypeReductionOp
188
//
189
190
template
<
typename
Ordinal,
typename
T>
191
CharToReferenceTypeReductionOp<Ordinal,T>::CharToReferenceTypeReductionOp
(
192
const
RCP
<
const
Serializer<Ordinal,T>
> &serializer
193
,
const
RCP
<
const
ReferenceTypeReductionOp<Ordinal,T>
> &reductOp
194
)
195
:serializer_(serializer), reductOp_(reductOp)
196
{}
197
198
template
<
typename
Ordinal,
typename
T>
199
void
CharToReferenceTypeReductionOp<Ordinal,T>::reduce
(
200
const
Ordinal charCount
201
,
const
char
charInBuffer[]
202
,
char
charInoutBuffer[]
203
)
const
204
{
205
ConstReferenceTypeDeserializationBuffer<Ordinal,T>
206
inBuffer(*serializer_,charCount,charInBuffer);
207
ReferenceTypeDeserializationBuffer<Ordinal,T>
208
inoutBuffer(*serializer_,charCount,charInoutBuffer);
209
reductOp_->reduce(
210
inBuffer.
getCount
(),inBuffer.
getBuffer
(),inoutBuffer.
getBuffer
()
211
);
212
}
213
214
}
// namespace Teuchos
215
216
#endif
// TEUCHOS_REDUCTION_OP_HELPERS_HPP
Teuchos::CharToReferenceTypeReductionOp::CharToReferenceTypeReductionOp
CharToReferenceTypeReductionOp(const RCP< const Serializer< Ordinal, T > > &serializer, const RCP< const ReferenceTypeReductionOp< Ordinal, T > > &reductOp)
Definition
Teuchos_ReductionOpHelpers.hpp:191
Teuchos::CharToReferenceTypeReductionOp::reduce
void reduce(const Ordinal charCount, const char charInBuffer[], char charInoutBuffer[]) const
Definition
Teuchos_ReductionOpHelpers.hpp:199
Teuchos::CharToValueTypeReductionOpImp::reduce
void reduce(const Ordinal charCount, const char charInBuffer[], char charInoutBuffer[]) const
Definition
Teuchos_ReductionOpHelpers.hpp:171
Teuchos::CharToValueTypeReductionOpImp::CharToValueTypeReductionOpImp
CharToValueTypeReductionOpImp(const RCP< const ValueTypeReductionOp< Ordinal, T > > &reductOp, const RCP< const Serializer > &serializer)
Definition
Teuchos_ReductionOpHelpers.hpp:163
Teuchos::CharToValueTypeReductionOp< Ordinal, T, typename DefaultSerializer< Ordinal, T >::DefaultSerializerType >::CharToValueTypeReductionOp
CharToValueTypeReductionOp(const RCP< const ValueTypeReductionOp< Ordinal, T > > &reductOp, const RCP< const Serializer > &serializer=DS::getDefaultSerializerRCP())
Definition
Teuchos_ReductionOpHelpers.hpp:119
Teuchos::CharToValueTypeReductionOp::CharToValueTypeReductionOp
CharToValueTypeReductionOp(const RCP< const ValueTypeReductionOp< Ordinal, T > > &reductOp, const RCP< const Serializer > &serializer)
Definition
Teuchos_ReductionOpHelpers.hpp:95
Teuchos::ConstReferenceTypeDeserializationBuffer
Encapsulate how an array of onst objects with reference sematics is deserialized from a char[] array ...
Definition
Teuchos_SerializerHelpers.hpp:150
Teuchos::ConstReferenceTypeDeserializationBuffer::getBuffer
const T *const * getBuffer() const
Definition
Teuchos_SerializerHelpers.hpp:340
Teuchos::ConstReferenceTypeDeserializationBuffer::getCount
Ordinal getCount() const
Definition
Teuchos_SerializerHelpers.hpp:346
Teuchos::ConstValueTypeDeserializationBuffer
Encapsulate how an array of non-const serialized objects with value sematics stored in a char[] array...
Definition
Teuchos_SerializationTraitsHelpers.hpp:466
Teuchos::DefaultSerializer
A class for instantiating a default serialization object.
Definition
Teuchos_SerializationTraitsHelpers.hpp:70
Teuchos::DefaultSerializer::DefaultSerializerType
SerializationTraits< Ordinal, T > DefaultSerializerType
Typename of default serializer.
Definition
Teuchos_SerializationTraitsHelpers.hpp:73
Teuchos::DefaultSerializer::getDefaultSerializerRCP
static Teuchos::RCP< DefaultSerializerType > getDefaultSerializerRCP()
Return an RCP of an instance of the default serializer.
Definition
Teuchos_SerializationTraitsHelpers.hpp:82
Teuchos::RCP
Smart reference counting pointer class for automatic garbage collection.
Definition
Teuchos_RCPDecl.hpp:429
Teuchos::ReferenceTypeDeserializationBuffer
Encapsulate how an array of non-const objects with reference sematics is deserialized from a char[] a...
Definition
Teuchos_SerializerHelpers.hpp:116
Teuchos::ReferenceTypeDeserializationBuffer::getBuffer
T *const * getBuffer() const
Definition
Teuchos_SerializerHelpers.hpp:292
Teuchos::ReferenceTypeReductionOp
Base interface class for user-defined reduction operations for objects that use reference semantics.
Definition
Teuchos_ReductionOp.hpp:80
Teuchos::Serializer
Strategy interface for the indirect serializing and deserializing objects of a given type handled usi...
Definition
Teuchos_Serializer.hpp:57
Teuchos::ValueTypeDeserializationBuffer
Encapsulate how an array of non-const serialized objects with value sematics stored in a char[] array...
Definition
Teuchos_SerializationTraitsHelpers.hpp:449
Teuchos::ValueTypeReductionOp
Base interface class for user-defined reduction operations for objects that use value semantics.
Definition
Teuchos_ReductionOp.hpp:60
Teuchos
The Teuchos namespace contains all of the classes, structs and enums used by Teuchos,...
Generated by
1.17.0