Main Page | Namespace List | Class Hierarchy | Class List | File List | Class Members | File Members

SerializableBitSet.h

Go to the documentation of this file.
00001 #ifndef _SERIALIZABLEBITSET_H 00002 #define _SERIALIZABLEBITSET_H 00003 00004 #include "Exceptions.h" 00005 00006 BOREALIS_NAMESPACE_BEGIN; 00007 00008 class SerializableBitSet 00009 { 00010 public: 00011 // Creates a bitset with numBits, numbered 0...(numBits-1), 00012 // that are all initialized to 'false'. 00013 SerializableBitSet(int numBits) 00014 throw (exception); 00015 00016 SerializableBitSet(const SerializableBitSet & src) 00017 throw (exception); 00018 00019 virtual ~SerializableBitSet(); 00020 00021 // Populates the bitset from the specified file. 00022 // The file pointer must be positioned at the first byte of the 00023 // bitset data. This will read from the file exactly as many bytes 00024 // as are needed to contain the number of bits stored by this bitset. 00025 void load(int fd) 00026 throw (std::exception); 00027 00028 // Writes the bitset's data to the specified file. 00029 // The file pointer must be positioned at the first byte where the bitset 00030 // is to be written to. This will write to the file exactly as many bytes 00031 // as are needed to contain the number of bits stored by this bitset. 00032 void save(int fd) const 00033 throw (std::exception); 00034 00035 // Bit counting is zero-based (0... (numBits - 1)). 00036 bool testBit(int bitNum) const 00037 throw (std::exception); 00038 00039 // Bit counting is zero-based (0... (numBits - 1)). 00040 void setBit(int bitNum, bool newValue) 00041 throw (std::exception); 00042 00043 // Returns the number of bits in the bit set with the specified value. 00044 int getBitCountForValue(bool value) const; 00045 00046 // Returns the lowest index of the bits in the bitset that have the 00047 // specified value. 00048 // Returns -1 if no bit in the bitset has the specified value. 00049 int getFirstIdxForValue(bool value) const; 00050 00051 SerializableBitSet & operator= (const SerializableBitSet & rhs) 00052 throw (exception); 00053 00054 bool operator==(const SerializableBitSet & rhs) const; 00055 00056 private: 00057 unsigned char *_pData; 00058 int _numDataBits; 00059 int _numDataBytes; 00060 00061 int _numTrueBits; 00062 int _numFalseBits; 00063 }; 00064 00065 BOREALIS_NAMESPACE_END; 00066 00067 #endif

Generated on Fri Nov 12 15:15:22 2004 for Borealis by doxygen 1.3.8