/*
 * $Id$
 *
 * [ Description ]
 * 
 */

#include "Behavioural/include/Component.h"

namespace morpheo              {
namespace behavioural          {

  Entity * Component::find_entity (std::string name)
  {
    log_printf(FUNC,Behavioural,"Component::find_entity", "Begin");

    Entity * _return = NULL;

    if (_entity->get_name() == name)
      _return = _entity;
    else
      if (_list_component->empty()== false)
	{
	  std::list<Tcomponent_t *>::iterator i = _list_component->begin();
	  
	  while (i != _list_component->end())
	    {
	      Entity * entity = (*i)->_entity;

	      if (entity->get_name() == name)
		{
		  _return = entity;
		  break;
		}
	      ++i;
	    }
	}

    log_printf(FUNC,Behavioural,"Component::find_entity", "End");

    return _return;
  };

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