Sacado_TemplateManagerImp.hpp

Go to the documentation of this file.
00001 // $Id: Sacado_TemplateManagerImp.hpp,v 1.2 2007/07/09 17:04:03 etphipp Exp $ 
00002 // $Source: /space/CVS/Trilinos/packages/sacado/src/template/Sacado_TemplateManagerImp.hpp,v $ 
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, template<typename> class 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, template<typename> class ObjectT>
00042 Sacado::TemplateManager<TypeSeq,BaseT,ObjectT>::
00043 ~TemplateManager()
00044 {
00045 }
00046 
00047 template <typename TypeSeq, typename BaseT, template<typename> class 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, template<typename> class 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, template<typename> class 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, template<typename> class 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, template<typename> class ObjectT>
00085 template<typename ScalarT>
00086 Teuchos::RCP< ObjectT<ScalarT> >
00087 Sacado::TemplateManager<TypeSeq,BaseT,ObjectT>::
00088 getAsObject()
00089 {
00090   int idx = mpl::find<TypeSeq,ScalarT>::value;
00091   return Teuchos::rcp_dynamic_cast< ObjectT<ScalarT> >(objects[idx], true);
00092 }
00093 
00094 template <typename TypeSeq, typename BaseT, template<typename> class ObjectT>
00095 template<typename ScalarT>
00096 Teuchos::RCP< const ObjectT<ScalarT> >
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 ObjectT<ScalarT> >(objects[idx], 
00102                    true);
00103 }
00104 
00105 template <typename TypeSeq, typename BaseT, template<typename> class ObjectT>
00106 typename Sacado::TemplateManager<TypeSeq,BaseT,ObjectT>::iterator
00107 Sacado::TemplateManager<TypeSeq,BaseT,ObjectT>::
00108 begin()
00109 {
00110   return Sacado::TemplateIterator<TypeSeq,BaseT,ObjectT>(*this,
00111                objects.begin());
00112 }
00113 
00114 template <typename TypeSeq, typename BaseT, template<typename> class ObjectT>
00115 typename Sacado::TemplateManager<TypeSeq,BaseT,ObjectT>::const_iterator
00116 Sacado::TemplateManager<TypeSeq,BaseT,ObjectT>::
00117 begin() const
00118 {
00119   return Sacado::ConstTemplateIterator<TypeSeq,BaseT,ObjectT>(*this,
00120                     objects.begin());
00121 }
00122 
00123 template <typename TypeSeq, typename BaseT, template<typename> class ObjectT>
00124 typename Sacado::TemplateManager<TypeSeq,BaseT,ObjectT>::iterator
00125 Sacado::TemplateManager<TypeSeq,BaseT,ObjectT>::
00126 end()
00127 {
00128   return Sacado::TemplateIterator<TypeSeq,BaseT,ObjectT>(*this,
00129                objects.end());
00130 }
00131 
00132 template <typename TypeSeq, typename BaseT, template<typename> class ObjectT>
00133 typename Sacado::TemplateManager<TypeSeq,BaseT,ObjectT>::const_iterator
00134 Sacado::TemplateManager<TypeSeq,BaseT,ObjectT>::
00135 end() const
00136 {
00137   return Sacado::ConstTemplateIterator<TypeSeq,BaseT,ObjectT>(*this,
00138                     objects.end());
00139 }

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