Tpetra_DefaultPlatform.hpp

00001 // @HEADER
00002 // ***********************************************************************
00003 // 
00004 //          Tpetra: Templated Linear Algebra Services Package
00005 //                 Copyright (2004) Sandia Corporation
00006 // 
00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00008 // license for use of this work by or on behalf of the U.S. Government.
00009 // 
00010 // This library is free software; you can redistribute it and/or modify
00011 // it under the terms of the GNU Lesser General Public License as
00012 // published by the Free Software Foundation; either version 2.1 of the
00013 // License, or (at your option) any later version.
00014 //  
00015 // This library is distributed in the hope that it will be useful, but
00016 // WITHOUT ANY WARRANTY; without even the implied warranty of
00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018 // Lesser General Public License for more details.
00019 //  
00020 // You should have received a copy of the GNU Lesser General Public
00021 // License along with this library; if not, write to the Free Software
00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00023 // USA
00024 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 
00025 // 
00026 // ***********************************************************************
00027 // @HEADER
00028 
00029 #ifndef TPETRA_DEFAULT_PLATFORM_HPP
00030 #define TPETRA_DEFAULT_PLATFORM_HPP
00031 
00032 #include "Tpetra_SerialPlatform.hpp"
00033 #ifdef HAVE_MPI
00034 #  include "Tpetra_MpiPlatform.hpp"
00035 #endif
00036 
00037 namespace Tpetra {
00038 
00046 template<typename Ordinal>
00047 class DefaultPlatform {
00048 public:
00049 
00052   static Teuchos::RCP<const Platform<Ordinal> > getPlatform();
00053 
00054 private:
00055 
00056   static Teuchos::RCP<const Platform<Ordinal> > platform_;
00057 
00058 };
00059 
00060 // ///////////////////////////
00061 // Template Implementations
00062 
00063 template<typename Ordinal>
00064 Teuchos::RCP<const Platform<Ordinal> >
00065 DefaultPlatform<Ordinal>::getPlatform()
00066 {
00067   if(!platform_.get()) {
00068 #ifdef HAVE_MPI
00069     platform_ = Teuchos::rcp(new MpiPlatform<Ordinal>(Teuchos::opaqueWrapper<MPI_Comm>(MPI_COMM_WORLD)));
00070 #else // HAVE_MPI    
00071     platform_ = Teuchos::rcp(new SerialPlatform<Ordinal>());
00072 #endif // HAVE_MPI    
00073   }
00074   return platform_;
00075 }
00076 
00077 template<typename Ordinal>
00078 Teuchos::RCP<const Platform<Ordinal> >
00079 DefaultPlatform<Ordinal>::platform_ = Teuchos::null;
00080 
00081 } // namespace Tpetra
00082 
00083 #endif // TPETRA_DEFAULT_PLATFORM_HPP
00084 

Generated on Wed May 12 21:59:41 2010 for Tpetra Matrix/Vector Services by  doxygen 1.4.7