#include "X3DAbstractNodeForward.h"

namespace X3DTK {

template<class T, class V>
SFNodeRecorder<T, V>::SFNodeRecorder(const SFString &name, V *T:: *node)
: X3DSFNodeRecorder(), _name(name), _node(node)
{
}

template<class T, class V>
void SFNodeRecorder<T, V>::record(X3DAbstractNode *N) const
{
  SFType *type = X3DAbstractNode_getType(N);

  static_cast<T *>(N)->*_node = 0;
    
  for (std::vector<std::pair<SFString, X3DSFNodeFunctor *> >::iterator it = type->nodeMap().begin(); it != type->nodeMap().end(); ++it)
  {
    if ((*it).first == _name)
      return;
  }
  
  type->nodeMap().push_back(std::pair<SFString, X3DSFNodeFunctor *>(_name, new SFNodeFunctor<T, V>(_node))); 
}

}
