

//****************************************************************************************
//************************          (I)   xmlClass          ******************************
//****************************************************************************************



template<typename XMLIZED>
void xmlClass::add_child( XMLIZED & object , std::string name )
{
  xmlObject_base * my_wrapper = xmlFC::find_xmlObject_base ( *this );
  if(my_wrapper)
    my_wrapper -> add_childSpace( xmlFC::create_xmlObject ( &object , name ) );
  else
    cerr<<"Error in xmlClass::add_child() : the father object has not been added in the XML structure yet!"<<endl;
}


template < typename TYPE >
void xmlClass::add_param( TYPE & newParam, std::string paramName )
{
  xmlObject_base * my_wrapper = xmlFC::find_xmlObject_base ( *this );
  if(my_wrapper)
    my_wrapper -> add_param( newParam, paramName );
  else
    cerr<<"Error in xmlClass::add_param() : the father object has not been added in the XML structure yet!"<<endl;
}

/*
void add_node ( xmlObject_base & node , std::string name )
{
	xmlObject_base * my_wrapper = xmlFC::find_xmlObject_base ( *this );
	if(my_wrapper)
		my_wrapper -> add_childSpace( node );
	else
		cerr<<"Error in xmlClass::add_child() : the father object has not been added in the XML structure yet!"<<endl;
}*/


//****************************************************************************************
//************************          (II)   xmlParam          *****************************
//****************************************************************************************


template<typename XMLIZED>
void xmlParam::add_object(XMLIZED & object , std::string name)
{
  xmlObject_base::static_toDelete.push_back ( xmlFC::create_xmlObject ( &object , name ) );
}


template<typename XMLIZED>
void xmlParam::save(XMLIZED & object , xmlpp::Node* father_node )
{
  xmlObject_base * new_obj = xmlFC::find_xmlObject_base ( object );
  if(new_obj)
  {
    new_obj ->save_XML (father_node) ;
  }
  else
    cerr<<"Error in xmlParam::save() : the object has not been added in the XML structure yet!"<<endl;
}


template<typename XMLIZED>
void xmlParam::load(XMLIZED & object , xmlpp::Node* father_node )
{
  xmlObject_base * new_obj = xmlFC::find_xmlObject_base ( object );
  if(new_obj)
  {
    new_obj->load_XML (father_node) ;
  }
  else
    cerr<<"Error in xmlParam::load() : the object has not been added in the XML structure yet!"<<endl;
}

// Custom functions... almost identical to the xmlClass versions. Only difference:
// In this case, for function add_child, the new xmlObject IS NOT registered in the toDelete vector of its father object.

template < typename TYPE , typename XMLIZED >
void xmlParam::add_param_custom(TYPE & newParam, std::string paramName, XMLIZED &fatherObject)
{
  xmlObject_base * father = xmlFC::find_xmlObject_base ( fatherObject );
  if(father)
    father->add_param(newParam, paramName);
  else
    cerr<<"Error in xmlParam::add_param_custom : the father object has not been added in the XML structure yet!"<<endl;
}

template<typename XMLIZED_1, typename XMLIZED_2>
void xmlParam::add_child_custom(XMLIZED_1 & childObject , std::string name, XMLIZED_2 & fatherObject)
{
  xmlObject_base * father = xmlFC::find_xmlObject_base ( fatherObject );
  if(father)
    father->add_childSpace( xmlFC::create_xmlObject ( &childObject , name ) );
  else
    cerr<<"Error in xmlParam::add_child_custom : the father object has not been added in the XML structure yet!"<<endl;
}

/*
template < typename XMLIZED >
void xmlParam::add_node_custom( xmlObject_base & node , std::string name, XMLIZED &fatherObject)
{
	xmlObject_base * father = xmlFC::find_xmlObject_base ( fatherObject );
	if(father)
		father->add_param( node , name );
	else
		cerr<<"Error in xmlParam::add_node_custom : the father object has not been added in the XML structure yet!"<<endl;
}*/


//****************************************************************************************
//**********************          (III)   xmlRegister          ***************************
//****************************************************************************************


//the total-chain version

template<uint order, class derivedCLASS>
template<class XMLIZED>
xmlRegister<order,derivedCLASS>::xmlRegister( XMLIZED & object, list<string> registerNames )
{
  //ENTERING( xmlRegister_total_chain_version )
  xmlObject<XMLIZED> * new_obj = xmlFC::find_xmlObject ( object );

  if(new_obj)
    Register_obj <order , XMLIZED , derivedCLASS>::total_registration ( registerNames , new_obj );

  else
    cerr<<"Error in xmlRegister : the object has not been added in the XML structure yet!"<<endl;
  //EXITING( xmlRegister_total_chain_version )
}


//the single-name version

template<uint order, class derivedCLASS>
template<class XMLIZED>
xmlRegister<order,derivedCLASS>::xmlRegister( XMLIZED & object, string registerName )
{
  //ENTERING( xmlRegister_single_name_version )
  xmlObject<XMLIZED> * new_obj = xmlFC::find_xmlObject ( object );

  if(new_obj)
    Register_obj <order , XMLIZED , derivedCLASS>::last_step_registration ( registerName , new_obj );

  else
    cerr<<"Error in xmlRegister : the object has not been added in the XML structure yet!"<<endl;
  //EXITING( xmlRegister_single_name_version )
}







