/// 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_X3DMULTIPASSPROCESSOR_H
#define X3DTK_X3DMULTIPASSPROCESSOR_H

#include "X3DProcessor.h"
#include "GraphTraversal.h"

#include <map>

namespace X3DTK {

/*! \brief Abstract class declared in <b><X3DTK/kernel.h></b> defining the concept of multi pass processor.
 *
 *  A multi pass processor is made up of a multiple walker and visitor. Several traversals
 *  of the scene graph are made. The different traversals are accessed by a string 
 *  key. For more details about how to define a processor, see the 
 *  <a href="Processor.html">processor</a> page.
 *
 *  \ingroup processor
 */

class X3DMultiPassProcessor : public X3DProcessor
{
  typedef std::map<SFString, GraphTraversal *, ltSFString> MFGraphTraversal;
public:
  /// Constructor.
  X3DMultiPassProcessor();
  /// Destructor.
  virtual ~X3DMultiPassProcessor() = 0;
  
  /// Sets the Walker for the processor traversal.
  virtual void setWalker(const SFString &processor, Walker *walker);
  /// Sets a component visitor for the processor traversal. If there is already a 
  /// visitor recorded for this component, then it is deleted and replaced by the new one.
  virtual void setComponentVisitor(const SFString &processor, X3DComponentVisitor *component);

  /// Sets the GraphTraversal of the processor traversal.
  /// For a Depth First Search traversal, use X3DTK::DFSGraphTraversal.
  void setGraphTraversal(const SFString &processor, GraphTraversal *graphTraversal);
  /// Gets the GraphTraversal.
  GraphTraversal *getGraphTraversal(const SFString &processor) const;
  /// Traverses the scene graph for the processor traversal.
  void traverse(const SFString &processor, X3DAbstractNode *N);

private:
  MFGraphTraversal _graphTraversalMap;  
};

}

#endif
