Sacado_TemplateManagerImp.hpp

Go to the documentation of this file.
00001 // $Id$ 
00002 // $Source$ 
00003 // @HEADER
00004 // ***********************************************************************
00005 // 
00006 //                           Sacado Package
00007 //                 Copyright (2006) Sandia Corporation
00008 // 
00009 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
00010 // the U.S. Government retains certain rights in this software.
00011 // 
00012 // This library is free software; you can redistribute it and/or modify
00013 // it under the terms of the GNU Lesser General Public License as
00014 // published by the Free Software Foundation; either version 2.1 of the
00015 // License, or (at your option) any later version.
00016 //  
00017 // This library is distributed in the hope that it will be useful, but
00018 // WITHOUT ANY WARRANTY; without even the implied warranty of
00019 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00020 // Lesser General Public License for more details.
00021 //  
00022 // You should have received a copy of the GNU Lesser General Public
00023 // License along with this library; if not, write to the Free Software
00024 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00025 // USA
00026 // Questions? Contact David M. Gay (dmgay@sandia.gov) or Eric T. Phipps
00027 // (etphipp@sandia.gov).
00028 // 
00029 // ***********************************************************************
00030 // @HEADER
00031 
00032 template <typename TypeSeq, typename BaseT, typename ObjectT>
00033 Sacado::TemplateManager<TypeSeq,BaseT,ObjectT>::
00034 TemplateManager()
00035 {
00036   // Determine number of types
00037   int sz = mpl::size<TypeSeq>::value;
00038   objects.resize(sz);
00039 }
00040 
00041 template <typename TypeSeq, typename BaseT, typename ObjectT>
00042 Sacado::TemplateManager<TypeSeq,BaseT,ObjectT>::
00043 ~TemplateManager()
00044 {
00045 }
00046 
00047 template <typename TypeSeq, typename BaseT, typename ObjectT>
00048 template <typename BuilderOpT>
00049 void
00050 Sacado::TemplateManager<TypeSeq,BaseT,ObjectT>::
00051 buildObjects(const BuilderOpT& builder)
00052 {
00053   mpl::for_each<TypeSeq>(BuildObject<BuilderOpT>(objects,builder));
00054 }
00055 
00056 template <typename TypeSeq, typename BaseT, typename ObjectT>
00057 void
00058 Sacado::TemplateManager<TypeSeq,BaseT,ObjectT>::
00059 buildObjects()
00060 {
00061   DefaultBuilderOp builder;
00062   (*this).template buildObjects<DefaultBuilderOp>(builder);
00063 }
00064 
00065 template <typename TypeSeq, typename BaseT, typename ObjectT>
00066 template<typename ScalarT>
00067 Teuchos::RCP<BaseT>
00068 Sacado::TemplateManager<TypeSeq,BaseT,ObjectT>::
00069 getAsBase()
00070 {
00071   int idx = mpl::find<TypeSeq,ScalarT>::value;
00072   return objects[idx];
00073 }
00074 
00075 template <typename TypeSeq, typename BaseT, typename ObjectT>
00076 template<typename ScalarT>
00077 Teuchos::RCP<const BaseT>
00078 Sacado::TemplateManager<TypeSeq,BaseT,ObjectT>::getAsBase() const
00079 {
00080   int idx = mpl::find<TypeSeq,ScalarT>::value;
00081   return objects[idx];
00082 }
00083 
00084 template <typename TypeSeq, typename BaseT, typename ObjectT>
00085 template<typename ScalarT>
00086 Teuchos::RCP< typename Sacado::mpl::apply<ObjectT,ScalarT>::type >
00087 Sacado::TemplateManager<TypeSeq,BaseT,ObjectT>::
00088 getAsObject()
00089 {
00090   int idx = mpl::find<TypeSeq,ScalarT>::value;
00091   return Teuchos::rcp_dynamic_cast< typename Sacado::mpl::apply<ObjectT,ScalarT>::type >(objects[idx], true);
00092 }
00093 
00094 template <typename TypeSeq, typename BaseT, typename ObjectT>
00095 template<typename ScalarT>
00096 Teuchos::RCP< const typename Sacado::mpl::apply<ObjectT,ScalarT>::type >
00097 Sacado::TemplateManager<TypeSeq,BaseT,ObjectT>::
00098 getAsObject() const
00099 {
00100   int idx = mpl::find<TypeSeq,ScalarT>::value;
00101   return Teuchos::rcp_dynamic_cast< const typename Sacado::mpl::apply<ObjectT,ScalarT>::type >(objects[idx], true);
00102 }
00103 
00104 template <typename TypeSeq, typename BaseT, typename ObjectT>
00105 typename Sacado::TemplateManager<TypeSeq,BaseT,ObjectT>::iterator
00106 Sacado::TemplateManager<TypeSeq,BaseT,ObjectT>::
00107 begin()
00108 {
00109   return Sacado::TemplateIterator<TypeSeq,BaseT,ObjectT>(*this,
00110                                                          objects.begin());
00111 }
00112 
00113 template <typename TypeSeq, typename BaseT, typename ObjectT>
00114 typename Sacado::TemplateManager<TypeSeq,BaseT,ObjectT>::const_iterator
00115 Sacado::TemplateManager<TypeSeq,BaseT,ObjectT>::
00116 begin() const
00117 {
00118   return Sacado::ConstTemplateIterator<TypeSeq,BaseT,ObjectT>(*this,
00119                                                               objects.begin());
00120 }
00121 
00122 template <typename TypeSeq, typename BaseT, typename ObjectT>
00123 typename Sacado::TemplateManager<TypeSeq,BaseT,ObjectT>::iterator
00124 Sacado::TemplateManager<TypeSeq,BaseT,ObjectT>::
00125 end()
00126 {
00127   return Sacado::TemplateIterator<TypeSeq,BaseT,ObjectT>(*this,
00128                                                          objects.end());
00129 }
00130 
00131 template <typename TypeSeq, typename BaseT, typename ObjectT>
00132 typename Sacado::TemplateManager<TypeSeq,BaseT,ObjectT>::const_iterator
00133 Sacado::TemplateManager<TypeSeq,BaseT,ObjectT>::
00134 end() const
00135 {
00136   return Sacado::ConstTemplateIterator<TypeSeq,BaseT,ObjectT>(*this,
00137                                                               objects.end());
00138 }

Generated on Wed May 12 21:39:37 2010 for Sacado Package Browser (Single Doxygen Collection) by  doxygen 1.4.7