Definition at line 22 of file fbxarray.h.
#include <fbxarray.h>
Classes |
|
| struct | Header |
Public Member Functions |
|
| int | GetCount () const |
| Get number of pointers in the array.
|
|
| void | Clear () |
| Remove all pointers without deleting the
associated objects. |
|
| void | Empty () |
| Fast empty, set object count to zero but
don't free any memory. |
|
| int | Reserve (int pCapacity) |
| Set array capacity to contain at least the
specified number of elements without reallocating. |
|
| void | SetCount (int pCount) |
| Set arrayCount to specified number of
elements. The array capacity is adjusted accordingly. |
|
| void | Resize (int pItemCount) |
| void | AddMultiple (int pItemCount) |
Protected Member Functions |
|
| FbxArrayBase () | |
| Constructor. |
|
| ~FbxArrayBase () | |
| Destructor. |
|
| int | InsertAt (int pIndex, void *pItem) |
| Insert an item at the given position.
|
|
| void * | GetAt (int pIndex) |
| Get the item at the given position. |
|
| void | RemoveAt (int pIndex) |
| Removes the item at the given position.
|
|
| bool | ValidateIndex (int pIndex) const |
| Check that the given position is inside the
array boundaries. |
|
| Header *const | GetHeader () const |
| Header * | GetHeader () |
| int | GetHeaderOffset () const |
| int | GetArrayCount () const |
| void | SetArrayCount (int pArrayCount) |
| int | GetBlockCount () const |
| void | SetBlockCount (int pArrayCount) |
Protected Attributes |
|
| int | mArrayCount |
| char * | mBaseArray |
| FbxArrayBase | ( | ) | [inline, protected] |
| ~FbxArrayBase | ( | ) | [inline, protected] |
| int GetCount | ( | ) | const [inline] |
Get number of pointers in the array.
Definition at line 28 of file fbxarray.h.
{ return GetArrayCount(); }
| void Clear | ( | ) | [inline] |
Remove all pointers without deleting the associated objects.
Definition at line 31 of file fbxarray.h.
{
if (mBaseArray!=NULL)
{
FbxFree(mBaseArray);
mArrayCount = 0;
mBaseArray = NULL;
}
}
| void Empty | ( | ) | [inline] |
Fast empty, set object count to zero but don't free any memory.
Definition at line 43 of file fbxarray.h.
{
#ifdef _DEBUG
memset( mBaseArray+ GetHeaderOffset() ,0,GetArrayCount()*TypeSize);
#endif
SetArrayCount(0);
}
| int Reserve | ( | int | pCapacity | ) | [inline] |
Set array capacity to contain at least the specified number of elements without reallocating.
| pCapacity | Number of items that can be stored in the array before reallocating the memory. |
Definition at line 57 of file fbxarray.h.
{
FBX_ASSERT( pCapacity > 0 );
if( pCapacity )
{
const FbxUInt lTempNewBlockCount = ( (FbxUInt) (pCapacity + FBXSDK_ARRAY_BLOCKSIZE - 1 ) / FBXSDK_ARRAY_BLOCKSIZE );
const FbxUInt lNewBlockCount = (lTempNewBlockCount > 1 ? lTempNewBlockCount : 1);
int lArrayCount = GetArrayCount();
int lBlockCount = GetBlockCount();
const FbxUInt lOldArraySize = lArrayCount*TypeSize;
const FbxUInt lNewArraySize = lNewBlockCount*FBXSDK_ARRAY_BLOCKSIZE*TypeSize;
if (lNewBlockCount != (FbxUInt) lBlockCount)
{
char* lBaseArray = (char*)FbxRealloc(mBaseArray, (size_t) lNewArraySize+ GetHeaderOffset() );
if (!lBaseArray)
return GetBlockCount()*FBXSDK_ARRAY_BLOCKSIZE;
mBaseArray = lBaseArray;
}
if( lNewBlockCount > (FbxUInt) lBlockCount ) {
memset( ((char*)mBaseArray+ GetHeaderOffset() ) + lOldArraySize, 0, (size_t) (lNewArraySize-lOldArraySize) );
SetArrayCount(lArrayCount);
} else if (pCapacity < lArrayCount)
{
memset( ((char*)mBaseArray+ GetHeaderOffset() ) + pCapacity*TypeSize, 0, (size_t) (lNewArraySize-pCapacity*TypeSize) );
SetArrayCount(pCapacity);
}
SetBlockCount(lNewBlockCount);
}
return GetBlockCount()*FBXSDK_ARRAY_BLOCKSIZE;
}
| void SetCount | ( | int | pCount | ) | [inline] |
Set arrayCount to specified number of elements. The array capacity is adjusted accordingly.
Force the array of elements to a given size.
Definition at line 104 of file fbxarray.h.
{
#ifdef _DEBUG
if (pCount<0)
{
FBX_ASSERT_NOW ("ArrayUL : Item count can't be negative");
return ;
}
#endif
int lArrayCount = GetArrayCount();
if (pCount > lArrayCount)
{
AddMultiple( pCount-lArrayCount);
}
else
{
SetArrayCount(pCount);
}
}
| void Resize | ( | int | pItemCount | ) | [inline] |
Definition at line 124 of file fbxarray.h.
{
FBX_ASSERT( pItemCount >= 0 );
const FbxUInt lTempNewBlockCount = ( (FbxUInt) (pItemCount + FBXSDK_ARRAY_BLOCKSIZE - 1 ) / FBXSDK_ARRAY_BLOCKSIZE );
const FbxUInt lNewBlockCount = (lTempNewBlockCount > 1 ? lTempNewBlockCount : 1);
int lArrayCount = GetArrayCount();
int lBlockCount = GetBlockCount();
const FbxUInt lOldArraySize = lArrayCount*TypeSize;
const FbxUInt lNewArraySize = lNewBlockCount*FBXSDK_ARRAY_BLOCKSIZE*TypeSize;
if (lNewBlockCount != (FbxUInt) lBlockCount)
{
char* lBaseArray = (char*)FbxRealloc(mBaseArray, (size_t) lNewArraySize+ GetHeaderOffset() );
if (!lBaseArray)
return;
mBaseArray = lBaseArray;
}
if( lNewBlockCount > (FbxUInt) lBlockCount )
{
memset( ((char*)mBaseArray+ GetHeaderOffset() ) + lOldArraySize, 0, (size_t) (lNewArraySize-lOldArraySize) );
}
else if (pItemCount < lArrayCount)
{
memset( ((char*)mBaseArray+ GetHeaderOffset() ) + pItemCount*TypeSize, 0, (size_t) (lNewArraySize-pItemCount*TypeSize) );
}
SetBlockCount(lNewBlockCount);
SetArrayCount(pItemCount);
}
| void AddMultiple | ( | int | pItemCount | ) | [inline] |
Definition at line 158 of file fbxarray.h.
{
FBX_ASSERT( pItemCount > 0 );
if( pItemCount )
{
int lArrayCount = GetArrayCount();
int lBlockCount = GetBlockCount();
const FbxUInt lTempNewBlockCount = ( (FbxUInt) (lArrayCount+pItemCount + FBXSDK_ARRAY_BLOCKSIZE - 1 ) / FBXSDK_ARRAY_BLOCKSIZE );
const FbxUInt lNewBlockCount = (lTempNewBlockCount > 1 ? lTempNewBlockCount : 1);
const FbxUInt lOldArraySize = lArrayCount*TypeSize;
const FbxUInt lNewArraySize = lNewBlockCount*FBXSDK_ARRAY_BLOCKSIZE*TypeSize;
FBX_ASSERT( lOldArraySize < lNewArraySize );
if( lNewBlockCount > (FbxUInt) lBlockCount )
{
char* lBaseArray = (char*)FbxRealloc(mBaseArray, (size_t) lNewArraySize+ GetHeaderOffset() );
if (!lBaseArray)
return;
mBaseArray = lBaseArray;
lBlockCount = lNewBlockCount;
}
memset( ((char*)mBaseArray+ GetHeaderOffset() ) + lOldArraySize, 0, (size_t) (lNewArraySize-lOldArraySize) );
SetArrayCount ( lArrayCount + pItemCount );
SetBlockCount (lBlockCount);
}
}
| int InsertAt | ( | int | pIndex, |
| void * | pItem | ||
| ) | [inline, protected] |
Insert an item at the given position.
| pIndex | Position where to insert the item. |
| pItem | Pointer to the item to be inserted. |
Reimplemented in FbxArray< void * >.
Definition at line 220 of file fbxarray.h.
{
int lArrayCount = GetArrayCount();
int lBlockCount = GetBlockCount();
FBX_ASSERT( pIndex >= 0 );
if (pIndex>lArrayCount) {
pIndex = GetArrayCount();
}
if (lArrayCount>= lBlockCount*FBXSDK_ARRAY_BLOCKSIZE)
{
// must Alloc.Realloc some new space
// double the number of blocks.
lBlockCount = ( 0 == lBlockCount ) ? 1 : lBlockCount * 2;
char* lBaseArray = (char*)FbxRealloc(mBaseArray, (size_t) (lBlockCount*FBXSDK_ARRAY_BLOCKSIZE*TypeSize) + GetHeaderOffset() );
if(!lBaseArray)
return -1;
mBaseArray = lBaseArray;
}
if (pIndex<lArrayCount)
{
// This is an insert
memmove (&(mBaseArray[(pIndex+1)*TypeSize+ GetHeaderOffset() ]), &(mBaseArray[(pIndex)*TypeSize+ GetHeaderOffset()] ), TypeSize*(lArrayCount-pIndex));
}
memmove (&(mBaseArray[(pIndex)*TypeSize+ GetHeaderOffset() ]), pItem, TypeSize);
SetArrayCount(lArrayCount+1);
SetBlockCount(lBlockCount);
return pIndex;
}
| void* GetAt | ( | int | pIndex | ) | [inline, protected] |
Get the item at the given position.
| pIndex | The position of the item to access. |
Definition at line 264 of file fbxarray.h.
{ return &(mBaseArray[(pIndex)*TypeSize+ GetHeaderOffset() ]); }
| void RemoveAt | ( | int | pIndex | ) | [inline, protected] |
Removes the item at the given position.
| pIndex | The position of the item to remove. |
Reimplemented in FbxArray< Type >, FbxArray< FbxNode * >, FbxArray< FbxAnimCurveNode * >, FbxArray< FbxProperty >, FbxArray< double >, FbxArray< FbxDocument * >, FbxArray< FbxArray< Element > * >, FbxArray< int >, FbxArray< AESequence * >, FbxArray< FbxDataType >, FbxArray< ReaderPluginEntry * >, FbxArray< FbxLayerElement * >, FbxArray< WriterPluginEntry * >, FbxArray< FbxPropertyPage * >, FbxArray< FbxXRefManagerProject * >, FbxArray< InputData >, FbxArray< FbxArray< int > * >, FbxArray< FbxTakeInfo * >, FbxArray< FbxString * >, FbxArray< FbxAccumulatorEntry * >, FbxArray< Type * >, FbxArray< PolygonDef >, FbxArray< void * >, FbxArray< FbxPoseInfo * >, FbxArray< FbxTakeLayerInfo * >, FbxArray< char >, FbxArray< ModifiedPropertyInfo * >, FbxArray< FbxObject * >, FbxArray< FbxMesh * >, FbxArray< NameCell * >, FbxArray< FbxStringListItem * >, FbxArray< FbxTexture * >, FbxArray< FbxLayer * >, FbxArray< FbxVector4 >, FbxArray< FbxConnectionPoint * >, FbxArray< ListItem * >, FbxArray< FbxSceneReference * >, FbxArray< xmlNode * >, and FbxArray< FbxLocalizationManager * >.
Definition at line 272 of file fbxarray.h.
{
#if defined(_DEBUG) && !defined(FBXSDK_ENV_MAC)
if (!ValidateIndex( pIndex ))
{
return;
}
#endif
int lArrayCount = GetArrayCount();
if (pIndex+1<lArrayCount)
{
memmove (&(mBaseArray[(pIndex)*TypeSize+ GetHeaderOffset() ]), &(mBaseArray[(pIndex+1)*TypeSize+ GetHeaderOffset() ]), TypeSize*(lArrayCount-pIndex-1));
}
SetArrayCount( lArrayCount-1 );
#ifdef _DEBUG
memset( &(mBaseArray[(GetArrayCount())*TypeSize+ GetHeaderOffset() ]),0,TypeSize);
#endif
}
| bool ValidateIndex | ( | int | pIndex | ) | const [inline, protected] |
Check that the given position is inside the array boundaries.
| pIndex | Index value to validate. |
true if the index value is within the array
boundaries. false otherwise.Definition at line 300 of file fbxarray.h.
{
int lArrayCount = GetArrayCount();
if (pIndex>=0 && pIndex<lArrayCount)
{
return true;
}
else
{
FBX_ASSERT_NOW("Array : Index out of range");
return false;
}
}
| Header* const GetHeader | ( | ) | const [inline, protected] |
Definition at line 314 of file fbxarray.h.
{
return (Header* const)mBaseArray;
}
| Header* GetHeader | ( | ) | [inline, protected] |
Definition at line 318 of file fbxarray.h.
{
return (Header*)mBaseArray;
}
| int GetHeaderOffset | ( | ) | const [inline, protected] |
| int GetArrayCount | ( | ) | const [inline, protected] |
| void SetArrayCount | ( | int | pArrayCount | ) | [inline, protected] |
Definition at line 330 of file fbxarray.h.
{
mArrayCount = pArrayCount;
}
| int GetBlockCount | ( | ) | const [inline, protected] |
Definition at line 334 of file fbxarray.h.
{
return GetHeader() ? GetHeader()->mBlockCount : 0;
}
| void SetBlockCount | ( | int | pArrayCount | ) | [inline, protected] |
Definition at line 338 of file fbxarray.h.
{
if (GetHeader()) GetHeader()->mBlockCount = pArrayCount;
}
int mArrayCount
[protected] |
Definition at line 343 of file fbxarray.h.
char* mBaseArray
[protected] |
Definition at line 344 of file fbxarray.h.