00001 /* @HEADER@ */ 00002 /* *********************************************************************** 00003 // 00004 // TSFExtended: Trilinos Solver Framework Extended 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 TSFSEQUENTIALITERATORDECL_HPP 00030 #define TSFSEQUENTIALITERATORDECL_HPP 00031 00032 #include "SundanceDefs.hpp" 00033 #include "Thyra_OperatorVectorTypes.hpp" 00034 00035 namespace TSFExtended 00036 { 00037 00038 using Teuchos::RCP; 00039 00040 /* Forward declare VectorSpace */ 00041 template <class Scalar> 00042 class VectorSpace; 00043 00044 /* Forward declare Vector */ 00045 template <class Scalar> 00046 class Vector; 00047 00048 00049 /** */ 00050 template <class Scalar> 00051 class SequentialIterator 00052 { 00053 public: 00054 00055 friend class VectorSpace<Scalar>; 00056 friend class Vector<Scalar>; 00057 00058 /** */ 00059 SequentialIterator() : space_(), blockIndex_(0), indexInCurrentBlock_(0), 00060 atEnd_(true){} 00061 00062 /** */ 00063 bool operator==(const SequentialIterator<Scalar>& other) const ; 00064 00065 /** */ 00066 bool operator!=(const SequentialIterator<Scalar>& other) const 00067 { 00068 return !operator==(other); 00069 } 00070 00071 /** */ 00072 SequentialIterator<Scalar> operator++(int); 00073 00074 /** */ 00075 const VectorSpace<Scalar>& space() const ; 00076 00077 00078 /** */ 00079 std::ostream& print(std::ostream& os) const ; 00080 00081 /** */ 00082 const OrdType& globalIndex() const {return globalIndex_;} 00083 00084 private: 00085 00086 /** */ 00087 const OrdType& indexInBlock() const {return indexInCurrentBlock_;} 00088 00089 /** */ 00090 const OrdType& blockIndex() const {return blockIndex_;} 00091 00092 /** Constructor is private: the construction is always done inside 00093 * the begin and end methods of vector space. */ 00094 SequentialIterator(const VectorSpace<Scalar>& space, 00095 int blockIndex, int indexInCurrentBlock, int globalIndex); 00096 00097 /** Constructor is private: the construction is always done inside 00098 * the begin and end methods of vector space. */ 00099 SequentialIterator(const VectorSpace<Scalar>& space); 00100 00101 /* This is odd but necessary: we store the VectorSpace handle in an RCP 00102 * because we can only forward declare VectorSpace at this point. */ 00103 RCP<VectorSpace<Scalar> > space_; 00104 OrdType blockIndex_; 00105 OrdType indexInCurrentBlock_; 00106 OrdType globalIndex_; 00107 bool atEnd_; 00108 }; 00109 00110 } 00111 00112 namespace TSFExtended 00113 { 00114 template <class Scalar> inline 00115 std::ostream& operator<<(std::ostream& os, 00116 const TSFExtended::SequentialIterator<Scalar>& i) 00117 { 00118 return i.print(os); 00119 } 00120 } 00121 00122 00123 #endif