/*
 *  Open BEAGLE
 *  Copyright (C) 2001-2004 by Christian Gagne and Marc Parizeau
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License as published by the Free Software Foundation; either
 *  version 2.1 of the License, or (at your option) any later version.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 *  Contact:
 *  Laboratoire de Vision et Systemes Numeriques
 *  Departement de genie electrique et de genie informatique
 *  Universite Laval, Quebec, Canada, G1V 4J7
 *  http://vision.gel.ulaval.ca
 *
 */

/*!
 *  \file   beagle/UShort.hpp
 *  \brief  Definition of the type UShort and related operators.
 *  \author Christian Gagne
 *  \author Marc Parizeau
 *  $Revision: 1.2 $
 *  $Date: 2004/01/15 21:08:57 $
 */

#ifndef Beagle_UShort_hpp
#define Beagle_UShort_hpp

#include "beagle/config.hpp"
#include "beagle/macros.hpp"
#include "beagle/WrapperT.hpp"


namespace Beagle {

/*!
 *  \brief Beagle wrapper of the atomic unsigned short type.
 *  \ingroup Adapt
 */
typedef WrapperT< unsigned short >
        UShort;

}


/*!
 *  \brief  Test whether an unsigned short is less than another.
 *  \param  inLeftUShort  Left unsigned short compared.
 *  \param  inRightUShort Right unsigned short compared.
 *  \return True if left unsigned short is less than the right one, false if not.
 *  \par Note:
 *    The operator is defined relatively to the function isLess of Beagle::UShort.
 */
inline bool operator<(const Beagle::UShort& inLeftUShort, const Beagle::UShort& inRightUShort)
{
  return inLeftUShort.isLess(inRightUShort);
}


/*!
 *  \brief  Test whether an unsigned short is less than, or equal to another.
 *  \param  inLeftUShort  Left unsigned short compared.
 *  \param  inRightUShort Right unsigned short compared.
 *  \return True if left unsigned short is less than, or equal to the right one, false if not.
 *  \par Note:
 *    The operator is defined relatively to the functions isLess and isEqual of Beagle::UShort.
 */
inline bool operator<=(const Beagle::UShort& inLeftUShort, const Beagle::UShort& inRightUShort)
{
  return ( inLeftUShort.isLess(inRightUShort) || inLeftUShort.isEqual(inRightUShort) );
}


/*!
 *  \brief  Test whether an unsigned short is more than another.
 *  \param  inLeftUShort  Left unsigned short compared.
 *  \param  inRightUShort Right unsigned short compared.
 *  \return True if left unsigned short is more than the right one, false if not.
 *  \par Note:
 *    The operator is defined relatively to the function isLess of Beagle::UShort.
 */
inline bool operator>(const Beagle::UShort& inLeftUShort, const Beagle::UShort& inRightUShort)
{
  return inRightUShort.isLess(inLeftUShort);
}


/*!
 *  \brief  Test whether an unsigned short is more than, or equal to another.
 *  \param  inLeftUShort  Left unsigned short compared.
 *  \param  inRightUShort Right unsigned short compared.
 *  \return True if left unsigned short is more than, or equal to the right one, false if not.
 *  \par Note:
 *    The operator is defined relatively to the functions isLess and isEqual of Beagle::UShort.
 */
inline bool operator>=(const Beagle::UShort& inLeftUShort, const Beagle::UShort& inRightUShort)
{
  return ( inRightUShort.isLess(inLeftUShort) || inLeftUShort.isEqual(inRightUShort) );
}


/*!
 *  \brief  Test whether an unsigned short is equal to another.
 *  \param  inLeftUShort  Left unsigned short compared.
 *  \param  inRightUShort Right unsigned short compared.
 *  \return True if left unsigned short is equal to the right one, false if not.
 *  \par Note:
 *    The operator is defined relatively to the function isEqual of Beagle::UShort.
 */
inline bool operator==(const Beagle::UShort& inLeftUShort, const Beagle::UShort& inRightUShort)
{
  return inLeftUShort.isEqual(inRightUShort);
}


/*!
 *  \brief  Test whether an unsigned short is not equal to another.
 *  \param  inLeftUShort  Left unsigned short compared.
 *  \param  inRightUShort Right unsigned short compared.
 *  \return True if left unsigned short is not equal to the right one, false if it is.
 *  \par Note:
 *    The operator is defined relatively to the function isEqual of Beagle::UShort.
 */
inline bool operator!=(const Beagle::UShort& inLeftUShort, const Beagle::UShort& inRightUShort)
{
  return ( inLeftUShort.isEqual(inRightUShort) == false);
}


/*!
 *  \brief Compare equality of a UShort with a unsigned short.
 *  \param inLeftUShort Left value to compare.
 *  \param inRightUShort Right value to compare.
 *  \return Result of the comparison.
 */
inline
bool operator==(const Beagle::UShort& inLeftUShort, unsigned short inRightUShort)
{
  return inLeftUShort.getWrappedValue() == inRightUShort;
}


