/*
 *  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/Long.hpp
 *  \brief  Definition of the type Long and related operators.
 *  \author Christian Gagne
 *  \author Marc Parizeau
 *  $Revision: 1.2 $
 *  $Date: 2004/01/15 21:08:57 $
 */

#ifndef Beagle_Long_hpp
#define Beagle_Long_hpp

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


namespace Beagle {

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

}


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


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


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


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


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


/*!
 *  \brief  Test whether an long is not equal to another.
 *  \param  inLeftLong  Left long compared.
 *  \param  inRightLong Right long compared.
 *  \return True if left 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::Long.
 */
inline bool operator!=(const Beagle::Long& inLeftLong, const Beagle::Long& inRightLong)
{
  return ( inLeftLong.isEqual(inRightLong) == false);
}


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


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


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


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


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


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


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


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


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


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


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


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


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


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



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


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


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


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


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


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


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


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


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


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


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


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


#endif // Beagle_Long_hpp



