Panzer  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Panzer_VectorTemplateIterator.hpp
Go to the documentation of this file.
1 // @HEADER
2 // ***********************************************************************
3 //
4 // Panzer: A partial differential equation assembly
5 // engine for strongly coupled complex multiphysics systems
6 // Copyright (2011) Sandia Corporation
7 //
8 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9 // the U.S. Government retains certain rights in this software.
10 //
11 // Redistribution and use in source and binary forms, with or without
12 // modification, are permitted provided that the following conditions are
13 // met:
14 //
15 // 1. Redistributions of source code must retain the above copyright
16 // notice, this list of conditions and the following disclaimer.
17 //
18 // 2. Redistributions in binary form must reproduce the above copyright
19 // notice, this list of conditions and the following disclaimer in the
20 // documentation and/or other materials provided with the distribution.
21 //
22 // 3. Neither the name of the Corporation nor the names of the
23 // contributors may be used to endorse or promote products derived from
24 // this software without specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 //
38 // Questions? Contact Roger P. Pawlowski (rppawlo@sandia.gov) and
39 // Eric C. Cyr (eccyr@sandia.gov)
40 // ***********************************************************************
41 // @HEADER
42 
43 #ifndef __Panzer_VectorTemplateIterator_hpp__
44 #define __Panzer_VectorTemplateIterator_hpp__
45 
46 #include <iterator>
47 #include <vector>
48 
49 #include "Teuchos_RCP.hpp"
50 
51 namespace panzer {
52 
61 template <typename TypeSeq, typename BaseT, typename ObjectT>
62 class VectorTemplateIterator : public std::iterator<std::input_iterator_tag,
63  std::vector<Teuchos::RCP<BaseT> > > {
64 public:
66  VectorTemplateIterator(panzer::VectorTemplateManager<TypeSeq,BaseT,ObjectT> & m,
67  typename std::vector<std::vector< Teuchos::RCP<BaseT> > >::iterator p)
68  : manager_(&m), object_iterator_(p) {}
69 
71  bool operator==(const VectorTemplateIterator& t) const
72  { return object_iterator_ == t.objectIterator_; }
73 
75  bool operator!=(const VectorTemplateIterator& t) const
76  { return object_iterator_ != t.object_iterator_; }
77 
80  operator*() const {
81  return *(object_iterator_);
82  }
83 
86  operator->() const {
87  return &(*(*object_iterator_));
88  }
89 
93  return *this;
94  }
95 
98  VectorTemplateIterator tmp = *this;
99  ++(*this);
100  return tmp;
101  }
102 
103 private:
104  panzer::VectorTemplateManager<TypeSeq,BaseT,ObjectT> * manager_;
105  typename std::vector<std::vector< Teuchos::RCP<BaseT> > >::iterator object_iterator_;
106 };
107 
108 template <typename TypeSeq, typename BaseT, typename ObjectT>
109 class ConstVectorTemplateIterator : public std::iterator<std::input_iterator_tag,
110  const std::vector<Teuchos::RCP<BaseT> > > {
111 public:
113  ConstVectorTemplateIterator(const panzer::VectorTemplateManager<TypeSeq,BaseT,ObjectT> & m,
114  typename std::vector<std::vector< Teuchos::RCP<BaseT> > >::const_iterator p)
115  : manager_(&m), object_iterator_(p) {}
116 
119  { return object_iterator_ == t.objectIterator_; }
120 
123  { return object_iterator_ != t.object_iterator_; }
124 
127  operator*() const {
128  return *(object_iterator_);
129  }
130 
133  operator->() const {
134  return &(*(*object_iterator_));
135  }
136 
140  return *this;
141  }
142 
145  ConstVectorTemplateIterator tmp = *this;
146  ++(*this);
147  return tmp;
148  }
149 
150 private:
151  const panzer::VectorTemplateManager<TypeSeq,BaseT,ObjectT> * manager_;
152  typename std::vector<std::vector< Teuchos::RCP<BaseT> > >::const_iterator object_iterator_;
153 };
154 
155 }
156 
157 #endif
panzer::VectorTemplateIterator< TypeSeq, BaseT, ObjectT >::reference operator*() const
Dereference operator.
ConstVectorTemplateIterator(const panzer::VectorTemplateManager< TypeSeq, BaseT, ObjectT > &m, typename std::vector< std::vector< Teuchos::RCP< BaseT > > >::const_iterator p)
Constructor.
std::vector< std::vector< Teuchos::RCP< BaseT > > >::iterator object_iterator_
panzer::VectorTemplateManager< TypeSeq, BaseT, ObjectT > * manager_
ConstVectorTemplateIterator operator++(int)
Postfix ++.
ConstVectorTemplateIterator & operator++()
Prefix ++.
panzer::ConstVectorTemplateIterator< TypeSeq, BaseT, ObjectT >::pointer operator->() const
-&gt; operator
VectorTemplateIterator & operator++()
Prefix ++.
bool operator==(const ConstVectorTemplateIterator &t) const
Equal operator.
bool operator!=(const VectorTemplateIterator &t) const
Not equal operator.
bool operator!=(const ConstVectorTemplateIterator &t) const
Not equal operator.
const panzer::VectorTemplateManager< TypeSeq, BaseT, ObjectT > * manager_
VectorTemplateIterator(panzer::VectorTemplateManager< TypeSeq, BaseT, ObjectT > &m, typename std::vector< std::vector< Teuchos::RCP< BaseT > > >::iterator p)
Constructor.
panzer::ConstVectorTemplateIterator< TypeSeq, BaseT, ObjectT >::reference operator*() const
Dereference operator.
VectorTemplateIterator operator++(int)
Postfix ++.
panzer::VectorTemplateIterator< TypeSeq, BaseT, ObjectT >::pointer operator->() const
-&gt; operator
std::vector< std::vector< Teuchos::RCP< BaseT > > >::const_iterator object_iterator_
bool operator==(const VectorTemplateIterator &t) const
Equal operator.