PlayaBlockIteratorDecl.hpp

00001 /* @HEADER@ */
00002 //   
00003 /* @HEADER@ */
00004 
00005 #ifndef PLAYA_BLOCKITERATORDECL_HPP
00006 #define PLAYA_BLOCKITERATORDECL_HPP
00007 
00008 #include "PlayaDefs.hpp"
00009 #include "Teuchos_Array.hpp"
00010 #include <deque> 
00011 
00012 namespace Playa
00013 {
00014 
00015 using Teuchos::RCP;
00016 using Teuchos::Array;
00017 
00018 /* Forward declare VectorSpaceBase */
00019 template <class Scalar> 
00020 class VectorSpaceBase;
00021 
00022 /* Forward declare VectorSpace */
00023 template <class Scalar> 
00024 class VectorSpace;
00025 
00026 /* Forward declare Vector */
00027 template <class Scalar> 
00028 class Vector;
00029 
00030 
00035 template <class Scalar>
00036 class BlockIterator
00037 {
00038 public:
00039 
00040   friend class VectorSpaceBase<Scalar>;
00041   friend class VectorSpace<Scalar>;
00042   friend class Vector<Scalar>;
00043 
00045   BlockIterator() : space_(),
00046                     index_(), 
00047                     atEnd_(true){}
00048 
00050   bool operator==(const BlockIterator<Scalar>& other) const ;
00051 
00053   bool operator!=(const BlockIterator<Scalar>& other) const 
00054     {
00055       return !operator==(other);
00056     }
00057 
00059   bool operator<(const BlockIterator<Scalar>& other) const ;
00060 
00062   BlockIterator<Scalar> operator++(int);
00063 
00065   const VectorSpace<Scalar>& space() const ;
00066   
00068   std::ostream& print(std::ostream& os) const ;
00069 
00071   const std::deque<int>& blockIndex() const {return index_;}
00072 
00074   bool atEnd() const {return atEnd_;}
00075 
00078   static bool& debug() 
00079     {static bool rtn = false; return rtn;}
00080 
00081 protected:
00082 
00085   void goToStart(const VectorSpace<Scalar>& space,
00086     std::deque<int>& pos) const ;
00087 
00090   BlockIterator(const VectorSpace<Scalar>& space,
00091     bool atEnd);
00092 
00095   bool advance(int level);
00096 
00097 private:
00099   RCP<const VectorSpace<Scalar> > space_;
00100   std::deque<int> index_;
00101   bool atEnd_;
00102 };
00103 
00104 }
00105 
00106 namespace Playa
00107 {
00109 template <class Scalar> inline
00110 std::ostream& operator<<(std::ostream& os, 
00111   const Playa::BlockIterator<Scalar>& i)
00112 {
00113   return i.print(os);
00114 }
00115 }
00116 
00117 
00118 #endif

doxygen