TuttleOFX  1
TuttleOFX/libraries/tuttle/src/tuttle/host/memory/IMemoryPool.hpp
Go to the documentation of this file.
00001 #ifndef _TUTTLE_HOST_CORE_IMEMORYPOOL_HPP_
00002 #define _TUTTLE_HOST_CORE_IMEMORYPOOL_HPP_
00003 
00004 #include <cstddef>
00005 #include <stdexcept>
00006 #include <boost/smart_ptr/intrusive_ptr.hpp>
00007 
00008 namespace tuttle {
00009 namespace host {
00010 namespace memory {
00011 
00012 class IUnknown
00013 {
00014 public:
00015         virtual ~IUnknown()    = 0;
00016         virtual void addRef()  = 0;
00017         virtual void release() = 0;
00018 };
00019 
00020 class IPoolData : public IUnknown
00021 {
00022 public:
00023         virtual ~IPoolData ()                     = 0;
00024 
00025         virtual char*        data()               = 0;
00026         virtual const char*  data() const         = 0;
00027         virtual const size_t size() const         = 0;
00028         virtual const size_t reservedSize() const = 0;
00029 
00030         virtual void setSize( const std::size_t newSize ) = 0;
00031 };
00032 
00033 void intrusive_ptr_add_ref( IPoolData* pData );
00034 void intrusive_ptr_release( IPoolData* pData );
00035 
00036 typedef ::boost::intrusive_ptr<IPoolData> IPoolDataPtr;
00037 
00038 class IMemoryPool
00039 {
00040 public:
00041         virtual ~IMemoryPool()                               = 0;
00042         virtual size_t       getUsedMemorySize() const       = 0;
00043         virtual std::size_t  getAllocatedAndUnusedMemorySize() const = 0;
00044         virtual size_t       getAllocatedMemorySize() const  = 0;
00045         virtual size_t       getAvailableMemorySize() const  = 0;
00046         virtual size_t       getWastedMemorySize() const     = 0;
00047         virtual size_t       getMaxMemorySize() const        = 0;
00048         virtual void         clear( size_t size )            = 0;
00049         virtual void         clearOne()                      = 0;
00050         virtual void         clear()                         = 0;
00051         virtual IPoolDataPtr allocate( const size_t size )   = 0;
00052         virtual std::size_t  updateMemoryAuthorizedWithRAM() = 0;
00053 };
00054 
00055 }
00056 }
00057 }
00058 
00059 #endif