Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

Buffer Class Reference

I/O buffer. More...

#include <buffer.h>

List of all members.

Public Methods

 Buffer ()
 Default constructor.

 Buffer (const Buffer &b)
 Copy constructor.

 Buffer (const char *buf, jint size)
 Constructor. More...

 ~Buffer ()
 Destructor. It frees allocated buffer.

const char * getBuffer () const
 Get pointer to buffer. More...

jint getSize () const
 Get size of data. More...

void clear ()
 Clear buffer. More...

void clear (jint newBufSize)
 Clear buffer and resize it. More...

void operator+= (const String &s)
 Addition assignment. More...

void operator+= (const jint c)
 Addition assignment. More...

void operator+= (const jlong c)
 Addition assignment. More...

void operator= (const Buffer &b)
 Assignment. More...


Private Types

enum  e { RESERVED = 50 }
 constants. More...


Private Methods

void reallocate (jint newBufSize)
 Reallocate buffer. More...


Private Attributes

char * _buf
 pointer to buffer.

jint _size
 size of data stored in buffer.

jint _bufSize
 buffer size.


Detailed Description

I/O buffer.

This class implements an input/output buffer needed during communication between profiler dynamic library and Java. This buffer can store anything you want in binary format. This class offers operators += and + for adding strings and jint/jlong values. Strings are stored as C-strings, so text + terminating null character. Jint/jlong types are special types defined by JVMPI, jint is 32-bit and jlong is 64-bit type. They are stored as numbers; jint (32-bit) in network-byte-order (using htonl() function), jlong (64-bit) must be divided to two 32-bit jint numbers (HI,LO parts of jlong), each of them stored in network-byte-order (HI part of jlong goes first, LO part of jlong goes second).

See also:
Commun
Author:
Marek Przeczek

Definition at line 58 of file buffer.h.


Member Enumeration Documentation

enum Buffer::e [private]
 

constants.

Enumeration values:
RESERVED  number of bytes reserved in buffer.

Definition at line 61 of file buffer.h.


Constructor & Destructor Documentation

Buffer::Buffer const char *    buf,
jint    size
 

Constructor.

This constructor constructs Buffer object using data from another buffer. The data are copied to this newly created Buffer object.

Parameters:
buf  pointer to buffer
size  size of buffer 'buf'

Definition at line 46 of file buffer.cpp.


Member Function Documentation

void Buffer::clear jint    newBufSize
 

Clear buffer and resize it.

It truncates buffer to zero length and resizes it.

Parameters:
newBufSize  new buffer size

Definition at line 124 of file buffer.cpp.

void Buffer::clear   [inline]
 

Clear buffer.

It truncates buffer to zero length, everything stored in the buffer will be lost.

Definition at line 122 of file buffer.h.

Referenced by IProf::_disableGC(), IProf::_enableGC(), IProf::_exitVM(), IProf::_getData(), IProf::_getInfo(), IProf::_isShutdowned(), IProf::_resumeVM(), IProf::_runGC(), IProf::_shutdown(), IProf::_suspendVM(), CommunSocket::operator>>(), CommunShMem::operator>>(), and IProf::run().

const char* Buffer::getBuffer   const [inline]
 

Get pointer to buffer.

This method returns pointer to buffer data.

Returns:
pointer to buffer

Definition at line 109 of file buffer.h.

Referenced by Buffer(), IProf::_getData(), IProf::_getInfo(), CommunSocket::operator<<(), CommunShMem::operator<<(), operator=(), and IProf::run().

jint Buffer::getSize   const [inline]
 

Get size of data.

This method returns size of data stored in buffer, so not exactly the buffer size. Buffer size is always greater or equal to data size.

Returns:
size of data

Definition at line 117 of file buffer.h.

Referenced by Buffer(), CommunSocket::operator<<(), CommunShMem::operator<<(), and operator=().

void Buffer::operator+= const jlong    c
 

Addition assignment.

This operator is used to append a jlong value (jlong = Java long type) to the end of buffer. Number (of 64-bit type) will be divided to two 32-bit numbers (two jint numbers - HI and LO parts), HI part goes first, LO part goes second, each of them is stored in network-byte-order. Buffer is modified.

Parameters:
c  jlong value

Definition at line 78 of file buffer.cpp.

void Buffer::operator+= const jint    c
 

Addition assignment.

This operator is used to append a jint value (jint = Java int type) to the end of buffer. Number is stored in network-byte-order. Buffer is modified.

Parameters:
c  jint value

Definition at line 65 of file buffer.cpp.

void Buffer::operator+= const String   s
 

Addition assignment.

This operator is used to append a C-string to the end of buffer. Buffer is modified.

Parameters:
s  reference to String object

Definition at line 55 of file buffer.cpp.

void Buffer::operator= const Buffer &    b
 

Assignment.

This operator is used to assign a "value" of another Buffer object. It means, buffer of right-side operand is copied to the buffer of left-side operand.

Parameters:
b  reference to another Buffer object
Returns:
temporal copy of Buffer object with new data

Definition at line 99 of file buffer.cpp.

void Buffer::reallocate jint    newBufSize [private]
 

Reallocate buffer.

This method reallocates/resizes buffer to appropriate size.

Parameters:
newBufSize  new buffer size

Definition at line 107 of file buffer.cpp.

Referenced by operator+=(), and operator=().


The documentation for this class was generated from the following files:
Generated on Mon Jan 28 14:53:28 2002 for Java Profiler Dynamic Library by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001