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

#ifndef Beagle_Bool_hpp
#define Beagle_Bool_hpp

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


namespace Beagle {

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

}


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


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


/*!
 *  \brief   Negate a Bool.
 *  \param   inBool Bool to negate.
 *  \return  Result of the negation.
 */
inline
Beagle::Bool operator!(const Beagle::Bool& inBool)
{
  return !(inBool.getWrappedValue());
}


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


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


/*!
 *  \brief   Logical AND of a Bool with a Bool.
 *  \param   inLeftBool Left value.
 *  \param   inRightBool Right value.
 *  \return  Result of the logical AND.
 */
inline
Beagle::Bool operator&&(const Beagle::Bool& inLeftBool,
                        const Beagle::Bool& inRightBool)
{
  return inLeftBool.getWrappedValue() && inRightBool.getWrappedValue();
}


/*!
 *  \brief   Logical AND of a Bool with a bool.
 *  \param   inLeftBool Left value.
 *  \param   inRightBool Right value.
 *  \return  Result of the logical AND.
 */
inline
Beagle::Bool operator&&(const Beagle::Bool& inLeftBool, bool inRightBool)
{
  return inLeftBool.getWrappedValue() && inRightBool;
}


/*!
 *  \brief   Logical OR of a Bool with a Bool.
 *  \param   inLeftBool Left value.
 *  \param   inRightBool Right value.
 *  \return  Result of the logical OR.
 */
inline
Beagle::Bool operator||(const Beagle::Bool& inLeftBool,
                        const Beagle::Bool& inRightBool)
{
  return inLeftBool.getWrappedValue() || inRightBool.getWrappedValue();
}


/*!
 *  \brief   Logical OR of a Bool with a bool.
 *  \param   inLeftBool Left value.
 *  \param   inRightBool Right value.
 *  \return  Result of the logical OR.
 */
inline
Beagle::Bool operator||(const Beagle::Bool& inLeftBool, bool inRightBool)
{
  return inLeftBool.getWrappedValue() || inRightBool;
}


#endif // Beagle_Bool_hpp



