/*
 * $Id: Instance_toXML.cpp 88 2008-12-10 18:31:39Z rosiere $
 *
 * [ Description ]
 * 
 */

#include "Behavioural/Configuration/include/Instance.h"

namespace morpheo {
namespace behavioural {
namespace configuration {

#undef  FUNCTION
#define FUNCTION "Instance::toXML"
  XML Instance::toXML (void)
  {
    XML xml (basename(_filename.c_str()));
    xml.filename_extension("");
    
    xml.balise_open_begin("core");
    xml.attribut("name",_name);
    xml.balise_open_end  ();

    for (list_parameters_t::iterator it = _list_parameters->begin();
         it != _list_parameters->end();
         ++it)
      xml.insert_XML(it->second->toXML(),1);

    for (list_links_t::iterator it1 = _list_links->begin();
         it1 != _list_links->end();
         ++it1)
      for (list_link_t::iterator it2 = it1->second.begin();
           it2 != it1->second.end();
           ++it2)
        xml.insert_XML(it2->second->toXML(),1);
    
    for (list_components_t::iterator it1 = _list_components->begin();
         it1 != _list_components->end();
         ++it1)
      for (list_instances_t::iterator it2 = it1->second.begin();
           it2 != it1->second.end();
           ++it2)
      xml.insert_XML(it2->second->toXML(),1);

    xml.balise_close();

    return xml;
  }

}; // end namespace configuration
}; // end namespace behavioural
}; // end namespace morpheo              
