/***************************************************************************
 *   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 ELEMENTNODE_H
#define ELEMENTNODE_H

#include "element.h"

class ElementNode;
class DocumentElement;
class VSetAnimValues;
/**
Abstract Element class that implements Node functions

@author Hans Oischinger
*/
class ElementNode : public Element
{
  Q_OBJECT
friend class VSetAnimValues;
public:
  ElementNode( const QString & name = "", unsigned int state = undefined );
  ElementNode( const ElementNode & );
  virtual ~ElementNode();

  ElementNode &operator=(const ElementNode &);
  virtual ElementNode *clone() = 0;

  virtual ElementNode* insertBefore( ElementNode* newChild, ElementNode* refChild );
  virtual ElementNode* insertAfter( ElementNode* newChild, ElementNode* refChild );
  virtual ElementNode* removeChild( ElementNode* oldChild );
  virtual ElementNode* appendChild( ElementNode* newChild );
  virtual bool hasChildNodes() const;

  virtual ElementNode* getParent() const { return parent; }
  virtual ElementNode* getPrev() const { return prev; }
  virtual ElementNode* getNext() const { return next; }
  virtual ElementNode* getFirstChild() const { return first; }
  virtual ElementNode* getLastChild() const { return last; }

  void deleteSubTree(); // FIXME: Use a iterator and the object db for this
  ElementNode *cloneSubTree(); // Clones the elements and all it's descendants
  
  virtual unsigned int getState();

protected:
  ElementNode* parent;
  ElementNode* prev;
  ElementNode* next;
  ElementNode* first;
  ElementNode* last;
};

#endif
