head	1.1;
access;
symbols
	r2_1:1.1
	r2_0:1.1
	r1_1_beta:1.1
	r1_1_alpha:1.1
	r1_0:1.1
	r0_11:1.1
	r0_10:1.1;
locks; strict;
comment	@// @;


1.1
date	94.01.31.16.32.26;	author thoth;	state Exp;
branches;
next	;


desc
@Implementation of a conceptual bit (on or off).
Used in BitDI.
@


1.1
log
@Initial revision
@
text
@// Emacs -*- C++ -*-

// 	Copyright 1993, Center for Computer Vision and Visualization,
// 	University of Florida.  All rights reserved.


//
//  $Log: uchar-operations.desc,v $

#ifndef IA_Bit_h_
#define IA_Bit_h_

#include <iostream.h>

class IA_Bit {
    char	val;			/* always 0 or 1 */
public:
    IA_Bit() {}
    IA_Bit(int v) { val = (v!=0); }

    operator int () const { return val; }

    operator=(int v) { val = (v!=0); return *this; }

    friend int operator<=(IA_Bit lhs, IA_Bit rhs) { return lhs.val <= rhs.val;}
    friend int operator<(IA_Bit lhs, IA_Bit rhs) { return lhs.val < rhs.val; }
    friend operator==(IA_Bit lhs, IA_Bit rhs) { return lhs.val == rhs.val; }
    friend operator!=(IA_Bit lhs, IA_Bit rhs) { return lhs.val != rhs.val; }
    friend int operator>(IA_Bit lhs, IA_Bit rhs) { return lhs.val > rhs.val; }
    friend int operator>=(IA_Bit lhs, IA_Bit rhs) { return lhs.val >= rhs.val;}

    friend operator&(IA_Bit lhs, IA_Bit rhs) { return lhs.val & rhs.val; }
    friend operator|(IA_Bit lhs, IA_Bit rhs) { return lhs.val | rhs.val; }
    friend operator^(IA_Bit lhs, IA_Bit rhs) { return lhs.val ^ rhs.val; }
    IA_Bit & operator&=(IA_Bit arg) { val &= arg.val; return *this; }
    IA_Bit & operator|=(IA_Bit arg) { val |= arg.val; return *this; }
    IA_Bit & operator^=(IA_Bit arg) { val ^= arg.val; return *this; }
    operator!() const { return !val; }


    friend ostream & operator<<( ostream &o, IA_Bit b) {
	return o << (int)b.val;
    }
};

template <class T>
inline T operator*(IA_Bit b, T val) { return b ? val : 0; }

template <class T>
inline T operator*(T val, IA_Bit b) { return b ? val : 0; }

#endif // IA_Bit_h_
@
