source: src/grid/grid_iterator_set.hpp@ 6f05224

Last change on this file since 6f05224 was dfed1c, checked in by Julian Iseringhausen <isering@…>, 14 years ago

Major vmg update.

git-svn-id: https://svn.version.fz-juelich.de/scafacos/trunk@1136 5161e1c8-67bf-11de-9fd5-51895aff932f

  • Property mode set to 100644
File size: 1.7 KB
Line 
1/**
2 * @file grid_iterator_set.hpp
3 * @author Julian Iseringhausen <isering@ins.uni-bonn.de>
4 * @date Thu May 12 16:22:02 2011
5 *
6 * @brief Classes that group grid iterators usefully.
7 *
8 */
9
10#ifndef GRID_ITERATOR_SET_HPP_
11#define GRID_ITERATOR_SET_HPP_
12
13#include "base/index.hpp"
14#include "base/object.hpp"
15#include "grid/grid_iterator.hpp"
16
17namespace VMG
18{
19
20class GridIteratorSet : public Object
21{
22public:
23 GridIteratorSet()
24 {}
25
26 GridIteratorSet(const GridIteratorSet& rhs) :
27 begin(rhs.begin)
28 {}
29
30 GridIteratorSet(const Index& begin, const Index& end)
31 {
32 SetBounds(begin, end);
33 }
34
35 virtual ~GridIteratorSet()
36 {}
37
38 const GridIterator& Begin() const {return begin;}
39 static int End() {return end;}
40
41 void SetBounds(const Index& begin_, const Index& end_)
42 {
43 if ((end_ - begin_).Product() > 0)
44 begin = GridIterator(begin_, begin_, end_);
45 else
46 begin = GridIterator(-1, begin_, end_);
47 }
48
49private:
50 GridIterator begin;
51 static const int end = -1;
52};
53
54class GridIteratorSet3
55{
56public:
57 GridIteratorSet3()
58 {}
59
60 GridIteratorSet3(const GridIteratorSet3& rhs)
61 {
62 for (int i=0; i<3; ++i)
63 this->iterators[i] = rhs.iterators[i];
64 }
65
66 GridIteratorSet& operator[](const int& index) {return iterators[index];}
67 const GridIteratorSet& operator[](const int& index) const {return iterators[index];}
68
69 GridIteratorSet& X() {return iterators[0];}
70 GridIteratorSet& Y() {return iterators[1];}
71 GridIteratorSet& Z() {return iterators[2];}
72
73 const GridIteratorSet& X() const {return iterators[0];}
74 const GridIteratorSet& Y() const {return iterators[1];}
75 const GridIteratorSet& Z() const {return iterators[2];}
76
77private:
78 GridIteratorSet iterators[3];
79};
80
81}
82
83#endif /* GRID_ITERATOR_SET_HPP_ */
Note: See TracBrowser for help on using the repository browser.