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>
63 public:
64 
65  // Iterator requirements
66  using iterator_category = std::input_iterator_tag;
67  using value_type = std::vector<Teuchos::RCP<BaseT>>;
68  using differnce_type = std::ptrdiff_t;
69  using pointer = value_type*;
71 
73  VectorTemplateIterator(panzer::VectorTemplateManager<TypeSeq,BaseT,ObjectT> & m,
74  typename std::vector<std::vector< Teuchos::RCP<BaseT> > >::iterator p)
75  : manager_(&m), object_iterator_(p) {}
76 
78  bool operator==(const VectorTemplateIterator& t) const
79  { return object_iterator_ == t.objectIterator_; }
80 
82  bool operator!=(const VectorTemplateIterator& t) const
83  { return object_iterator_ != t.object_iterator_; }
84 
87  operator*() const {
88  return *(object_iterator_);
89  }
90 
93  operator->() const {
94  return &(*(*object_iterator_));
95  }
96 
100  return *this;
101  }
102 
105  VectorTemplateIterator tmp = *this;
106  ++(*this);
107  return tmp;
108  }
109 
110 private:
111  panzer::VectorTemplateManager<TypeSeq,BaseT,ObjectT> * manager_;
112  typename std::vector<std::vector< Teuchos::RCP<BaseT> > >::iterator object_iterator_;
113 };
114 
115 template <typename TypeSeq, typename BaseT, typename ObjectT>
117 public:
118 
119  // Iterator requirements
120  using iterator_category = std::input_iterator_tag;
121  using value_type = const std::vector<Teuchos::RCP<BaseT>>;
122  using differnce_type = std::ptrdiff_t;
123  using pointer = value_type*;
125 
127  ConstVectorTemplateIterator(const panzer::VectorTemplateManager<TypeSeq,BaseT,ObjectT> & m,
128  typename std::vector<std::vector< Teuchos::RCP<BaseT> > >::const_iterator p)
129  : manager_(&m), object_iterator_(p) {}
130 
133  { return object_iterator_ == t.objectIterator_; }
134 
137  { return object_iterator_ != t.object_iterator_; }
138 
141  operator*() const {
142  return *(object_iterator_);
143  }
144 
147  operator->() const {
148  return &(*(*object_iterator_));
149  }
150 
154  return *this;
155  }
156 
159  ConstVectorTemplateIterator tmp = *this;
160  ++(*this);
161  return tmp;
162  }
163 
164 private:
165  const panzer::VectorTemplateManager<TypeSeq,BaseT,ObjectT> * manager_;
166  typename std::vector<std::vector< Teuchos::RCP<BaseT> > >::const_iterator object_iterator_;
167 };
168 
169 }
170 
171 #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 ++.
std::vector< Teuchos::RCP< BaseT >> value_type
const std::vector< Teuchos::RCP< BaseT >> value_type
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.