/*!
 *  \brief Compare inequality of a UShort with a unsigned short.
 *  \param inLeftUShort Left value to compare.
 *  \param inRightUShort Right value to compare.
 *  \return Result of the comparison.
 */
inline
bool operator!=(const Beagle::UShort& inLeftUShort, unsigned short inRightUShort)
{
  return inLeftUShort.getWrappedValue() != inRightUShort;
}


/*!
 *  \brief Test if a UShort is < than a unsigned short.
 *  \param inLeftUShort Left value to compare.
 *  \param inRightUShort Right value to compare.
 *  \return Result of the comparison.
 */
inline
bool operator<(const Beagle::UShort& inLeftUShort, unsigned short inRightUShort)
{
  return inLeftUShort.getWrappedValue() < inRightUShort;
}


/*!
 *  \brief Test if a UShort is <= than a unsigned short.
 *  \param inLeftUShort Left value to compare.
 *  \param inRightUShort Right value to compare.
 *  \return Result of the comparison.
 */
inline
bool operator<=(const Beagle::UShort& inLeftUShort, unsigned short inRightUShort)
{
  return inLeftUShort.getWrappedValue() <= inRightUShort;
}


/*!
 *  \brief Test if a UShort is > than a unsigned short.
 *  \param inLeftUShort Left value to compare.
 *  \param inRightUShort Right value to compare.
 *  \return Result of the comparison.
 */
inline
bool operator>(const Beagle::UShort& inLeftUShort, unsigned short inRightUShort)
{
  return inLeftUShort.getWrappedValue() > inRightUShort;
}


/*!
 *  \brief Test if a UShort is >= than a unsigned short.
 *  \param inLeftUShort Left value to compare.
 *  \param inRightUShort Right value to compare.
 *  \return Result of the comparison.
 */
inline
bool operator>=(const Beagle::UShort& inLeftUShort, unsigned short inRightUShort)
{
  return inLeftUShort.getWrappedValue() >= inRightUShort;
}


/*!
 *  \brief Increment a UShort (prefix version).
 *  \param inUShort UShort to increment.
 *  \return UShort incremented.
 */
inline
Beagle::UShort& operator++(Beagle::UShort& inUShort)
{
  inUShort.getWrappedValue()++;
  return inUShort;
}


/*!
 *  \brief Increment a UShort (postfix version).
 *  \param inUShort UShort to increment.
 *  \return UShort before being incremented.
 */
inline
Beagle::UShort operator++(Beagle::UShort& inUShort, int)
{
  Beagle::UShort lUShort = inUShort;
  inUShort.getWrappedValue()++;
  return lUShort;
}


/*!
 *  \brief Add two UShort.
 *  \param inLeftUShort Left value to add.
 *  \param inRightUShort Right value to add.
 *  \return Result of the addition.
 */
inline
Beagle::UShort operator+(const Beagle::UShort& inLeftUShort, const Beagle::UShort& inRightUShort)
{
  return inLeftUShort.getWrappedValue() + inRightUShort.getWrappedValue();
}


/*!
 *  \brief Add a UShort with a unsigned short.
 *  \param inLeftUShort Left value to add.
 *  \param inRightUShort Right value to add.
 *  \return Result of the addition.
 */
inline
Beagle::UShort operator+(const Beagle::UShort& inLeftUShort, unsigned short inRightUShort)
{
  return inLeftUShort.getWrappedValue() + inRightUShort;
}


/*!
 *  \brief Add a UShort to a UShort.
 *  \param inLeftUShort Left value to which the right one is added.
 *  \param inRightUShort Value to add.
 *  \return Result of the addition.
 */
inline
Beagle::UShort& operator+=(Beagle::UShort& inLeftUShort, const Beagle::UShort& inRightUShort)
{
  inLeftUShort.getWrappedValue() += inRightUShort.getWrappedValue();
  return inLeftUShort;
}


/*!
 *  \brief Add a unsigned short to a UShort.
 *  \param inLeftUShort Left value to which the right one is added.
 *  \param inRightUShort Value to add.
 *  \return Result of the addition.
 */
inline
Beagle::UShort& operator+=(Beagle::UShort& inLeftUShort, unsigned short inRightUShort)
{
  inLeftUShort.getWrappedValue() += inRightUShort;
  return inLeftUShort;
}


/*!
 *  \brief Decrement a UShort (prefix version).
 *  \param inUShort UShort to decrement.
 *  \return UShort decremented.
 */
inline
Beagle::UShort& operator--(Beagle::UShort& inUShort)
{
  inUShort.getWrappedValue()--;
  return inUShort;
}


/*!
 *  \brief Decrement a UShort (postfix version).
 *  \param inUShort UShort to decrement.
 *  \return UShort before being decremented.
 */
inline
Beagle::UShort operator--(Beagle::UShort& inUShort, int)
{
  Beagle::UShort lUShort = inUShort;
  inUShort.getWrappedValue()--;
  return lUShort;
}



/*!
 *  \brief Subtract two UShort.
 *  \param inLeftUShort Left value to subtract.
 *  \param inRightUShort Right value to subtract.
 *  \return Result of the subtract.
 */
