/*
 *  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, G1K 7P4
 *  http://vision.gel.ulaval.ca
 *
 */

/*!
 *  \file   beagle/ULong.hpp
 *  \brief  Definition of the type ULong and related operators.
 *  \author Christian Gagne
 *  \author Marc Parizeau
 *  $Revision: 1.3 $
 *  $Date: 2004/04/25 23:12:21 $
 */

#ifndef Beagle_ULong_hpp
#define Beagle_ULong_hpp

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


namespace Beagle {

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

}


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


/*!
 *  \brief  Test whether an unsigned long is less than, or equal to another.
 *  \param  inLeftULong  Left unsigned long compared.
 *  \param  inRightULong Right unsigned long compared.
 *  \return True if left unsigned long 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::ULong.
 */
inline bool operator<=(const Beagle::ULong& inLeftULong, const Beagle::ULong& inRightULong)
{
  return ( inLeftULong.isLess(inRightULong) || inLeftULong.isEqual(inRightULong) );
}


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


/*!
 *  \brief  Test whether an unsigned long is more than, or equal to another.
 *  \param  inLeftULong  Left unsigned long compared.
 *  \param  inRightULong Right unsigned long compared.
 *  \return True if left unsigned long 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::ULong.
 */
inline bool operator>=(const Beagle::ULong& inLeftULong, const Beagle::ULong& inRightULong)
{
  return ( inRightULong.isLess(inLeftULong) || inLeftULong.isEqual(inRightULong) );
}


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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



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


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


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


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


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


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


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


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


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


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


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


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


#endif // Beagle_ULong_hpp



