/// This file is part of the X3DToolKit library
/// Copyright (C) 2002-2004  Yannick Le Goc (legoc@imag.fr)

/// http://artis.imag.fr/Members/Yannick.Legoc/X3D/

/// This library is free software; you can redistribute it and/or
/// modify it under the terms of the GNU Lesser General Public
/// License as published by the Free Software Foundation; either
/// version 2.1 of the License, or (at your option) any later version.

/// This library 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
/// Lesser General Public License for more details.

/// You should have received a copy of the GNU Lesser General Public
/// License along with this library; if not, write to the Free Software
/// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#ifndef X3DTK_X3DLOADER_H
#define X3DTK_X3DLOADER_H

#include "X3DTypes.h"
#include "Walker.h"

#include <list>

namespace X3DTK {

class X3DComponentWalker;
class X3DComponentVisitor;

namespace X3D {

class Creator;
class X3DComponentCreator;
class Scene;
class FileValidator;
class X3DXmlLoader;

}

/*! \brief Class declared in <b><X3DTK/X3D/scenegraph.h></b> defining a facade to 
 *  the X3D loader of which version depends on your system. 
 *
 *  The loader creates an X3D scene graph, and is the entry point of any X3DToolKit 
 *  application. It is encapsulated into X3DTK::SimpleX3DGLScene and X3DTK::SimplifiedMeshScene.
 *  
 *  \ingroup X3DLoader
 */

class X3DLoader
{
public:
  /// Constructor.
  X3DLoader();
  /// Destructor.
  virtual ~X3DLoader() = 0;
  
  /// Loads an X3D scene graph from the file. If fileValidation is true, then the file will be 
  /// verified and messages will be written if the file is invalid. Nevertheless the 
  /// content of the scene is not deleted. The new scene graph is allocated, and has to
  /// be released later.
  X3D::Scene *load(const char *file, bool fileValidation = true) const;
  
  /// Sets the componentCreator. If there is already a creator recorded for this 
  /// component recorded, then it is deleted and replaced by the new one.
  void setComponentCreator(X3D::X3DComponentCreator *component);
  /// Sets the Walker for the FileValidator. If there is already a creator recorded 
  /// for this component, then it is deleted and replaced by the new one.  
  void setWalkerForFileValidator(Walker *walker);
  /// Sets the componentVisitor for the FileValidator. If there is already a creator recorded 
  /// for this component, then it is deleted and replaced by the new one.
  void setComponentVisitorForFileValidator(X3DComponentVisitor *component);
  /// Sets the FileValidator. If there is already a creator recorded for this component,
  /// then it is deleted and replaced by the new one.
  void setFileValidator(X3D::FileValidator *fileValidator);
  
protected:
  /// Creator.
  X3D::Creator *creator;
  /// FileValidator.
  X3D::FileValidator *fileValidator;  
  /// XmlLoader.
  X3D::X3DXmlLoader *xmlLoader;
};

}

#endif
