Thyra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Thyra_MultiVectorAllocator.hpp
1 // @HEADER
2 // *****************************************************************************
3 // Thyra: Interfaces and Support for Abstract Numerical Algorithms
4 //
5 // Copyright 2004 NTESS and the Thyra contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef THYRA_MULTI_VECTOR_ALLOCATOR_HPP
11 #define THYRA_MULTI_VECTOR_ALLOCATOR_HPP
12 
13 #include "Thyra_VectorSpaceBase.hpp"
14 #include "Teuchos_Assert.hpp"
15 
16 namespace Thyra {
17 
21 template<class Scalar>
23 public:
25  MultiVectorAllocator() : numMembers_(0) {}
29  MultiVectorAllocator( const Teuchos::RCP<const VectorSpaceBase<Scalar> > &vs, int numMembers )
30  : vs_(vs), numMembers_(numMembers)
31  {
32 #ifdef TEUCHOS_DEBUG
33  TEUCHOS_TEST_FOR_EXCEPTION( vs.get()==NULL, std::logic_error, "Error!" );
34 #endif
35  }
37  const ptr_t allocate() const { return vs_->createMembers(numMembers_); } // required!
38 private:
40  int numMembers_;
41 };
42 
43 } // namespace Thyra
44 
45 #endif // THYRA_MULTI_VECTOR_ALLOCATOR_HPP
Teuchos::RCP< MultiVectorBase< Scalar > > ptr_t
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Allocator class to be used with Teuchos::AbstractFactoryStd to create MultiVectorBase objects of a gi...
Abstract interface for objects that represent a space for vectors.
MultiVectorAllocator(const Teuchos::RCP< const VectorSpaceBase< Scalar > > &vs, int numMembers)