fbxmemory.h

Go to the documentation of this file.
00001 /****************************************************************************************
00002  
00003    Copyright (C) 2012 Autodesk, Inc.
00004    All rights reserved.
00005  
00006    Use of this software is subject to the terms of the Autodesk license agreement
00007    provided at the time of installation or download, or which otherwise accompanies
00008    this software in either electronic or hard copy form.
00009  
00010 ****************************************************************************************/
00011 
00013 #ifndef _FBXSDK_CORE_BASE_MEMORY_H_
00014 #define _FBXSDK_CORE_BASE_MEMORY_H_
00015 
00016 #include <fbxsdk/fbxsdk_def.h>
00017 
00018 #include <fbxsdk/fbxsdk_nsbegin.h>
00019 
00021 //  WARNING!
00022 //  Anything beyond these lines may not be documented accurately and is
00023 //  subject to change without notice.
00025 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00026 
00027 class FBXSDK_DLL FbxPointerFreeGuard
00028 {
00029 public:
00030     FbxPointerFreeGuard(void* pPtr=NULL);
00031     virtual ~FbxPointerFreeGuard();
00032 
00033     void SetPointer(void* pPtr);
00034 
00035 private:
00036     void* mPtr;
00037 };
00038 
00039 #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS
00040 
00043 class FBXSDK_DLL FbxMemoryPool
00044 {
00045 public:
00053     FbxMemoryPool(size_t pBlockSize=0, size_t pBlockCount=0, bool pAlignment=false, bool pResizable=true, bool pSupportConcurrentAccess=true);
00054     virtual ~FbxMemoryPool();
00055 
00062     void Init(size_t pBlockSize, size_t pBlockCount=0, bool pAlignment=false, bool pResizable=true);
00063 
00065     void Clear();
00066 
00070     void* Allocate();
00071 
00076     void Free(void* pMemBlock);
00077 
00078 private:
00079     void        InitVars();
00080     void*       Pop();
00081 
00082     FbxAtomic   mCountFreeBlock;
00083     void*       mFreeBlocks;
00084     size_t      mBlockSize;
00085     bool        mAlignment;
00086     bool        mResizable;
00087     bool        mSupportConcurrentAccess;
00088 };
00089 
00090 #include <fbxsdk/fbxsdk_nsend.h>
00091 
00092 #endif /* _FBXSDK_CORE_BASE_MEMORY_H_ */