/*
 * SecBus - This file is part of SecBus
 * Copyright (C) 2012 - Telecom ParisTech
 * 
 * This file must be used under the terms of the CeCILL.
 * This source file is licensed as described in the file COPYING, which
 * you should have received as part of this distribution.  The terms
 * are also available at    
 * http://www.cecill.info/licences/Licence_CeCILL_V1.1-US.txt
 *
 */

#ifndef IF_HELPERS__H_
#define IF_HELPERS__H_

#define CREATE_IF(if_name, ...)					      \
  template<template<typename> class IN,				      \
    template<typename> class OUT,				      \
    ##__VA_ARGS__>						      \
    class if_name##_WIRES

#define CREATE_SIGNAL(if_name, ...)					\
  struct if_name##_SIGNALS :						\
    public if_name##_WIRES<my_sc_signal, my_sc_signal, ##__VA_ARGS__>	

#define CREATE_IN(if_name, ...)						\
  struct if_name##_IN :							\
    public if_name##_WIRES<sc_in, sc_out, ##__VA_ARGS__>   

#define CREATE_OUT(if_name, ...)					\
  struct if_name##_OUT :						\
    public if_name##_WIRES<sc_out, sc_in, ##__VA_ARGS__>   

#define TPL_IN(if_name, ...)				\
  typedef if_name##_WIRES<sc_in, sc_out, ##__VA_ARGS__>	\
    base_##if_name##_IN_t;						

#define TPL_OUT(if_name, ...)				\
  typedef if_name##_WIRES<sc_out, sc_in, ##__VA_ARGS__>	\
    base_##if_name##_OUT_t;						

#define ADD_OPERATOR(if_name, param)		\
  public:					\
  void operator () (if_name ##_## param &sig);

#define ADD_TPLOPERATOR(if_name, param, ...)			\
  public:							\
  void operator () (if_name ##_## param <__VA_ARGS__> &sig);

#define CREATE_SENSITIVE(if_name, param)			\
  sc_core::sc_sensitive& operator <<(				\
    sc_core::sc_sensitive &ss,					\
      if_name ##_## param &sig);

template<typename T>
class my_sc_signal : public sc_signal<T>
{
public:
  /* support for operator = with signals */
  my_sc_signal<T>& operator = (const T& a)
  {
    this->write(a);
    return *this;
  }
};

#endif
