/*
 * $Id: Component_get_component.cpp 94 2008-12-15 11:04:03Z rosiere $
 *
 * [ Description ]
 * 
 */

#include "Behavioural/include/Component.h"
#include "Common/include/Tabulation.h"

namespace morpheo              {
namespace behavioural          {

#undef  FUNCTION
#define FUNCTION "Component::get_component"

  std::string Component::get_component (void)
  {
    log_printf(FUNC,Behavioural,FUNCTION,"Begin");

    uint32_t               depth          = 0;
    std::string                 separator      = "\n";
    bool                   last_separator = false;

    std::list<Tcomponent_t *>::iterator  i  = _list_component->begin();
    bool                   empty = _list_component->empty();

    std::string                 tab=morpheo::tab(depth);

    std::ostringstream          text;

    if (not empty)
      {
	// First
	if (i != _list_component->end())
	  {
	    text << tab << *((*i)->_entity);
	    ++i;
	  }
	
	while (i != _list_component->end())
	  {
	    text << separator;
	    text << tab << *((*i)->_entity);
	    ++i;
	  }
	
	if (last_separator)
	  text << separator;
      }

    log_printf(FUNC,Behavioural,FUNCTION,"End");

    return text.str();
  };

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