Teuchos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PackageA.cpp
Go to the documentation of this file.
1 #include "PackageA.hpp"
2 
3 namespace A {
4 
5  // Creating an instance of this "object" registers A::FactoryA<MV,
6  // OP> with the central registry of packages' factories. That lets
7  // getLinearSolver create solvers from package A.
8  template<class MV, class OP, class NormType>
10  public:
12 #ifdef HAVE_TEUCHOSCORE_CXX11
13  typedef std::shared_ptr<Trilinos::Details::LinearSolverFactory<MV, OP, NormType> > ptr_type;
14 #else
16 #endif // HAVE_TEUCHOSCORE_CXX11
17 
18  ptr_type factory (new FactoryA<MV, OP, NormType> ());
19  Trilinos::Details::registerLinearSolverFactory<MV, OP, NormType> ("A", factory);
20  }
21  };
22 
23 } // namespace A
24 
25 namespace { // (anonymous)
26 
27  // For each triple of types (MV, OP, NormType) of interest, register
28  // A::FactoryA<MV, OP, NormType>. We use MV =
29  // Common::MultiVector<Scalar> and OP = Common::Operator<Scalar>
30  // here, for various Scalar types. NormType = Scalar simulates the
31  // case where Scalar is real (not complex).
32  //
33  // This is a stub of what you likely will want to do with Tpetra and
34  // its downstream solver packages. See the public documentation of
35  // Trilinos::Details::LinearSolverFactory for details.
36  //
37  // The ## operator in a macro appends two things. For example, with
38  // INSTMACRO( float ), registerer_##SCALAR becomes registerer_float.
39  // This ensures that the different instances of RegisterFactoryA
40  // have different names.
41 
42 #define INSTMACRO( SCALAR ) \
43  A::RegisterFactoryA< Common::MultiVector< SCALAR >, Common::Operator< SCALAR >, SCALAR > registerer_##SCALAR;
44 
45  //A::RegisterFactoryA< Common::MultiVector<double>, Common::Operator<double>, double > registerer_double;
46  INSTMACRO( double )
47 
48  //A::RegisterFactoryA< Common::MultiVector<float>, Common::Operator<float>, float > registerer_float;
49  INSTMACRO( float )
50 
51 } // namespace (anonymous)
#define INSTMACRO(SCALAR)
Definition: PackageA.cpp:42
Smart reference counting pointer class for automatic garbage collection.