Teko  Version of the Day
 All Classes Files Functions Variables Pages
Teko_StaticRequestCallback.hpp
1 // @HEADER
2 // *****************************************************************************
3 // Teko: A package for block and physics based preconditioning
4 //
5 // Copyright 2010 NTESS and the Teko contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef __Teko_StaticRequestCallback_hpp__
11 #define __Teko_StaticRequestCallback_hpp__
12 
13 #include "Teko_RequestCallback.hpp"
14 
15 namespace Teko {
16 
27 template <typename DataT>
28 class StaticRequestCallback : public RequestCallback<DataT> {
29  public:
30  StaticRequestCallback(const std::string& name, DataT data) : name_(name), data_(data) {}
31 
32  DataT request(const RequestMesg& rm);
33  void preRequest(const RequestMesg& rm);
34  bool handlesRequest(const RequestMesg& rm);
35 
36  private:
37  std::string name_;
38  DataT data_;
39 };
40 
41 template <typename DataT>
42 DataT StaticRequestCallback<DataT>::request(const RequestMesg& rm) {
43  TEUCHOS_ASSERT(handlesRequest(rm));
44 
45  return data_;
46 }
47 
48 template <typename DataT>
49 void StaticRequestCallback<DataT>::preRequest(const RequestMesg& rm) {
50  TEUCHOS_ASSERT(handlesRequest(rm));
51 }
52 
53 template <typename DataT>
54 bool StaticRequestCallback<DataT>::handlesRequest(const RequestMesg& rm) {
55  return name_ == rm.getName();
56 }
57 
58 } // namespace Teko
59 
60 #endif
void preRequest(const RequestMesg &rm)
DataT request(const RequestMesg &rm)
bool handlesRequest(const RequestMesg &rm)