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

#include "attribute.h"
#include <qstring.h>

class ElementNode;
/**
Holds a reference to elements
Similar to SVGURIReference in SVG 1.1
 
@author Hans Oischinger
*/
class URIReference : public Attribute
{
public:
  URIReference( ElementNode* parent, bool referenceParentIfInvalid = false );
  ~URIReference();

  URIReference &operator=(const URIReference&);
  virtual Attribute* clone();

  QString getURI() const { return m_URI; }
  QString getLocalURI() const;
  void setURI( const QString & uri ) { m_URI = uri; }

  ElementNode* getRefElement();
  void setRefElement( ElementNode* ref );

  virtual void accept( AVisitor& );

  // If m_ref or m_URI are invalid return a ref to parent()
  // usefull for animateElement which references it's parent by default
  bool getReferenceParentIfInvalid() const { return m_referenceParentIfInvalid; }
  void setReferenceParentIfInvalid( bool b ) { m_referenceParentIfInvalid = b; }

protected:
  ElementNode* searchRefElementforURI() const;

protected:
  ElementNode* m_parentElement; // The Element that owns us
  QString m_URI;
  ElementNode* m_ref;
  bool m_referenceParentIfInvalid;
};

#endif
