Elm  1.0
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Iterator.h
1 /*
2  * $Id$
3  * Iterator class interface
4  *
5  * This file is part of OTAWA
6  * Copyright (c) 2004-08, IRIT UPS.
7  *
8  * OTAWA is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * OTAWA is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with OTAWA; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22 #ifndef ELM_DATASTRUCT_ITERATOR_H
23 #define ELM_DATASTRUCT_ITERATOR_H
24 
25 #include <elm/PreIterator.h>
26 
27 namespace elm { namespace datastruct {
28 
29 // IteratorInst class
30 template <class T>
31 class IteratorInst {
32 public:
33  virtual ~IteratorInst(void) { }
34  virtual bool ended(void) const = 0;
35  virtual T item(void) const = 0;
36  virtual void next(void) = 0;
37 };
38 
39 
40 // Iterator class
41 template <class T>
42 class Iterator: public PreIterator<Iterator<T>, T> {
43 public:
44  inline Iterator(IteratorInst<T> *_iter): iter(_iter) { }
45  inline IteratorInst<T> *instance(void) const { return iter; }
46  inline ~Iterator(void) { delete iter; }
47  inline bool ended(void) const { return iter->ended(); }
48  inline T item(void) const { return iter->item(); }
49  inline void next(void) { iter->next(); }
50 protected:
52 };
53 
54 } } // elm::datastruct
55 
56 #endif // ELM_DATASTRUCT_ITERATOR_H
bool ended(void) const
Definition: Iterator.h:47
Definition: PreIterator.h:29
Iterator(IteratorInst< T > *_iter)
Definition: Iterator.h:44
Definition: Iterator.h:31
IteratorInst< T > * iter
Definition: Iterator.h:51
~Iterator(void)
Definition: Iterator.h:46
virtual T item(void) const =0
virtual void next(void)=0
virtual ~IteratorInst(void)
Definition: Iterator.h:33
IteratorInst< T > * instance(void) const
Definition: Iterator.h:45
T item(void) const
Definition: Iterator.h:48
void next(void)
Definition: Iterator.h:49
Definition: Iterator.h:42
virtual bool ended(void) const =0