Buffer Class Reference
[PEARL.base]

Generic memory buffer implementation. More...

#include <Buffer.h>

Inheritance diagram for Buffer:

MpiMessage

List of all members.

Public Member Functions

Constructors & destructor
 Buffer (std::size_t capacity=512)
 Buffer (const Buffer &rhs)
virtual ~Buffer ()
Assignment operator
Bufferoperator= (const Buffer &rhs)
Accessing buffer properties
std::size_t capacity () const
std::size_t size () const
Storing data values
void put_id (const ident_t &id)
void put_time (const timestamp_t &timestamp)
void put_uint32 (const uint32_t &value)
void put_double (const double &value)
void put_event (const Event &event)
Retrieving data values
ident_t get_id ()
timestamp_t get_time ()
uint32_t get_uint32 ()
double get_double ()
RemoteEvent get_event (const GlobalDefs &defs)

Protected Attributes

std::size_t m_capacity
 Current buffer capacity.
std::size_t m_size
 Current usage of buffer.
std::size_t m_position
 Current read position.
uint8_t * m_data
 Pointer to the actual data.


Detailed Description

The Buffer class provides a generic implementation of a memory buffer which is able to adjust its size dynamically. It can be used, for example, to pass event data between several processes or threads. To allow its use in heterogeneous environments, this class transparently handles the problem of different byte orders.

Constructor & Destructor Documentation

Buffer ( std::size_t  capacity = 512  ) 

Creates a new buffer instance with the given capacity, which has to be at least 1 byte (default: 512).

Parameters:
capacity Initial capacity

Buffer ( const Buffer rhs  ) 

Copy constructor. Creates a new instance and initializes its data with the contents of the given buffer rhs (deep copy).

Parameters:
rhs Source operand

~Buffer (  )  [virtual]

Destructor. Destroys the instance and releases all occupied resources.


Member Function Documentation

size_t capacity (  )  const

Returns the current capacity of the buffer instance in bytes.

Returns:
Buffer capacity

double get_double (  ) 

Returns the double-precision floating-point value store in the buffer at the current read position.

Returns:
Double-precision floating-point value

RemoteEvent get_event ( const GlobalDefs defs  ) 

Returns a new instance of RemoteEvent, initialized with the data stored in the buffer at the current read position.

Parameters:
defs GlobalDefs instance providing the corresponding global definition data.
Returns:
RemoteEvent instance

ident_t get_id (  ) 

Returns the identifier stored in the buffer at the current read position.

Returns:
Identifier

timestamp_t get_time (  ) 

Returns the timestamp stored in the buffer at the current read position.

Returns:
Timestamp

uint32_t get_uint32 (  ) 

Returns the 32-bit unsigned integer value stored in the buffer at the current read position.

Returns:
32-bit unsigned integer value

Buffer & operator= ( const Buffer rhs  ) 

Assignment operator. Creates a deep copy of the given argument rhs.

Parameters:
rhs Source operand
Returns:
Reference to the instance

void put_double ( const double &  value  ) 

Appends the given double-precision floating-point value to the buffer. If not enough buffer space is available, the buffer will be automatically resized.

Parameters:
value Value to be appended

void put_event ( const Event event  ) 

Appends the data of the given event to the buffer. If not enough buffer space is available, the buffer will be automatically resized.

Parameters:
event Event to be written to the buffer

void put_id ( const ident_t id  ) 

Appends the given id to the buffer. If not enough buffer space is available, the buffer will be automatically resized.

Parameters:
id Identifier to be appended

void put_time ( const timestamp_t timestamp  ) 

Appends the given timestamp to the buffer. If not enough buffer space is available, the buffer will be automatically resized.

Parameters:
timestamp Timestamp to be appended

void put_uint32 ( const uint32_t &  value  ) 

Appends the given unsigned 32-bit integer value to the buffer. If not enough buffer space is available, the buffer will be automatically resized.

Parameters:
value Value to be appended

size_t size (  )  const

Returns the current usage of the buffer instance in bytes.

Returns:
Buffer usage


SCALASCA    Copyright © 1998–2009 Forschungszentrum Jülich, Jülich Supercomputing Centre