#ifndef __JACOUSTICS__JTRANSMISSION_T__
#define __JACOUSTICS__JTRANSMISSION_T__

#include <istream>
#include <ostream>

#include "JLang/JComparable.hh"

/**
 * \file
 *
 * Acoustic transmission identifier.
 * \author mdejong
 */
namespace JACOUSTICS {}
namespace JPP { using namespace JACOUSTICS; }

namespace JACOUSTICS {

  using JLANG::JComparable;


  /**
   * Acoustic transmission identifier.
   */
  struct JTransmission_t :
    public JComparable<JTransmission_t>
  {
    /**
     * Default constructor.
     */
    JTransmission_t() :
      tx(-1),
      rx(-1)
    {}


    /**
     * Constructor.
     *
     * \param  tx                emitter  identifier
     * \param  rx                receiver identifier
     */
    JTransmission_t(const int tx,
		    const int rx) :
      tx(tx),
      rx(rx)
    {}


    /**
     * Less than method.
     *
     * \param  id                transmission identifier
     * \return                   true is this transmission identifier is less than given transmision identifier; else false
     *
     */
    inline bool less(const JTransmission_t& id) const
    {
      if (this->tx == id.tx)
	return this->rx < id.rx;
      else
	return this->tx < id.tx;
    }


    /**
     * Read transmission identifier from input stream.
     *
     * \param  in                input stream
     * \param  object            transmission identifier
     * \return                   input stream
     */
    friend inline std::istream& operator>>(std::istream& in, JTransmission_t& object)
    {
      return in >> object.tx >> object.rx;
    }


    /**
     * Write transmission identifier to output stream.
     *
     * \param  out               output stream
     * \param  object            transmission identifier
     * \return                   output stream
     */
    friend inline std::ostream& operator<<(std::ostream& out, const JTransmission_t& object)
    {
      return out << object.tx << ' ' << object.rx;
    }


    int tx;                 //!< emitter  identifier
    int rx;                 //!< receiver identifier
  };
}

#endif