73 lines
1.9 KiB
C++
73 lines
1.9 KiB
C++
//-----------------------------------------------------------------------------+
|
|
// Copyright (C), 1998-2007, SH Software Co. Ltd.
|
|
// = FileName : BitTable.h
|
|
// = Version : ver2.0
|
|
// = Author : zjq
|
|
// = CreateDate : 2002-09-09
|
|
// = Description: 类的声明,位数组,以位或位单元的模式来进行数据读写和内存分配,用于大规模控制矩阵
|
|
// = Maintainers:
|
|
//
|
|
//-----------------------------------------------------------------------------+
|
|
#ifndef _BITTABLE_H_
|
|
#define _BITTABLE_H_
|
|
|
|
class GEOAPI BitTable
|
|
{
|
|
public:
|
|
BitTable(long unitNum, long unitSize = 1);
|
|
BitTable(void* p, long byteSize, bool bClient = true);
|
|
BitTable& operator = (const BitTable& bTable);
|
|
void Attach(long byteSize, char *p);
|
|
char* Detach();
|
|
~BitTable();
|
|
|
|
//位数转字节数
|
|
static long BitToByte(long bitNum);
|
|
bool IsValidIndex(long i) const;
|
|
long GetLength() const;
|
|
long GetByteSize() const;
|
|
long GetBitSize() const;
|
|
void SetUnitSize(long size);
|
|
long GetUnitSize() const;
|
|
//新单元数
|
|
void Realloc(long unitNum);
|
|
|
|
//bit read/write,使用位索引,非单元索引!
|
|
bool operator[](long i);
|
|
void Set(long i);
|
|
void Reset(long i);
|
|
|
|
//unit read/write
|
|
//取单元值
|
|
long GetValue(long i) const;
|
|
//单元赋值
|
|
void SetValue(long i,char value);
|
|
void SetAll(char value);
|
|
void SetAll();
|
|
void Reset();
|
|
|
|
//data transfer
|
|
operator char() const;
|
|
operator int() const;
|
|
operator float() const;
|
|
operator double() const;
|
|
operator const char*() const;
|
|
operator const int*() const;
|
|
operator const float*() const;
|
|
operator const double*() const;
|
|
|
|
protected:
|
|
//位定位
|
|
void BitToByte(long i, long& byteIndex,long& bitIndex) const;
|
|
//单元定位
|
|
void UnitToByte(long i, long& byteIndex,long& bitIndex) const;
|
|
|
|
protected:
|
|
long length; //unit num
|
|
long unit; //unit length; 仅支持1,2,4
|
|
char *pData;
|
|
bool bOwner; //是否数据代理
|
|
};
|
|
|
|
#endif
|