| 1 | /**************************************************************************************** | 
|---|
| 2 |  | 
|---|
| 3 | Copyright (C) 2015 Autodesk, Inc. | 
|---|
| 4 | All rights reserved. | 
|---|
| 5 |  | 
|---|
| 6 | Use of this software is subject to the terms of the Autodesk license agreement | 
|---|
| 7 | provided at the time of installation or download, or which otherwise accompanies | 
|---|
| 8 | this software in either electronic or hard copy form. | 
|---|
| 9 |  | 
|---|
| 10 | ****************************************************************************************/ | 
|---|
| 11 |  | 
|---|
| 12 | //! \file fbxbitset.h | 
|---|
| 13 | #ifndef _FBXSDK_CORE_BASE_BITSET_H_ | 
|---|
| 14 | #define _FBXSDK_CORE_BASE_BITSET_H_ | 
|---|
| 15 |  | 
|---|
| 16 | #include <fbxsdk/fbxsdk_def.h> | 
|---|
| 17 |  | 
|---|
| 18 | #include <fbxsdk/fbxsdk_nsbegin.h> | 
|---|
| 19 |  | 
|---|
| 20 | /** An automatic growing array of bit. | 
|---|
| 21 | * | 
|---|
| 22 | * The bit array will automatically grow when specifying bit indexes that are greater | 
|---|
| 23 | * than the array size when calling SetBit or UnsetBit. Indexes can vary from 0 to | 
|---|
| 24 | * FBXSDK_UINT_MAX-1. When an invalid index is returned from any functions, FBXSDK_UINT_MAX | 
|---|
| 25 | * is returned. The bit array is not thread safe. | 
|---|
| 26 | */ | 
|---|
| 27 | class FBXSDK_DLL FbxBitSet | 
|---|
| 28 | { | 
|---|
| 29 | public: | 
|---|
| 30 | /** Constructor. | 
|---|
| 31 | * \param pInitialSize Initial bit array size in bit count (not in byte count!). | 
|---|
| 32 | */ | 
|---|
| 33 | FbxBitSet(const FbxUInt pInitialSize=0); | 
|---|
| 34 |  | 
|---|
| 35 | //! Destructor. | 
|---|
| 36 | virtual ~FbxBitSet(); | 
|---|
| 37 |  | 
|---|
| 38 | /** Set the bit at the specified bit index to true regardless of its current value. | 
|---|
| 39 | * \param pBitIndex The bit index in the array in the range of [0, FBXSDK_UINT_MAX-1]. | 
|---|
| 40 | */ | 
|---|
| 41 | void SetBit(const FbxUInt pBitIndex); | 
|---|
| 42 |  | 
|---|
| 43 | /** Set all the bits to the specified value regardless of their current value. | 
|---|
| 44 | * \param pValue The boolean value to set to all bits. | 
|---|
| 45 | */ | 
|---|
| 46 | void SetAllBits(const bool pValue); | 
|---|
| 47 |  | 
|---|
| 48 | /** Set the bit at the specified bit index to false regardless of its current value. | 
|---|
| 49 | * \param pBitIndex The bit index in the array in the range of [0, FBXSDK_UINT_MAX-1]. | 
|---|
| 50 | */ | 
|---|
| 51 | void UnsetBit(const FbxUInt pBitIndex); | 
|---|
| 52 |  | 
|---|
| 53 | /** Get the bit boolean value at the specified bit index. | 
|---|
| 54 | * \param pBitIndex The bit index in the array in the range of [0, FBXSDK_UINT_MAX-1]. | 
|---|
| 55 | * \return True if the bit is set, false otherwise. | 
|---|
| 56 | */ | 
|---|
| 57 | bool GetBit(const FbxUInt pBitIndex) const; | 
|---|
| 58 |  | 
|---|
| 59 | /** Get the bit index of the first bit that is currently set. | 
|---|
| 60 | * \return The bit index of the first set bit, FBXSDK_UINT_MAX if none found. | 
|---|
| 61 | */ | 
|---|
| 62 | FbxUInt GetFirstSetBitIndex() const; | 
|---|
| 63 |  | 
|---|
| 64 | /** Get the bit index of the last bit that is currently set. | 
|---|
| 65 | * \return The bit index of the last set bit, FBXSDK_UINT_MAX if none found. | 
|---|
| 66 | */ | 
|---|
| 67 | FbxUInt GetLastSetBitIndex() const; | 
|---|
| 68 |  | 
|---|
| 69 | /** Get the bit index of the next set bit after the specified bit index. | 
|---|
| 70 | * \param pBitIndex The start bit index in the array in the range of [0, FBXSDK_UINT_MAX-1]. | 
|---|
| 71 | * \return The bit index of the next set bit, FBXSDK_UINT_MAX if none found. | 
|---|
| 72 | */ | 
|---|
| 73 | FbxUInt GetNextSetBitIndex(const FbxUInt pBitIndex) const; | 
|---|
| 74 |  | 
|---|
| 75 | /** Get the bit index of the previous set bit before the specified bit index. | 
|---|
| 76 | * \param pBitIndex The start bit index in the array in the range of [0, FBXSDK_UINT_MAX-1]. | 
|---|
| 77 | * \return The bit index of the previous set bit, FBXSDK_UINT_MAX if none found. | 
|---|
| 78 | */ | 
|---|
| 79 | FbxUInt GetPreviousSetBitIndex(const FbxUInt pBitIndex) const; | 
|---|
| 80 |  | 
|---|
| 81 | private: | 
|---|
| 82 | void Grow(const FbxUInt pNewSize); | 
|---|
| 83 |  | 
|---|
| 84 | void* mData; | 
|---|
| 85 | FbxUInt mSize; | 
|---|
| 86 | }; | 
|---|
| 87 |  | 
|---|
| 88 | #include <fbxsdk/fbxsdk_nsend.h> | 
|---|
| 89 |  | 
|---|
| 90 | #endif /* _FBXSDK_CORE_BASE_BITSET_H_ */ | 
|---|
| 91 |  | 
|---|