CrossFramework Library
|
00001 00006 #if defined(XBASE_INCLUDED_AUTOMEMBLOCK_HPP) 00007 #else 00008 #define XBASE_INCLUDED_AUTOMEMBLOCK_HPP 00009 00010 //------------------------------------------------------------ 00011 #include <XBase/IAllocator.hpp> 00012 #include <XBase/MemBlock.hpp> 00013 #include <XBase/Pointer.hpp> 00014 00015 //------------------------------------------------------------ 00016 namespace XBase { 00017 class IAllocator; 00018 } 00019 00020 //------------------------------------------------------------ 00021 namespace XBase { 00023 00024 00030 class AutoMemBlock 00031 { 00032 public: 00034 00035 00036 AutoMemBlock(); 00037 00042 AutoMemBlock( pword_t aSize , IAllocator& aAllocator = IAllocator::Default() , pword_t aAlignment = IAllocator::DefaultAlignment ); 00043 00049 AutoMemBlock( const MemBlock& aBlock , IAllocator& aAllocator ); 00050 00052 AutoMemBlock( const AutoMemBlock& ); 00053 00055 ~AutoMemBlock(); 00057 00059 00060 00064 bool isEmpty()const; 00065 00070 void clear(); 00071 00073 const MemBlock& ref()const; 00075 00077 00078 00079 AutoMemBlock& operator=( const AutoMemBlock& aRHS ); 00080 00082 const MemBlock& operator*()const; 00083 00085 const MemBlock* operator->()const; 00087 00088 private: 00089 mutable MemBlock mBlock; 00090 mutable Pointer< IAllocator > mAllocatorPtr; 00091 }; 00093 } 00094 //------------------------------------------------------------ 00095 #endif 00096 // EOF