RTOp Package Browser (Single Doxygen Collection) Version of the Day
Loading...
Searching...
No Matches
RTOpPack_RTOpServer.hpp
Go to the documentation of this file.
1// @HEADER
2// ***********************************************************************
3//
4// RTOp: Interfaces and Support Software for Vector Reduction Transformation
5// Operations
6// Copyright (2006) Sandia Corporation
7//
8// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
9// license for use of this work by or on behalf of the U.S. Government.
10//
11// Redistribution and use in source and binary forms, with or without
12// modification, are permitted provided that the following conditions are
13// met:
14//
15// 1. Redistributions of source code must retain the above copyright
16// notice, this list of conditions and the following disclaimer.
17//
18// 2. Redistributions in binary form must reproduce the above copyright
19// notice, this list of conditions and the following disclaimer in the
20// documentation and/or other materials provided with the distribution.
21//
22// 3. Neither the name of the Corporation nor the names of the
23// contributors may be used to endorse or promote products derived from
24// this software without specific prior written permission.
25//
26// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37//
38// Questions? Contact Roscoe A. Bartlett (rabartl@sandia.gov)
39//
40// ***********************************************************************
41// @HEADER
42
43#ifndef RTOP_SERVER_HPP
44#define RTOP_SERVER_HPP
45
46//#include <typeinfo>
47//#include <ostream>
48//#include <iomanip>
49
51
52namespace RTOpPack {
53
54template<class Scalar>
56 const Teuchos::RCP<Teuchos::AbstractFactory<RTOpPack::RTOpT<Scalar> > > &op_factory
57 )
58{
59 // ToDo: RAB: 20030620: Validate op_factory properly!
60 op_factories_[op_factory->create()->op_name()] = op_factory;
61}
62
63template<class Scalar>
64Teuchos::RCP<Teuchos::AbstractFactory<RTOpPack::RTOpT<Scalar> > >
65RTOpServer<Scalar>::get_op_factory( const char op_name[] ) const
66{
67 typename op_factories_t::const_iterator itr = op_factories_.find(op_name);
68 TEUCHOS_TEST_FOR_EXCEPTION(
69 itr == op_factories_.end(), std::logic_error
70 ,"RTOpServer<Scalar>::get_op_factory(...): Error, an operator factory with the "
71 "operator name \'" << op_name << "\' does not exist!"
72 );
73 return itr->second;
74}
75
76template<class Scalar>
77void RTOpServer<Scalar>::print_op_factories(std::ostream& o) const
78{
79 using std::setw;
80 const int w = 30;
81 o << "\nRTOpServer<Scalar>::print_op_factories(...): RTOp operator factories currently registered\n\n" << std::left;
82 o << setw(w) << "Operator name" << "Operator type" << std::endl;
83 o << setw(w) << "-------------" << "-------------" << std::endl;
84 for( typename op_factories_t::const_iterator itr = op_factories_.begin(); itr != op_factories_.end(); ++itr ) {
85 o << setw(w) << itr->first << typeName(*itr->second->create()) << std::endl;
86 }
87 o << std::endl;
88}
89
90} // namespace RTOpPack
91
92#endif // RTOP_SERVER_HPP
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.
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.
Templated interface to vector reduction/transformation operators {abstract}.