/***************************************************************************
 *   Copyright (C) 2004 by Hans Oischinger                                 *
 *   hans.oischinger@kdemail.net                                           *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   51 Franklin Steet, Fifth Floor, Boston, MA 02110-1301, USA.             *
 ***************************************************************************/
#ifndef ELEMENTTREEITERATOR_H
#define ELEMENTTREEITERATOR_H

#include "elementnode.h"

/**
@author Hans Oischinger
*/
class ElementTreeIterator
{
public:
  ElementTreeIterator( ElementNode* root, bool includeUseClones = false );
  virtual ~ElementTreeIterator();

  virtual ElementNode* start();
  virtual ElementNode* prev();
  virtual ElementNode* next();
  virtual ElementNode* current();

  void setincludeUseClones( bool b ) { m_includeUseClones = b; }
  unsigned int level() { return m_level; }

private:
  bool m_includeUseClones;  // TRUE if we should also go through Use childs
  ElementNode* m_rootNode;
  ElementNode* m_currentNode;
  ElementNode* m_prevNode;
  ElementNode* m_nextNode;  // These two allow prev() & next() on NULL nodes
  unsigned int m_level;
};

class ElementTreeConstIterator
{
public:
  ElementTreeConstIterator( ElementNode* root );
  virtual ~ElementTreeConstIterator();

  virtual const ElementNode* start();
  virtual const ElementNode* prev();
  virtual const ElementNode* next();
  virtual const ElementNode* current();
  
private:
  const ElementNode* m_rootNode;
  const ElementNode* m_currentNode;
  const ElementNode* m_prevNode;
  const ElementNode* m_nextNode;  // These two allow prev() & next() on NULL nodes
};

#endif