inline
Beagle::UShort operator-(const Beagle::UShort& inLeftUShort, const Beagle::UShort& inRightUShort)
{
  return inLeftUShort.getWrappedValue() - inRightUShort.getWrappedValue();
}


/*!
 *  \brief Subtract a unsigned short from a UShort.
 *  \param inLeftUShort Left value to subtract.
 *  \param inRightUShort Right value to subtract.
 *  \return Result of the subtract.
 */
inline
Beagle::UShort operator-(const Beagle::UShort& inLeftUShort, unsigned short inRightUShort)
{
  return inLeftUShort.getWrappedValue() - inRightUShort;
}


/*!
 *  \brief Subtract a UShort from a UShort.
 *  \param inLeftUShort Left value from which the right unsigned short is subtracted.
 *  \param inRightUShort Value to subtract.
 *  \return Result of the subtraction.
 */
inline
Beagle::UShort& operator-=(Beagle::UShort& inLeftUShort, const Beagle::UShort& inRightUShort)
{
  inLeftUShort.getWrappedValue() -= inRightUShort.getWrappedValue();
  return inLeftUShort;
}


/*!
 *  \brief Subtract a unsigned short from a UShort.
 *  \param inLeftUShort Left value from which the right unsigned short is subtracted.
 *  \param inRightUShort Value to subtract.
 *  \return Result of the subtraction.
 */
inline
Beagle::UShort& operator-=(Beagle::UShort& inLeftUShort, unsigned short inRightUShort)
{
  inLeftUShort.getWrappedValue() -= inRightUShort;
  return inLeftUShort;
}


/*!
 *  \brief Multiply two UShort.
 *  \param inLeftUShort Left value to multiply.
 *  \param inRightUShort Right value to multiply.
 *  \return Result of the multiply.
 */
inline
Beagle::UShort operator*(const Beagle::UShort& inLeftUShort, const Beagle::UShort& inRightUShort)
{
  return inLeftUShort.getWrappedValue() * inRightUShort.getWrappedValue();
}


/*!
 *  \brief Multiply a UShort with a unsigned short.
 *  \param inLeftUShort Left value to multiply.
 *  \param inRightUShort Right value to multiply.
 *  \return Result of the multiply.
 */
inline
Beagle::UShort operator*(const Beagle::UShort& inLeftUShort, unsigned short inRightUShort)
{
  return inLeftUShort.getWrappedValue() * inRightUShort;
}


/*!
 *  \brief Multiply a UShort with a UShort.
 *  \param inLeftUShort Left value to which the right unsigned short is multiplied.
 *  \param inRightUShort Right value to multiply.
 *  \return Result of the multiplication.
 */
inline
Beagle::UShort& operator*=(Beagle::UShort& inLeftUShort, const Beagle::UShort& inRightUShort)
{
  inLeftUShort.getWrappedValue() *= inRightUShort.getWrappedValue();
  return inLeftUShort;
}


/*!
 *  \brief Multiply a UShort with a unsigned short.
 *  \param inLeftUShort Left value from which the right unsigned short is multiplied.
 *  \param inRightUShort Right value to multiply.
 *  \return Result of the multiplication.
 */
inline
Beagle::UShort& operator*=(Beagle::UShort& inLeftUShort, unsigned short inRightUShort)
{
  inLeftUShort.getWrappedValue() *= inRightUShort;
  return inLeftUShort;
}


/*!
 *  \brief Divide two UShort.
 *  \param inLeftUShort Left value to divide.
 *  \param inRightUShort Right value to divide.
 *  \return Result of the division.
 */
inline
Beagle::UShort operator/(const Beagle::UShort& inLeftUShort, const Beagle::UShort& inRightUShort)
{
  return inLeftUShort.getWrappedValue() / inRightUShort.getWrappedValue();
}


/*!
 *  \brief Divide a UShort with a unsigned short.
 *  \param inLeftUShort Left value to divide.
 *  \param inRightUShort Right value to divide.
 *  \return Result of the division.
 */
inline
Beagle::UShort operator/(const Beagle::UShort& inLeftUShort, unsigned short inRightUShort)
{
  return inLeftUShort.getWrappedValue() / inRightUShort;
}


/*!
 *  \brief Divide a UShort with a UShort.
 *  \param inLeftUShort Left value to which the right unsigned short is divided.
 *  \param inRightUShort Right value to divide.
 *  \return Result of the division.
 */
inline
Beagle::UShort& operator/=(Beagle::UShort& inLeftUShort, const Beagle::UShort& inRightUShort)
{
  inLeftUShort.getWrappedValue() /= inRightUShort.getWrappedValue();
  return inLeftUShort;
}


/*!
 *  \brief Divide a UShort with a unsigned short.
 *  \param inLeftUShort Left value from which the right unsigned short is divided.
 *  \param inRightUShort Right value to divide.
 *  \return Result of the division.
 */
inline
Beagle::UShort operator/=(Beagle::UShort& inLeftUShort, unsigned short inRightUShort)
{
  inLeftUShort.getWrappedValue() /= inRightUShort;
  return inLeftUShort;
}


#endif // Beagle_UShort_hpp



