#ifndef BitSet16_HEADER #define BitSet16_HEADER 1 ////////////////////////////////////////////////////////////////////////// //! file="amma/BasType/BitSet16.hh" //! lib=Mtype //! userlevel=Normal //! author="Charles Galambos" //! date="9/12/1996" //! docentry="Basic Types.Misc" //! rcsid="$Id: BitSet16.hh,v 1.5 1998/05/14 15:09:37 ees1cg Exp $" #include "amma/Boolean.hh" #include "amma/StdTypeA.hh" //: Class BitSet16C is the set of 16 logical flags. // Assumes integers are at least 16 bit. class BitSet16C { public: // Constructors, copies, assigment, and destructor // ----------------------------------------------- BitSet16C() : Bits(0) { } // Default constructor. BitSet16C(IntT Value) : Bits(Value) { } // Default constructor. BitSet16C(const BitSet16C &Oth) : Bits(Oth.Bits) {} // Copy constructor. // Modifications of flags // ---------------------- void ZeroAll(void) { Bits = 0; } // Zero all bits. void SetAll(void) { Bits = 0xffffffff; } // Set all bits to 1. void Zero(IntT ABit) { Bits &= ~(1 << ABit); } // Set bit to zero. void Set(IntT ABit) { Bits |= (1 << ABit); } // Set bit to one. // Access to information about the object // -------------------------------------- BooleanT operator[](IntT ABit) const { return (Bits & (1 << ABit)) != 0; } // Test a bit. BooleanT IsEmpty(void) const { return Bits == 0; } // Are all bits zero ? IntT Dim(void) const { return 16; } // Number of bits. private: // The representation of the object // -------------------------------- IntT Bits; // This should be 32-bits long. }; #endif