Code

Added filter iterrator, corrected objectlists
[gosa.git] / include / class_ObjectListIterator.inc
1 <?php
3 /*! \brief   Implementation for iterating through ObjectList objects
4     \author  Cajus Pollmeier <pollmeier@gonicus.de>
5     \version 1.00
6     \date    2007/11/02
8     The class ObjectList handles a list of objects found in the database
9     based on an optional filter modules. This objects can be iterated
10     directly by using this iterator class.
12     \sa ObjectList
13  */
14 class ObjectListIterator implements Iterator {
16   /*!
17     \brief Reference container for objects
19     This variable stores the list of objects.
20    */
21         private $objects;
23   /*!
24     \brief Iterator position
26     Keeps the current position inside our ObjectList
27    */
28   private $position;
30   /*! \brief ObjectListIterator constructor
32     The ObjectListIterator is initialized by a list of objects from the
33     ObjectList object.
35     \param objects List of objects to be iterated
36    */
37         public function __construct(&$objects){
38     $this->objects= &$objects;
39   }
42   /*! \brief Rewind to the begining of the ObjectList */
43   public function rewind(){
44     $this->position= 0;
45   }
48   /*! \brief Check if the next object is valid */
49   public function valid() {
50     return isset($this->objects[$this->position]);
51   }
54   /*! \brief Return the current key
55       \return integer Current position
56    */
57   public function key() {
58     return $this->position;
59   }
60   
62   /*! \brief Return the current value
63       \return object Current value
64    */
65   public function current() {
66     return $this->objects[$this->position];
67   }
70   /*! \brief Go to the next index */
71   public function next() {
72     $this->position++;
73   }
75 }
77 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
78 ?>