#include <utilities/memory_handler.h>
Открытые члены | |
| template<class stored_type > | |
| stored_type * | Allocate (PointerInterface *Ptr, const std::size_t ItemCount, const std::string &BlockDescription="") |
| template<class stored_type > | |
| void | Deallocate (stored_type *DeallocatingData) |
| template<class stored_type > | |
| void | Copy (stored_type *&Ptr1, stored_type *&Ptr2) |
Закрытые данные | |
| std::vector< MemoryDescription > | MemoryDesriptions |
Класс для хранения данных обо всех выделенных блоках.
См. определение в файле memory_handler.h строка 219
| stored_type * nitro::MemoryHandler::Allocate | ( | PointerInterface * | Ptr, | |
| const std::size_t | ItemCount, | |||
| const std::string & | BlockDescription = "" | |||
| ) |
Функция для выделения памяти.
| Ptr | - . | |
| ItemCount | - . | |
| BlockDescription | - Описание блока выделенной памяти. |
| nitro::exception | Кидается исключение этого типа с описанием ошибки и её кодом. |
См. определение в файле memory_handler.h строка 347
Перекрестные ссылки nitro::exception::code(), MemoryDesriptions и nitro::exception::what().
{
try
{
stored_type * Ptr( new stored_type[ ItemCount ] );
for( std::size_t i( 0 ) ; i < MemoryDesriptions.size() ; i++ )
{
if( MemoryDesriptions[ i ].AddressIn( PtrI ) )
{
MemoryDesriptions[ i ].RegisterPointer( PtrI );
}
}
MemoryDesriptions.push_back( MemoryDescription( ( void * )Ptr , sizeof( stored_type ) * ItemCount , BlockDescription ) );
return( Ptr );
}
catch( nitro::exception e )
{
throw( nitro::exception( std::string( "MemoryHandler::Allocate( PointerInterface * PtrI , const std::size_t ItemCount , const std::string & BlockDescription /* = "" */ )::" ) + e.what() , e.code() ) );
}
catch( ... )
{
throw( nitro::exception( std::string( "MemoryHandler::Allocate( PointerInterface * PtrI , const std::size_t ItemCount , const std::string & BlockDescription /* = "" */ )::An error occured" ) , 0 ) );
}
}

| void nitro::MemoryHandler::Copy | ( | stored_type *& | Ptr1, | |
| stored_type *& | Ptr2 | |||
| ) |
Функция вызывается, когда один указатель инициализируется посредством другого.
| Ptr1 | - Инициализируемый указатель. | |
| Ptr2 | - Инициализирующий указатель. |
| nitro::exception | Кидается исключение этого типа с описанием ошибки и её кодом. |
См. определение в файле memory_handler.h строка 313
Перекрестные ссылки nitro::exception::code(), MemoryDesriptions и nitro::exception::what().
{
try
{
for( std::size_t i( 0 ) ; i < MemoryDesriptions.size() ; i++ )
{
if( MemoryDesriptions[ i ].AddressIn( Ptr1 ) )
{
MemoryDesriptions[ i ].OnAssigned();
break;
}
}
for( std::size_t i( 0 ) ; i < MemoryDesriptions.size() ; i++ )
{
if( MemoryDesriptions[ i ].AddressIn( Ptr2 ) )
{
MemoryDesriptions[ i ].OnCopied();
break;
}
}
Ptr1 = Ptr2;
}
catch( nitro::exception e )
{
throw( nitro::exception( std::string( "MemoryHandler::Copy( stored_type & * Ptr1 , stored_type & * Ptr2 )::" ) + e.what() , e.code() ) );
}
catch( ... )
{
throw( nitro::exception( std::string( "MemoryHandler::Copy( stored_type & * Ptr1 , stored_type & * Ptr2 )::An error occured" ) , 0 ) );
}
}

| void nitro::MemoryHandler::Deallocate | ( | stored_type * | DeallocatingData | ) |
Функция для освобождения выделенной памяти.
| DeallocatingData | - Указатель выделенный блок памяти, который нужно удалить. |
| nitro::exception | - Кидается исключение этого типа с описанием ошибки и её кодом. |
См. определение в файле memory_handler.h строка 375
Перекрестные ссылки nitro::exception::code(), MemoryDesriptions и nitro::exception::what().
{
try
{
for( std::size_t i( 0 ) ; i < MemoryDesriptions.size() ; i++ )
{
if( MemoryDesriptions[ i ].AddressIn( DeallocatingData ) )
{
MemoryDesriptions[ i ].ReleaseNestedPointers();
delete [] DeallocatingData;
MemoryDesriptions.erase( MemoryDesriptions.begin() + i );
}
}
}
catch( nitro::exception e )
{
throw( nitro::exception( std::string( "MemoryHandler::Deallocate( stored_type * DeallocatingData )::" ) + e.what() , e.code() ) );
}
catch( ... )
{
throw( nitro::exception( std::string( "MemoryHandler::Deallocate( stored_type * DeallocatingData )::An error occured" ) , 0 ) );
}
}

std::vector< MemoryDescription > nitro::MemoryHandler::MemoryDesriptions [private] |
Массив с данными о выделеннымх блоках памяти.
См. определение в файле memory_handler.h строка 310
Используется в Allocate(), Copy() и Deallocate().
1.6.1