SCIRun  5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FieldVIndex.h
Go to the documentation of this file.
1 /*
2  For more information, please see: http://software.sci.utah.edu
3 
4  The MIT License
5 
6  Copyright (c) 2009 Scientific Computing and Imaging Institute,
7  University of Utah.
8 
9 
10  Permission is hereby granted, free of charge, to any person obtaining a
11  copy of this software and associated documentation files (the "Software"),
12  to deal in the Software without restriction, including without limitation
13  the rights to use, copy, modify, merge, publish, distribute, sublicense,
14  and/or sell copies of the Software, and to permit persons to whom the
15  Software is furnished to do so, subject to the following conditions:
16 
17  The above copyright notice and this permission notice shall be included
18  in all copies or substantial portions of the Software.
19 
20  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26  DEALINGS IN THE SOFTWARE.
27 */
28 
29 #ifndef CORE_DATATYPES_FIELDVINDEX_H
30 #define CORE_DATATYPES_FIELDVINDEX_H 1
31 
32 
35 
36 namespace SCIRun {
37 
38 /// Base type for index types.
39 template <class T>
41 public:
42  typedef T value_type;
43 
45  index_(i) {}
46 
47  /// Required interface for an Index.
48  operator T const &() const { return index_; }
49 
50  inline FieldVIndexBase<T> operator+(const int) const;
51  inline FieldVIndexBase<T> operator+(const long long) const;
52  inline FieldVIndexBase<T> operator+(const FieldVIndexBase<T>&) const;
53  inline FieldVIndexBase<T> operator-(const int) const;
54  inline FieldVIndexBase<T> operator-(const long long) const;
55  inline FieldVIndexBase<T> operator-(const FieldVIndexBase<T>&) const;
57  inline void operator++(int);
59  inline void operator--(int);
60  inline FieldVIndexBase<T>& operator+=(const int);
61  inline FieldVIndexBase<T>& operator+=(const long long);
63  inline FieldVIndexBase<T>& operator-=(const int);
64  inline FieldVIndexBase<T>& operator-=(const long long);
66 
67  T index_;
68 };
69 
70 template<class T>
72 {
73  return (FieldVIndexBase<T>(index_+i));
74 }
75 
76 template<class T>
77 inline FieldVIndexBase<T> FieldVIndexBase<T>::operator+(const long long i) const
78 {
79  return (FieldVIndexBase<T>(index_+i));
80 }
81 
82 
83 template<class T>
85 {
86  return (FieldVIndexBase<T>(index_+i.index_));
87 }
88 
89 template<class T>
91 {
92  return (FieldVIndexBase<T>(index_-i));
93 }
94 
95 template<class T>
96 inline FieldVIndexBase<T> FieldVIndexBase<T>::operator-(const long long i) const
97 {
98  return (FieldVIndexBase<T>(index_-i));
99 }
100 
101 template<class T>
103 {
104  return (FieldVIndexBase<T>(index_-i.index_));
105 }
106 
107 template<class T>
109 {
110  index_ += static_cast<T>(i);
111  return *this;
112 }
113 
114 template<class T>
116 {
117  index_ += static_cast<T>(i);
118  return *this;
119 }
120 
121 
122 template<class T>
124 {
125  index_++;
126  return *this;
127 }
128 
129 template<class T>
131 {
132  index_++;
133 }
134 
135 
136 template<class T>
138 {
139  index_--;
140  return *this;
141 }
142 
143 template<class T>
145 {
146  index_--;
147 }
148 
149 template<class T>
151 {
152  index_ += i.index_;
153  return (*this);
154 }
155 
156 template<class T>
158 {
159  index_ -= static_cast<T>(i);
160  return (*this);
161 }
162 
163 template<class T>
165 {
166  index_ -= static_cast<T>(i);
167  return (*this);
168 }
169 
170 
171 template<class T>
173 {
174  index_ -= i.index_;
175  return (*this);
176 }
177 
178 
179 /// Distinct type for node index.
180 template <class T>
181 struct VNodeIndex : public FieldVIndexBase<T> {
183  FieldVIndexBase<T>(0) {}
184  VNodeIndex(T index) :
185  FieldVIndexBase<T>(index) {}
186 };
187 
188 /// Distinct type for additional lagrangian node.
189 template <class T>
190 struct VENodeIndex : public FieldVIndexBase<T> {
192  FieldVIndexBase<T>(0) {}
193  VENodeIndex(T index) :
194  FieldVIndexBase<T>(index) {}
195 };
196 
197 
198 /// Distinct type for edge index.
199 template <class T>
200 struct VEdgeIndex : public FieldVIndexBase<T> {
202  FieldVIndexBase<T>(0) {}
203  VEdgeIndex(T index) :
204  FieldVIndexBase<T>(index) {}
205 };
206 
207 
208 /// Distinct type for face index.
209 template <class T>
210 struct VFaceIndex : public FieldVIndexBase<T> {
212  FieldVIndexBase<T>(0) {}
213  VFaceIndex(T index) :
214  FieldVIndexBase<T>(index) {}
215 };
216 
217 /// Distinct type for cell index.
218 template <class T>
219 struct VCellIndex : public FieldVIndexBase<T> {
221  FieldVIndexBase<T>(0) {}
222  VCellIndex(T index) :
223  FieldVIndexBase<T>(index) {}
224 };
225 
226 /// Distinct type for elem index.
227 template <class T>
228 struct VElemIndex : public FieldVIndexBase<T> {
230  FieldVIndexBase<T>(0) {}
231  VElemIndex(T index) :
232  FieldVIndexBase<T>(index) {}
233 };
234 
235 /// Distinct type for elem index.
236 template <class T>
237 struct VDElemIndex : public FieldVIndexBase<T> {
239  FieldVIndexBase<T>(0) {}
240  VDElemIndex(T index) :
241  FieldVIndexBase<T>(index) {}
242 };
243 
244 
245 } // end namespace SCIRun
246 
247 #endif
248 
Distinct type for elem index.
Definition: FieldVIndex.h:228
specializations of template&lt;class T&gt; find_type_name() function for build-in and simple types not deri...
VENodeIndex()
Definition: FieldVIndex.h:191
FieldVIndexBase< T > & operator-=(const int)
Definition: FieldVIndex.h:157
VFaceIndex()
Definition: FieldVIndex.h:211
bool index_(ArrayMathProgramCode &pc)
Definition: ArrayMathFunctionSourceSink.cc:636
VNodeIndex(T index)
Definition: FieldVIndex.h:184
VEdgeIndex()
Definition: FieldVIndex.h:201
VEdgeIndex(T index)
Definition: FieldVIndex.h:203
Distinct type for face index.
Definition: FieldVIndex.h:210
VElemIndex(T index)
Definition: FieldVIndex.h:231
T value_type
Definition: FieldVIndex.h:42
Distinct type for edge index.
Definition: FieldVIndex.h:200
Distinct type for elem index.
Definition: FieldVIndex.h:237
FieldVIndexBase< T > operator-(const int) const
Definition: FieldVIndex.h:90
VDElemIndex()
Definition: FieldVIndex.h:238
VElemIndex()
Definition: FieldVIndex.h:229
Distinct type for node index.
Definition: FieldVIndex.h:181
FieldVIndexBase(T i)
Definition: FieldVIndex.h:44
VCellIndex(T index)
Definition: FieldVIndex.h:222
VFaceIndex(T index)
Definition: FieldVIndex.h:213
VNodeIndex()
Definition: FieldVIndex.h:182
Distinct type for additional lagrangian node.
Definition: FieldVIndex.h:190
FieldVIndexBase< T > operator+(const int) const
Definition: FieldVIndex.h:71
Base type for index types.
Definition: FieldVIndex.h:40
VENodeIndex(T index)
Definition: FieldVIndex.h:193
VCellIndex()
Definition: FieldVIndex.h:220
T index_
Definition: FieldVIndex.h:67
FieldVIndexBase< T > & operator++()
Definition: FieldVIndex.h:123
FieldVIndexBase< T > & operator+=(const int)
Definition: FieldVIndex.h:108
Distinct type for cell index.
Definition: FieldVIndex.h:219
VDElemIndex(T index)
Definition: FieldVIndex.h:240
FieldVIndexBase< T > & operator--()
Definition: FieldVIndex.h:137