MOAB: Mesh Oriented datABase  (version 5.2.1)
moab::ParallelComm::Buffer Class Reference

#include <ParallelComm.hpp>

Public Member Functions

 Buffer (unsigned int sz=0)
 Buffer (const Buffer &)
 ~Buffer ()
void reset_buffer (size_t buff_pos=0)
void reset_ptr (size_t buff_pos=0)
void reserve (unsigned int new_size)
void set_stored_size ()
int get_stored_size ()
int get_current_size ()
void check_space (unsigned int addl_space)

Public Attributes

unsigned char * mem_ptr
unsigned char * buff_ptr
unsigned int alloc_size

Detailed Description

Definition at line 692 of file ParallelComm.hpp.


Constructor & Destructor Documentation

moab::ParallelComm::Buffer::Buffer ( unsigned int  sz = 0) [inline]

Definition at line 1267 of file ParallelComm.hpp.

References reserve().

                                                         : mem_ptr( NULL ), buff_ptr( NULL ), alloc_size( 0 )
{
    if( new_size ) this->reserve( new_size );
}
moab::ParallelComm::Buffer::Buffer ( const Buffer other_buff) [inline]

Definition at line 1259 of file ParallelComm.hpp.

References alloc_size, buff_ptr, and mem_ptr.

{
    alloc_size = other_buff.alloc_size;
    mem_ptr    = (unsigned char*)malloc( alloc_size );
    memcpy( mem_ptr, other_buff.mem_ptr, alloc_size );
    buff_ptr = mem_ptr + ( other_buff.buff_ptr - other_buff.mem_ptr );
}

Definition at line 1272 of file ParallelComm.hpp.

{
    if( mem_ptr )
    {
        free( mem_ptr );
        mem_ptr = NULL;
    }
}

Member Function Documentation

Definition at line 721 of file ParallelComm.hpp.

References buff_ptr, and mem_ptr.

Referenced by moab::ParallelComm::pack_entity_seq(), and moab::ParCommGraph::send_mesh_parts().

        {
            return (int)( buff_ptr - mem_ptr );
        }

Definition at line 717 of file ParallelComm.hpp.

References mem_ptr.

Referenced by moab::ParallelComm::recv_buffer(), and moab::ParallelComm::send_buffer().

        {
            return *( (int*)mem_ptr );
        }
void moab::ParallelComm::Buffer::reserve ( unsigned int  new_size) [inline]

Definition at line 1283 of file ParallelComm.hpp.

Referenced by moab::ParallelComm::broadcast_entities(), Buffer(), moab::ParallelComm::recv_buffer(), reset_buffer(), and moab::ParallelComm::scatter_entities().

{

#ifdef DEBUG_BUFFER
    int tmp_pos = 0;
    if( mem_ptr ) { tmp_pos = buff_ptr - mem_ptr; }
    buff_ptr = (unsigned char*)malloc( new_size );
    assert( 0 <= tmp_pos && tmp_pos <= (int)alloc_size );
    if( tmp_pos ) memcpy( buff_ptr, mem_ptr, tmp_pos );
    if( mem_ptr ) free( mem_ptr );
    mem_ptr    = buff_ptr;
    alloc_size = new_size;
    buff_ptr   = mem_ptr + tmp_pos;
#else
    if( mem_ptr && alloc_size < new_size )
    {
        size_t tmp_pos = mem_ptr ? buff_ptr - mem_ptr : 0;
        mem_ptr        = (unsigned char*)realloc( mem_ptr, new_size );
        alloc_size     = new_size;
        buff_ptr       = mem_ptr + tmp_pos;
    }
    else if( !mem_ptr )
    {
        mem_ptr    = (unsigned char*)malloc( new_size );
        alloc_size = new_size;
        buff_ptr   = mem_ptr;
    }
#endif
}
void moab::ParallelComm::Buffer::reset_buffer ( size_t  buff_pos = 0) [inline]

Definition at line 702 of file ParallelComm.hpp.

References moab::ParallelComm::INITIAL_BUFF_SIZE, reserve(), and reset_ptr().

        {
            reset_ptr( buff_pos );
            reserve( INITIAL_BUFF_SIZE );
        }

Member Data Documentation

List of all members.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines