BALL  1.4.79
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
baseIterator.h
Go to the documentation of this file.
1 // -*- Mode: C++; tab-width: 2; -*-
2 // vi: set ts=2:
3 //
4 
5 #ifndef BALL_CONCEPT_BASEITERATOR_H
6 #define BALL_CONCEPT_BASEITERATOR_H
7 
8 #ifndef BALL_CONFIG_CONFIG_H
9 # include <BALL/CONFIG/config.h>
10 #endif
11 
12 #ifndef BALL_COMMON_GLOBAL_H
13 # include <BALL/COMMON/global.h>
14 #endif
15 
16 #ifndef BALL_COMMON_EXCEPTION_H
17 # include <BALL/COMMON/exception.h>
18 #endif
19 
20 namespace BALL
21 {
22 
63  template <typename Container, typename DataType, typename Position, typename Traits>
65  {
66  public:
67 
73  typedef DataType value_type;
78  typedef const DataType* pointer;
80  typedef const DataType& reference;
82  typedef std::input_iterator_tag iterator_category;
84 
90 
93  : traits_(iterator.traits_)
94  {
95  }
96 
100 
104 
110  {
111  traits_ = iterator.traits_;
112  return *this;
113  }
114 
116  BALL_INLINE void swap(BaseIterator& iterator) { std::swap(traits_, iterator.traits_); }
118 
122 
124  BALL_INLINE void invalidate() { traits_.invalidate(); }
125 
127  BALL_INLINE void setTraits(const Traits& traits) { traits_ = traits; }
128 
130  BALL_INLINE const Traits& getTraits() const { return traits_; }
131 
133  BALL_INLINE Traits& getTraits() { return traits_; }
134 
136  BALL_INLINE const Container* getContainer() const { return traits_.getContainer(); }
138 
142 
147  BALL_INLINE operator const Position& () const { return traits_.getPosition(); }
148 
150  BALL_INLINE reference operator * () const { return (reference)traits_.getData(); }
151 
153  BALL_INLINE pointer operator -> () const { return (pointer)&traits_.getData(); }
155 
159 
161  BALL_INLINE bool operator == (const BaseIterator& iterator) const { return (traits_ == iterator.traits_); }
162 
164  BALL_INLINE bool operator != (const BaseIterator& iterator) const { return !(traits_ == iterator.traits_); }
165 
170  BALL_INLINE bool isSingular() const { return traits_.isSingular(); }
171 
175  BALL_INLINE bool isValid() const { return traits_.isValid(); }
176 
178  BALL_INLINE bool operator + () const { return traits_.isValid(); }
179 
181  BALL_INLINE bool operator - () const { return !traits_.isValid(); }
183 
184  protected:
185 
189  BALL_INLINE BaseIterator(const Container& container)
190  : traits_(container)
191  {
192  }
193 
194  private:
195 
197  Traits traits_;
198  };
199 
200 
201 } // namespace BALL
202 
203 #endif // BALL_CONCEPT_BASEITERATOR_H
BALL_INLINE reference operator*() const
Convert an iterator to its Datatype by returning a reference to the current data. ...
Definition: baseIterator.h:150
BALL_INLINE void invalidate()
Invalidate the iterator.
Definition: baseIterator.h:124
BALL_INLINE bool operator==(const BaseIterator &iterator) const
Equality operator.
Definition: baseIterator.h:161
BALL_INLINE BaseIterator(const Container &container)
Definition: baseIterator.h:189
std::input_iterator_tag iterator_category
Definition: baseIterator.h:82
BALL_INLINE void setTraits(const Traits &traits)
Set the traits.
Definition: baseIterator.h:127
BALL_INLINE pointer operator->() const
Return a pointer to the current data.
Definition: baseIterator.h:153
const DataType * pointer
Definition: baseIterator.h:78
const DataType & reference
Definition: baseIterator.h:80
#define BALL_INLINE
Definition: debug.h:15
BALL_INLINE bool isValid() const
Definition: baseIterator.h:175
BALL_INLINE bool operator!=(const BaseIterator &iterator) const
Inequality operator.
Definition: baseIterator.h:164
BALL_INLINE BaseIterator(const BaseIterator &iterator)
Copy constructor.
Definition: baseIterator.h:92
BALL_INLINE void swap(BaseIterator &iterator)
Swap two iterators.
Definition: baseIterator.h:116
Position difference_type
Definition: baseIterator.h:76
BALL_INLINE const Traits & getTraits() const
Get a constant reference to the traits of this iterator.
Definition: baseIterator.h:130
BALL_INLINE bool operator-() const
Invalidity perdicate.
Definition: baseIterator.h:181
BALL_INLINE bool isSingular() const
Definition: baseIterator.h:170
BALL_INLINE bool operator+() const
Validity predicate.
Definition: baseIterator.h:178
BALL_INLINE BaseIterator & operator=(const BaseIterator &iterator)
Definition: baseIterator.h:109
BALL_INLINE ~BaseIterator()
Destructor.
Definition: baseIterator.h:98
BALL_INLINE Traits & getTraits()
Get a constant reference to the traits of this iterator.
Definition: baseIterator.h:133
BALL_INLINE BaseIterator()
Default constructor.
Definition: baseIterator.h:89
BALL_INLINE const Container * getContainer() const
Get a constant pointer to the container of this iterator.
Definition: baseIterator.h:136