/// 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 X3DROUTE_H
#define X3DROUTE_H

#include "X3DMemberFunctor.h"

#include <vector>

namespace X3DTK {
namespace X3D {

class Scene;

}

class X3DRoute;
typedef X3DRoute *SFRoute;
typedef std::vector<X3DRoute *> MFRoute;

class X3DRoute 
{
public:
  static X3DRoute *create(X3DAbstractNode *A, const SFString &a_name, X3DAbstractNode *B, const SFString &b_name);
  inline void send() {_b->setValueOf(_bNode, _a->getValueOf(_aNode));};
  static bool remove(X3DRoute *route);
  
  /// Gets the from node.
  inline X3DAbstractNode *getFromNode() const {return _aNode;};
  /// Gets the from field.
  inline const SFString &getFromField() const {return _fromField;};
  /// Gets the to node.
  inline X3DAbstractNode *getToNode() const {return _bNode;};
  /// Gets the to field.
  inline const SFString &getToField() const {return _toField;};
  /// Function loading the Scene.
  static void loadScene(X3D::Scene *S, const MFRoute &routes);
  
private:
  X3DRoute(X3DAbstractNode *A, const SFString &fromField, X3DMemberFunctor *a, X3DAbstractNode *B, const SFString &toField, X3DMemberFunctor *b);
  ~X3DRoute();
   
  X3DAbstractNode *_aNode;
  SFString _fromField;
  X3DMemberFunctor *_a;
  X3DAbstractNode *_bNode;
  SFString _toField;
  X3DMemberFunctor *_b;  
  
  static MFRoute _routes;
};

}

#endif
