Flow123d  3.9.0-d39db4f
range_wrapper.hh
Go to the documentation of this file.
1 /*!
2  *
3  * Copyright (C) 2015 Technical University of Liberec. All rights reserved.
4  *
5  * This program is free software; you can redistribute it and/or modify it under
6  * the terms of the GNU General Public License version 3 as published by the
7  * Free Software Foundation. (http://www.gnu.org/licenses/gpl-3.0.en.html)
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12  *
13  *
14  * @file range_wrapper.hh
15  * @brief Implementation of range helper class.
16  */
17 
18 #ifndef RANGE_WRAPPER_HH_
19 #define RANGE_WRAPPER_HH_
20 
22 
23 /**
24  * @brief Range helper class.
25  *
26  * Allow iterate in bounds given by begin and end iterator. Class can be used for iterable accessor classes.
27  *
28  * Template argument:
29  * - ObjectIn Type over its instances is iterated,
30  * - ObjectOut Operators '*' and '->' returns objects of this type.
31  *
32  * Require the template object to implement:
33  * - ObjectIn must be implicitly convertible to ObjectOut type.
34  */
35 template<class ObjectIn, class ObjectOut>
37 {
38 public:
39  /// Constructor.
41  : begin_(begin), end_(end) {}
42 
43  /// Iterator to begin item of range.
45  return begin_;
46  }
47 
48  /// Iterator to end item of range.
50  return end_;
51  }
52 
53 private:
56 };
57 
58 
59 /**
60  * @brief Range helper class.
61  *
62  * Same as previous but doesn't provide specialization of operators '*' and '->'.
63  */
64 template<class Object>
65 class Range
66 {
67 public:
68  /// Constructor.
70  : begin_(begin), end_(end) {}
71 
72  /// Iterator to begin item of range.
74  return begin_;
75  }
76 
77  /// Iterator to end item of range.
79  return end_;
80  }
81 
82 private:
85 };
86 
87 
88 #endif // RANGE_WRAPPER_HH_
general_iterator.hh
Template Iter serves as general template for internal iterators.
Iter
General iterator template. Provides iterator over objects of type Object in some container.
Definition: general_iterator.hh:32
RangeConvert::end
IterConvert< ObjectIn, ObjectOut > end()
Iterator to end item of range.
Definition: range_wrapper.hh:49
Range::Range
Range(Iter< Object > begin, Iter< Object > end)
Constructor.
Definition: range_wrapper.hh:69
Range::begin_
Iter< Object > begin_
Definition: range_wrapper.hh:83
RangeConvert::end_
IterConvert< ObjectIn, ObjectOut > end_
Definition: range_wrapper.hh:55
RangeConvert::begin_
IterConvert< ObjectIn, ObjectOut > begin_
Definition: range_wrapper.hh:54
RangeConvert
Range helper class.
Definition: range_wrapper.hh:36
IterConvert
General iterator template. Provides iterator over objects of type ObjectIn in some container....
Definition: general_iterator.hh:63
RangeConvert::RangeConvert
RangeConvert(IterConvert< ObjectIn, ObjectOut > begin, IterConvert< ObjectIn, ObjectOut > end)
Constructor.
Definition: range_wrapper.hh:40
Range
Range helper class.
Definition: range_wrapper.hh:65
Range::end
Iter< Object > end()
Iterator to end item of range.
Definition: range_wrapper.hh:78
Range::end_
Iter< Object > end_
Definition: range_wrapper.hh:84
Range::begin
Iter< Object > begin()
Iterator to begin item of range.
Definition: range_wrapper.hh:73
RangeConvert::begin
IterConvert< ObjectIn, ObjectOut > begin()
Iterator to begin item of range.
Definition: range_wrapper.hh:44