Teuchos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Teuchos_ReductionOpHelpers.hpp
Go to the documentation of this file.
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"
16 
17 namespace Teuchos {
18 
25 template<typename Ordinal, typename T, typename Serializer>
27 {
28 public:
31  const RCP<const ValueTypeReductionOp<Ordinal,T> > &reductOp,
32  const RCP<const Serializer>& serializer
33  );
35  void reduce(
36  const Ordinal charCount
37  ,const char charInBuffer[]
38  ,char charInoutBuffer[]
39  ) const;
40 private:
43  // Not defined and not to be called!
47 };
48 
55 template<typename Ordinal, typename T,
58  public CharToValueTypeReductionOpImp<Ordinal,T,Serializer>
59 {
60 public:
64  const RCP<const ValueTypeReductionOp<Ordinal,T> > &reductOp,
65  const RCP<const Serializer>& serializer
66  ) : Base(reductOp, serializer) {}
67 };
68 
78 template<typename Ordinal, typename T>
79 class CharToValueTypeReductionOp<Ordinal,T,typename DefaultSerializer<Ordinal,T>::DefaultSerializerType> :
80  public CharToValueTypeReductionOpImp<Ordinal,T,typename DefaultSerializer<Ordinal,T>::DefaultSerializerType>
81 {
82 public:
83  typedef DefaultSerializer<Ordinal,T> DS; // work around for parsing bug in gcc 4.1-4.2
88  const RCP<const ValueTypeReductionOp<Ordinal,T> > &reductOp,
89  const RCP<const Serializer>& serializer = DS::getDefaultSerializerRCP()
90  ) : Base(reductOp, serializer) {}
91 };
92 
99 template<typename Ordinal, typename T>
101 {
102 public:
105  const RCP<const Serializer<Ordinal,T> > &serializer
106  ,const RCP<const ReferenceTypeReductionOp<Ordinal,T> > &reductOp
107  );
109  void reduce(
110  const Ordinal charCount
111  ,const char charInBuffer[]
112  ,char charInoutBuffer[]
113  ) const;
114 private:
117  // Not defined and not to be called!
121 };
122 
123 // /////////////////////////////////////
124 // Template implementations
125 
126 //
127 // CharToValueTypeReductionOpImp
128 //
129 
130 template<typename Ordinal, typename T, typename Serializer>
132  const RCP<const ValueTypeReductionOp<Ordinal,T> > &reductOp,
133  const RCP<const Serializer>& serializer
134  )
135  :reductOp_(reductOp), serializer_(serializer)
136 {}
137 
138 template<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_);
148  inoutBuffer(charCount,charInoutBuffer,serializer_);
149  reductOp_->reduce(
150  inBuffer.getCount(),inBuffer.getBuffer(),inoutBuffer.getBuffer()
151  );
152 }
153 
154 //
155 // CharToReferenceTypeReductionOp
156 //
157 
158 template<typename Ordinal, typename T>
160  const RCP<const Serializer<Ordinal,T> > &serializer
161  ,const RCP<const ReferenceTypeReductionOp<Ordinal,T> > &reductOp
162  )
163  :serializer_(serializer), reductOp_(reductOp)
164 {}
165 
166 template<typename Ordinal, typename T>
168  const Ordinal charCount
169  ,const char charInBuffer[]
170  ,char charInoutBuffer[]
171  ) const
172 {
174  inBuffer(*serializer_,charCount,charInBuffer);
176  inoutBuffer(*serializer_,charCount,charInoutBuffer);
177  reductOp_->reduce(
178  inBuffer.getCount(),inBuffer.getBuffer(),inoutBuffer.getBuffer()
179  );
180 }
181 
182 } // namespace Teuchos
183 
184 #endif // TEUCHOS_REDUCTION_OP_HELPERS_HPP
A class for instantiating a default serialization object.
Strategy interface for the indirect serializing and deserializing objects of a given type handled usi...
void reduce(const Ordinal charCount, const char charInBuffer[], char charInoutBuffer[]) const
Encapsulate how an array of non-const objects with reference sematics is deserialized from a char[] a...
CharToValueTypeReductionOp(const RCP< const ValueTypeReductionOp< Ordinal, T > > &reductOp, const RCP< const Serializer > &serializer)
Encapsulate how an array of onst objects with reference sematics is deserialized from a char[] array ...
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 ...
CharToValueTypeReductionOpImp & operator=(const CharToValueTypeReductionOpImp &)
Base interface class for user-defined reduction operations for objects that use value semantics...
RCP< const ReferenceTypeReductionOp< Ordinal, T > > reductOp_
Decorator class that uses a strategy object to convert to and from char[] to typed buffers for object...
RCP< const ValueTypeReductionOp< Ordinal, T > > reductOp_
RCP< const Serializer< Ordinal, T > > serializer_
CharToValueTypeReductionOp(const RCP< const ValueTypeReductionOp< Ordinal, T > > &reductOp, const RCP< const Serializer > &serializer=DS::getDefaultSerializerRCP())
Serialization traits class for types T that use value semantics.
Base interface class for user-defined reduction operations for objects that use reference semantics...
CharToValueTypeReductionOpImp< Ordinal, T, Serializer > Base
CharToReferenceTypeReductionOp & operator=(const CharToReferenceTypeReductionOp &)
Smart reference counting pointer class for automatic garbage collection.
Encapsulate how an array of non-const serialized objects with value sematics stored in a char[] array...
Encapsulate how an array of non-const serialized objects with value sematics stored in a char[] array...
Decorator class that uses traits to convert to and from char[] to typed buffers for objects that use ...