namespace X3DTK {

template<class T, class V> 
std::pair<StringType, EnterFunction *> Recorder<T, V>::getEnterFunction(void (*ptrF)(T *))
{
  BaseRecorder::beginFunctionDefinition();
  
  //finding if an occurence of T
  T *t = new T();

  SFType *type = t->getType();
  std::pair<StringType, EnterFunction *> result;
  result.first.type = type->getName();
  result.first.component = type->getComponentName();
  result.first.sceneGraph = type->getSceneGraphName();  
  result.first.encodedName = type->getEncodedName(); 
  result.second = new EnterFunction(reinterpret_cast<ptrToEnterFunction>(ptrF));
    
  delete t;
  BaseRecorder::endFunctionDefinition();

  return result;
}

template<class T, class V> 
std::pair<StringType, WalkOnFunction *> Recorder<T, V>::getWalkOnFunction(bool (*ptrF)(T *, SFNode))
{
  BaseRecorder::beginFunctionDefinition();

  //finding if an occurence of T
  T *t = new T();

  SFType *type = t->getType();
  std::pair<StringType, WalkOnFunction *> result;
  result.first.type = type->getName();
  result.first.component = type->getComponentName();
  result.first.sceneGraph = type->getSceneGraphName();
  result.first.encodedName = type->getEncodedName();
  result.second = new WalkOnFunction(reinterpret_cast<ptrToWalkOnFunction>(ptrF));
       
  delete t;
  BaseRecorder::endFunctionDefinition();

  return result;
}

template<class T, class V> 
std::pair<StringType, LeaveFunction *> Recorder<T, V>::getLeaveFunction(void (*ptrF)(T *))
{
  BaseRecorder::beginFunctionDefinition();

  //finding if an occurence of T
  T *t = new T();
  
  SFType *type = t->getType();
  std::pair<StringType, LeaveFunction *> result;
  result.first.type = type->getName();
  result.first.component = type->getComponentName();
  result.first.sceneGraph = type->getSceneGraphName();
  result.first.encodedName = type->getEncodedName();  
  result.second = new LeaveFunction(reinterpret_cast<ptrToLeaveFunction>(ptrF));
    
  delete t;
  BaseRecorder::endFunctionDefinition();
  
  return result;
}

template<class T, class V> 
std::pair<StringType, CreationFunction *> Recorder<T, V>::getCreationFunction()
{
  BaseRecorder::beginFunctionDefinition();

  //finding if an occurence of T
  T *t = new T();
  
  SFType *type = t->getType();
  std::pair<StringType, CreationFunction *> result;
  result.first.type = type->getName();
  result.first.component = type->getComponentName();
  result.first.sceneGraph = type->getSceneGraphName();
  result.first.encodedName = type->getEncodedName();  
  result.second = new CreationFunction(reinterpret_cast<ptrToCreationFunction>(&NodeFactory<T>::create));
    
  delete t;
  BaseRecorder::endFunctionDefinition();
  
  return result;
}

template<class T, class V> 
TypeName Recorder<T, V>::getTypeName(const SFString &name, const SFString &component, const SFString &sceneGraph)
{
  TypeName result;
  result.name = name;
  result.component = component;
  result.sceneGraph = sceneGraph;
  result.cloner = new NodeCloner<T>();
  
  return result;
}

template<class T, class V>
AttributeRecorder<T, V> Recorder<T, V>::getAttribute(const SFString &name, V T:: *member, const V &init)
{
  return AttributeRecorder<T, V>(name, member, init);
}

template<class T, class V>
SFNodeRecorder<T, V> Recorder<T, V>::getSFNode(const SFString &name, V *T:: *node)
{
  return SFNodeRecorder<T, V>(name, node);
}

template<class T, class V>
MFNodeRecorder<T, V> Recorder<T, V>::getMFNode(const SFString &name, MFNode T:: *nodes)
{
  return MFNodeRecorder<T, V>(name, nodes);
}

}
