Support Software for Vector Reduction/Transformation Operators  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
RTOpPack_RTOpServer.hpp
1 // @HEADER
2 // *****************************************************************************
3 // RTOp: Interfaces and Support Software for Vector Reduction Transformation
4 // Operations
5 //
6 // Copyright 2006 NTESS and the RTOp contributors.
7 // SPDX-License-Identifier: BSD-3-Clause
8 // *****************************************************************************
9 // @HEADER
10 
11 #ifndef RTOP_SERVER_HPP
12 #define RTOP_SERVER_HPP
13 
14 //#include <typeinfo>
15 //#include <ostream>
16 //#include <iomanip>
17 
18 #include "RTOpPack_RTOpServerDecl.hpp"
19 
20 namespace RTOpPack {
21 
22 template<class Scalar>
25  )
26 {
27  // ToDo: RAB: 20030620: Validate op_factory properly!
28  op_factories_[op_factory->create()->op_name()] = op_factory;
29 }
30 
31 template<class Scalar>
33 RTOpServer<Scalar>::get_op_factory( const char op_name[] ) const
34 {
35  typename op_factories_t::const_iterator itr = op_factories_.find(op_name);
37  itr == op_factories_.end(), std::logic_error
38  ,"RTOpServer<Scalar>::get_op_factory(...): Error, an operator factory with the "
39  "operator name \'" << op_name << "\' does not exist!"
40  );
41  return itr->second;
42 }
43 
44 template<class Scalar>
45 void RTOpServer<Scalar>::print_op_factories(std::ostream& o) const
46 {
47  using std::setw;
48  const int w = 30;
49  o << "\nRTOpServer<Scalar>::print_op_factories(...): RTOp operator factories currently registered\n\n" << std::left;
50  o << setw(w) << "Operator name" << "Operator type" << std::endl;
51  o << setw(w) << "-------------" << "-------------" << std::endl;
52  for( typename op_factories_t::const_iterator itr = op_factories_.begin(); itr != op_factories_.end(); ++itr ) {
53  o << setw(w) << itr->first << typeName(*itr->second->create()) << std::endl;
54  }
55  o << std::endl;
56 }
57 
58 } // namespace RTOpPack
59 
60 #endif // RTOP_SERVER_HPP
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Teuchos::RCP< Teuchos::AbstractFactory< RTOpPack::RTOpT< Scalar > > > get_op_factory(const char op_name[]) const
Get an operator factory given the name of the operator.
void add_op_factory(const Teuchos::RCP< Teuchos::AbstractFactory< RTOpPack::RTOpT< Scalar > > > &op_factory)
Add a new abstract factory for an RTOpT operator.
void print_op_factories(std::ostream &o) const
Print out all of the operator factories that have been added.
std::string typeName(const T &t)