/*
 * $Id: Interfaces_find_signal.cpp 81 2008-04-15 18:40:01Z rosiere $
 *
 * [ Description ]
 * 
 */

#include "Behavioural/include/Interfaces.h"

namespace morpheo              {
namespace behavioural          {

#undef  FUNCTION
#define FUNCTION "Interfaces::find_signal"
  Signal * Interfaces::find_signal (std::string name)
  {
    log_printf(FUNC,Behavioural,FUNCTION,"Begin");

    Signal * _return = NULL;
    if (_list_interface->empty()== false)
      {
	std::list<Interface_fifo*>::iterator i = _list_interface->begin();

	while (i != _list_interface->end())
	  {
	    Signal * signal = (*i)->find_signal(name);

	    // Warning : Name of signal is uniq
	    if (signal != NULL)
	      {
		_return = signal;
		break;
	      }

	    ++i;
	  }
      }
     
    log_printf(FUNC,Behavioural,FUNCTION,"End");
    return _return;
  };

#undef  FUNCTION
#define FUNCTION "Interfaces::find_signal"
  bool Interfaces::find_signal (Signal * signal)
  {
    log_printf(FUNC,Behavioural,FUNCTION,"Begin");

    bool _return = false;

    if (_list_interface->empty()== false)
      {
	std::list<Interface_fifo*>::iterator i = _list_interface->begin();

	while (i != _list_interface->end())
	  {
	    if ((*i)->find_signal(signal) == true)
	      {
		_return = true;
		break;
	      }

	    ++i;
	  }
      }
  
    log_printf(FUNC,Behavioural,FUNCTION,"End");   
    return _return;
  };

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