EpetraExt_Transform_Composite.h

Go to the documentation of this file.
00001 // @HEADER
00002 // ***********************************************************************
00003 // 
00004 //     EpetraExt: Epetra Extended - Linear Algebra Services Package
00005 //                 Copyright (2001) 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 //-----------------------------------------------------------------------
00030 // EpetraExt_Transform_Composite.h
00031 //-----------------------------------------------------------------------
00032 
00033 #ifndef EPETRAEXT_TRANSFORM_COMPOSITE_H
00034 #define EPETRAEXT_TRANSFORM_COMPOSITE_H
00035 
00036 #include <EpetraExt_Transform.h>
00037 
00038 #include <list>
00039 
00040 namespace EpetraExt {
00041 
00043 
00046 template<typename T>
00047 class Transform_Composite : public SameTypeTransform<T>
00048 {
00049 
00050  public:
00051 
00052   typedef SameTypeTransform<T> * TransformTypePtr;
00053 
00055   Transform_Composite() {}
00056 
00058   virtual ~Transform_Composite();
00059 
00061 
00064   void addTransform( TransformTypePtr new_trans );
00065 
00067 
00074   virtual
00075   typename Transform<T,T>::NewTypeRef
00076   operator()
00077   ( typename Transform<T,T>::OriginalTypeRef orig );
00078 
00080 
00085   virtual bool fwd();
00086 
00088 
00092   virtual bool rvs();
00093 
00094  protected:
00095 
00096   typedef typename list<TransformTypePtr>::iterator         TransListIter;
00097   typedef typename list<TransformTypePtr>::reverse_iterator TransListRvsIter;
00098 
00099   list<TransformTypePtr> transList_;
00100 
00101 }; // end class Tranform_Composite
00102 
00103 template<typename T>
00104 Transform_Composite<T>::
00105 ~Transform_Composite()
00106 {
00107   TransListIter iter = transList_.begin();
00108   TransListIter end = transList_.end();
00109   for( ; iter != end; ++iter ) delete *iter;
00110 }
00111 
00112 template<typename T>
00113 void
00114 Transform_Composite<T>::
00115 addTransform( TransformTypePtr new_trans )
00116 {
00117   transList_.push_back( new_trans );
00118 }
00119 
00120 template<typename T>
00121 typename Transform<T,T>::NewTypeRef
00122 Transform_Composite<T>::
00123 operator()
00124 ( typename Transform<T,T>::OriginalTypeRef orig )
00125 {
00126   this->origObj_ = &orig;
00127   this->newObj_ = &orig;
00128 
00129   TransListIter iter = transList_.begin();
00130   TransListIter end = transList_.end();
00131   for( ; iter != end; ++iter )
00132     this->newObj_ = &((**iter)( *(this->newObj_) ));
00133 
00134   return *(this->newObj_);
00135 }
00136 
00137 template<typename T>
00138 bool
00139 Transform_Composite<T>::
00140 fwd()
00141 {
00142   bool success = true;
00143 
00144   TransListIter iter = transList_.begin();
00145   TransListIter end = transList_.end();
00146   for( ; iter != end; ++iter )
00147     if( !(**iter).fwd() ) return false;
00148 
00149   return success;
00150 }
00151 
00152 template<typename T>
00153 bool
00154 Transform_Composite<T>::
00155 rvs()
00156 {
00157   bool success = true;
00158 
00159   TransListRvsIter iter = transList_.rbegin();
00160   TransListRvsIter end = transList_.rend();
00161   for( ; iter != end; ++iter )
00162     if( !(**iter).rvs() ) return false;
00163 
00164   return success;
00165 }
00166 
00167 } //namespace EpetraExt
00168   
00169 #endif //EPETRAEXT_TRANSFORM_COMPOSITE_H

Generated on Thu Sep 18 12:31:44 2008 for EpetraExt by doxygen 1.3.9.1