00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #if !defined(BITBLOCK_HPP)
00012 #define BITBLOCK_HPP
00013 #include "gtypes.h"
00014 #include <string.h>
00015 #include <iostream.h>
00016 #include "gtbuffer.hpp"
00017
00018
00019 class BitBlock
00020 {
00021 public:
00022 BitBlock(GINT Size);
00023 ~BitBlock();
00024 BitBlock(const BitBlock &a);
00025 BitBlock &operator=(const BitBlock &);
00026 GUSHORT operator()(const GINT bit_posn);
00027 GUSHORT operator[](const GINT bit_posn);
00028 friend ostream& operator<<(ostream&, BitBlock&);
00029
00030 void SetBits(GINT bit_index, const GUSHORT yTo);
00031
00032 GBOOL SetBlock(GUSHORT *new_block, GINT num_subblocks);
00033 GBOOL SetBlock(GUSHORT *new_block, GINT num_subblocks, GINT size_subblock, GINT desired_bitspersubblock);
00034 GBOOL SetBlock(GBuffer<GUSHORT > *new_block, GINT num_subblocks);
00035 GBOOL SetBlock(GUSHORT *hi_block, GUSHORT *lo_block, GINT n);
00036 GUSHORT *GetBlock();
00037 void *LoWord();
00038 void *HiWord();
00039 GINT GetBlockSize_InBits();
00040 GINT GetBlockSize_InBlocks();
00041 void Reset();
00042 void TransferBits(void *in_elems, GINT nelems, size_t elem_size);
00043
00044
00045 private:
00046
00047 GUSHORT getbits_(GUSHORT , int posn, int numbits);
00048 GUSHORT setbits_(GUSHORT , int posn, int numbits, GUSHORT y);
00049
00050
00051 GUSHORT *iBlock;
00052 GINT BitFieldLength;
00053 GINT nBits;
00054 GINT NumIntSubBlocks;
00055
00056 };
00057 #endif
00058