Teko  Version of the Day
 All Classes Files Functions Variables Pages
Teko_RequestMesg.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_RequestMesg_hpp__
11 #define __Teko_RequestMesg_hpp__
12 
13 #include <string>
14 #include <iostream>
15 
16 #include "Teuchos_RCP.hpp"
17 #include "Teuchos_ParameterList.hpp"
18 
19 namespace Teko {
20 
21 class RequestMesg {
22  public:
30  explicit RequestMesg(const std::string& name, unsigned int tag = 0) : name_(name), tag_(tag) {}
31 
38  explicit RequestMesg(const Teuchos::RCP<const Teuchos::ParameterList>& pl) : paramList_(pl) {
39  fromParameterList(*paramList_);
40  }
41 
43  virtual ~RequestMesg() {}
44 
46  std::string getName() const { return name_; }
47 
49  unsigned int getTag() const { return tag_; }
50 
52  const Teuchos::RCP<const Teuchos::ParameterList> getParameterList() const {
53  return paramList_.getConst();
54  }
55 
56  protected:
57  void fromParameterList(const Teuchos::ParameterList& pl) {
58  name_ = "Parameter List";
59  tag_ = 0;
60  if (pl.isParameter("Name")) name_ = pl.get<std::string>("Name");
61  if (pl.isParameter("Tag")) tag_ = pl.get<unsigned int>("Tag");
62  }
63 
64  std::string name_;
65  unsigned int tag_;
66  Teuchos::RCP<const Teuchos::ParameterList> paramList_;
67 };
68 
69 // simple stream interface for RequestMesg
70 inline std::ostream& operator<<(std::ostream& os, const Teko::RequestMesg& rm) {
71  os << "RequestMesg <"
72  << "name = \"" << rm.getName() << "\", "
73  << "tag = " << rm.getTag() << ">";
74 
75  return os;
76 }
77 
78 } // end namespace Teko
79 
80 #endif