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

StreamBuffer Class Reference

The stream buffer is a small object collecting object data. More...

#include <GaudiKernel/StreamBuffer.h>

List of all members.

Public Types

typedef std::vector<ContainedLinkContainedLinks
typedef std::vector<IdentifiedLinkIdentifiedLinks
 Definition of the identifiable link set. More...

typedef void (* AnalyzeFunction )(const void* data, int siz, const std::type_info& type)
 Definition of the buffer analyzer.

enum  Mode { UNINITIALIZED, READING, WRITING }
 Streamer mode. More...

enum  SwapAction { SINGLE_BYTE, SWAP, NOSWAP }
 Data Sawp actions. More...

enum  State { INVALID = -1, VALID }
 Link state defintions. More...


Public Methods

 StreamBuffer (bool do_swap=true)
 Standard constructor. More...

virtual ~StreamBuffer ()
 Standard destructor. More...

const char* data () const
 Read access to data buffer. More...

char* data ()
 write access to data buffer. More...

void erase ()
 Reset the buffer. More...

void reserve (long len)
 Reserve buffer space; Default: 16 k buffer size. More...

void extend (long len)
 Extend the buffer. More...

long size () const
 Total buffer size. More...

ContainedLinkscontainedLinks ()
 Access to contained links. More...

const ContainedLinkscontainedLinks () const
 CONST Access to contained links. More...

IdentifiedLinksidentifiedLinks ()
 Access to identified links. More...

const IdentifiedLinksidentifiedLinks () const
 CONST Access to identified links. More...

void setMode (Mode m)
 Set mode of the stream and allocate buffer. More...

bool isReading () const
 Get stream buffer state. More...

bool isWriting () const
 Get stream buffer state. More...

long buffPointer () const
 Retrieve current buffer pointer. More...

void setBuffPointer (long ptr)
 Retrieve current buffer pointer. More...

void setAnalyzer (AnalyzeFunction fun=0)
 Enable user analysis function. More...

void swapToBuffer (const void* source, int siz)
 Swap buffers: int, long, short, float and double. More...

void swapFromBuffer (void* target, int siz)
 Swap buffers: int, long, short, float and double. More...

StreamBuffer& writeBytes (const char* str, long len)
 Write string to output stream. More...

void getIdentifiedLink (DataObject*& pObject, long& hint)
void addIdentifiedLink (const DataObject* pObject, long hint)
void getContainedLink (ContainedObject*& pObject, long& hint, long& link)
void addContainedLink (const ContainedObject* pObject, long hint, long link)
StreamBuffer& operator<< (int data)
 Output Streamer. More...

StreamBuffer& operator>> (int & data)
 Input Streamer. More...

StreamBuffer& operator<< (unsigned int data)
 Output Streamer. More...

StreamBuffer& operator>> (unsigned int & data)
 Input Streamer. More...

StreamBuffer& operator<< (long data)
 Output Streamer. More...

StreamBuffer& operator>> (long & data)
 Input Streamer. More...

StreamBuffer& operator<< (unsigned long data)
 Output Streamer. More...

StreamBuffer& operator>> (unsigned long & data)
 Input Streamer. More...

StreamBuffer& operator<< (short data)
 Output Streamer. More...

StreamBuffer& operator>> (short & data)
 Input Streamer. More...

StreamBuffer& operator<< (unsigned short data)
 Output Streamer. More...

StreamBuffer& operator>> (unsigned short & data)
 Input Streamer. More...

StreamBuffer& operator<< (char data)
 Output Streamer. More...

StreamBuffer& operator>> (char & data)
 Input Streamer. More...

StreamBuffer& operator<< (unsigned char data)
 Output Streamer. More...

StreamBuffer& operator>> (unsigned char & data)
 Input Streamer. More...

StreamBuffer& operator<< (float data)
 Output Streamer. More...

StreamBuffer& operator>> (float & data)
 Input Streamer. More...

StreamBuffer& operator<< (double data)
 Output Streamer. More...

StreamBuffer& operator>> (double & data)
 Input Streamer. More...

StreamBuffer& operator>> (char* data)
 Streamer to read strings in (char*) format. More...

StreamBuffer& operator<< (const char *data)
 Streamer to write strings in (char*) format. More...

StreamBuffer& operator>> (std::string& data)
 Streamer to read strings in (std::string) format. More...

StreamBuffer& operator<< (const std::string& data)
 Streamer to write strings in (std::string) format. More...

template<classTYPE> StreamBuffer& operator>> (TYPE*& refpObject)
 Streamer to read links to contained or identified objects. More...

StreamBuffer& operator<< (const ContainedObject* pObject)
 Streamer to write links to contained objects. More...

StreamBuffer& operator<< (const DataObject* pObject)
 Streamer to write links to identified objects. More...

void serialize (DataIO& ioObject)
 Serialize the buffer using an IO object. More...


Protected Methods

SwapAction swapBuffer (int siz) const
 Check for byte swapping. More...

template<classTYPE> StreamBuffer& getObjectPointer (const DataObject* pObject, TYPE*& refpObject)
 Helper to distinguis between identified pointers and contained pointers. More...

template<classTYPE> StreamBuffer& getObjectPointer (const ContainedObject* pObject, TYPE*& refpObject)
 Helper to distinguis between identified pointers and contained pointers. More...


Protected Attributes

Mode m_mode
 Boolean indicating wether the stream is in read or write mode. More...

long m_pointer
 Current buffer pointer. More...

long m_length
 Total buffer length. More...

char* m_buffer
 Pointer to heap buffer. More...

bool m_swapEnabled
 Flag indicating swapping. More...

ContainedLinks m_containedLinks
 Container with links to contained objects. More...

IdentifiedLinks m_identifiedLinks
 Container with links to contained objects. More...

AnalyzeFunction m_analyzer
 Hook function for analysis of data to the stream. More...


Friends

class  DataObject


Detailed Description

The stream buffer is a small object collecting object data.

The basic idea behind the StreamBuffer is generic object conversion. The StreamBuffer acts as a byte stream (hence inheriting from a std::string) and stores any information streamed to the buffer. Since the information must be represented in a generic way on the fly byte swapping is performed. However, not only primitive data can be stored in the buffer, but also pointers to DataObjects (symbolic links) and pointers to contained objects. Automatically during serialization the persistent references to the corresponding objects and containers must be stored. These objects are accessible from the StreamBuffer object.

"On the fly" data conversion to non persistent

Author(s):
M.Frank

Definition at line 35 of file StreamBuffer.h.


Member Typedef Documentation

typedef void(* StreamBuffer::AnalyzeFunction)(const void *data,int siz,const std::type_info &type)
 

Definition of the buffer analyzer.

typedef std::vector<ContainedLink> StreamBuffer::ContainedLinks
 

Definition at line 144 of file StreamBuffer.h.

typedef std::vector<IdentifiedLink> StreamBuffer::IdentifiedLinks
 

Definition of the identifiable link set.

Definition at line 146 of file StreamBuffer.h.


Member Enumeration Documentation

enum StreamBuffer::Mode
 

Streamer mode.

Enumeration values:
UNINITIALIZED  
READING  
WRITING  

Definition at line 109 of file StreamBuffer.h.

enum StreamBuffer::State
 

Link state defintions.

Enumeration values:
INVALID  
VALID  

Definition at line 113 of file StreamBuffer.h.

enum StreamBuffer::SwapAction
 

Data Sawp actions.

Enumeration values:
SINGLE_BYTE  
SWAP  
NOSWAP  

Definition at line 111 of file StreamBuffer.h.


Constructor & Destructor Documentation

StreamBuffer::StreamBuffer ( bool do_swap = true ) [inline]
 

Standard constructor.

Definition at line 202 of file StreamBuffer.h.

StreamBuffer::~StreamBuffer ( ) [inline, virtual]
 

Standard destructor.

Definition at line 212 of file StreamBuffer.h.


Member Function Documentation

void StreamBuffer::addContainedLink ( const ContainedObject * pObject,
long hint,
long link ) [inline]
 

Definition at line 327 of file StreamBuffer.h.

void StreamBuffer::addIdentifiedLink ( const DataObject * pObject,
long hint ) [inline]
 

Definition at line 316 of file StreamBuffer.h.

long StreamBuffer::buffPointer ( ) const [inline]
 

Retrieve current buffer pointer.

Definition at line 284 of file StreamBuffer.h.

Referenced by StreamBuffer::Ostream::dump().

const ContainedLinks & StreamBuffer::containedLinks ( ) const [inline]
 

CONST Access to contained links.

Definition at line 253 of file StreamBuffer.h.

ContainedLinks & StreamBuffer::containedLinks ( ) [inline]
 

Access to contained links.

Definition at line 249 of file StreamBuffer.h.

char * StreamBuffer::data ( ) [inline]
 

write access to data buffer.

Definition at line 220 of file StreamBuffer.h.

const char * StreamBuffer::data ( ) const [inline]
 

Read access to data buffer.

Definition at line 216 of file StreamBuffer.h.

Referenced by StreamBuffer::Ostream::dump(), and StreamBuffer::Istream::load().

void StreamBuffer::erase ( ) [inline]
 

Reset the buffer.

Definition at line 224 of file StreamBuffer.h.

Referenced by StreamBuffer::Istream::load().

void StreamBuffer::extend ( long len ) [inline]
 

Extend the buffer.

Definition at line 235 of file StreamBuffer.h.

Referenced by swapToBuffer().

void StreamBuffer::getContainedLink ( ContainedObject *& pObject,
long & hint,
long & link ) [inline]
 

Definition at line 320 of file StreamBuffer.h.

void StreamBuffer::getIdentifiedLink ( DataObject *& pObject,
long & hint ) [inline]
 

Definition at line 310 of file StreamBuffer.h.

template<classTYPE>
StreamBuffer & StreamBuffer::getObjectPointer ( const ContainedObject * pObject,
TYPE *& refpObject ) [inline, protected]
 

Helper to distinguis between identified pointers and contained pointers.

This entry resolves contained pointers (= Pointers to ContainedObject instances.)

Definition at line 193 of file StreamBuffer.h.

template<classTYPE>
StreamBuffer & StreamBuffer::getObjectPointer ( const DataObject * pObject,
TYPE *& refpObject ) [inline, protected]
 

Helper to distinguis between identified pointers and contained pointers.

This entry resolves identified pointers (= Pointers to DataObject instances.)

Definition at line 183 of file StreamBuffer.h.

const IdentifiedLinks & StreamBuffer::identifiedLinks ( ) const [inline]
 

CONST Access to identified links.

Definition at line 262 of file StreamBuffer.h.

IdentifiedLinks & StreamBuffer::identifiedLinks ( ) [inline]
 

Access to identified links.

Definition at line 258 of file StreamBuffer.h.

bool StreamBuffer::isReading ( ) const [inline]
 

Get stream buffer state.

Definition at line 275 of file StreamBuffer.h.

Referenced by StreamBuffer::DataIO::serialize().

bool StreamBuffer::isWriting ( ) const [inline]
 

Get stream buffer state.

Definition at line 280 of file StreamBuffer.h.

Referenced by StreamBuffer::DataIO::serialize().

StreamBuffer & StreamBuffer::operator<< ( const DataObject * pObject ) [inline]
 

Streamer to write links to identified objects.

Links to identified objects are not stored immediately, but collected instead and analyzed later.

Parameters:
pObject   Pointer to object to be loaded.
Returns:
Reference to StreamBuffer object

Definition at line 533 of file StreamBuffer.h.

StreamBuffer & StreamBuffer::operator<< ( const ContainedObject * pObject ) [inline]
 

Streamer to write links to contained objects.

Links to contained objects are not stored immediately, but collected instead and analyzed later.

Parameters:
pObject   Pointer to object to be loaded.
Returns:
Reference to StreamBuffer object

Definition at line 521 of file StreamBuffer.h.

StreamBuffer & StreamBuffer::operator<< ( const std::string & data ) [inline]
 

Streamer to write strings in (std::string) format.

Definition at line 494 of file StreamBuffer.h.

StreamBuffer & StreamBuffer::operator<< ( const char * data ) [inline]
 

Streamer to write strings in (char*) format.

Definition at line 474 of file StreamBuffer.h.

StreamBuffer & StreamBuffer::operator<< ( double data ) [inline]
 

Output Streamer.

Definition at line 454 of file StreamBuffer.h.

StreamBuffer & StreamBuffer::operator<< ( float data ) [inline]
 

Output Streamer.

Definition at line 443 of file StreamBuffer.h.

StreamBuffer & StreamBuffer::operator<< ( unsigned char data ) [inline]
 

Output Streamer.

Definition at line 432 of file StreamBuffer.h.

StreamBuffer & StreamBuffer::operator<< ( char data ) [inline]
 

Output Streamer.

Definition at line 421 of file StreamBuffer.h.

StreamBuffer & StreamBuffer::operator<< ( unsigned short data ) [inline]
 

Output Streamer.

Definition at line 410 of file StreamBuffer.h.

StreamBuffer & StreamBuffer::operator<< ( short data ) [inline]
 

Output Streamer.

Definition at line 399 of file StreamBuffer.h.

StreamBuffer & StreamBuffer::operator<< ( unsigned long data ) [inline]
 

Output Streamer.

Definition at line 388 of file StreamBuffer.h.

StreamBuffer & StreamBuffer::operator<< ( long data ) [inline]
 

Output Streamer.

Definition at line 377 of file StreamBuffer.h.

StreamBuffer & StreamBuffer::operator<< ( unsigned int data ) [inline]
 

Output Streamer.

Definition at line 366 of file StreamBuffer.h.

StreamBuffer & StreamBuffer::operator<< ( int data ) [inline]
 

Output Streamer.

Definition at line 355 of file StreamBuffer.h.

template<classTYPE>
StreamBuffer & StreamBuffer::operator>> ( TYPE *& refpObject ) [inline]
 

Streamer to read links to contained or identified objects.

The specified internal function call distinguishes between contained and identified objects.

Parameters:
refpObject   Reference to pointer to object to be loaded.
Returns:
Reference to StreamBuffer object

Definition at line 511 of file StreamBuffer.h.

StreamBuffer & StreamBuffer::operator>> ( std::string & data ) [inline]
 

Streamer to read strings in (std::string) format.

Definition at line 485 of file StreamBuffer.h.

StreamBuffer & StreamBuffer::operator>> ( char * data ) [inline]
 

Streamer to read strings in (char*) format.

Definition at line 465 of file StreamBuffer.h.

StreamBuffer & StreamBuffer::operator>> ( double & data ) [inline]
 

Input Streamer.

Definition at line 460 of file StreamBuffer.h.

StreamBuffer & StreamBuffer::operator>> ( float & data ) [inline]
 

Input Streamer.

Definition at line 449 of file StreamBuffer.h.

StreamBuffer & StreamBuffer::operator>> ( unsigned char & data ) [inline]
 

Input Streamer.

Definition at line 438 of file StreamBuffer.h.

StreamBuffer & StreamBuffer::operator>> ( char & data ) [inline]
 

Input Streamer.

Definition at line 427 of file StreamBuffer.h.

StreamBuffer & StreamBuffer::operator>> ( unsigned short & data ) [inline]
 

Input Streamer.

Definition at line 416 of file StreamBuffer.h.

StreamBuffer & StreamBuffer::operator>> ( short & data ) [inline]
 

Input Streamer.

Definition at line 405 of file StreamBuffer.h.

StreamBuffer & StreamBuffer::operator>> ( unsigned long & data ) [inline]
 

Input Streamer.

Definition at line 394 of file StreamBuffer.h.

StreamBuffer & StreamBuffer::operator>> ( long & data ) [inline]
 

Input Streamer.

Definition at line 383 of file StreamBuffer.h.

StreamBuffer & StreamBuffer::operator>> ( unsigned int & data ) [inline]
 

Input Streamer.

Definition at line 372 of file StreamBuffer.h.

StreamBuffer & StreamBuffer::operator>> ( int & data ) [inline]
 

Input Streamer.

Definition at line 361 of file StreamBuffer.h.

void StreamBuffer::reserve ( long len ) [inline]
 

Reserve buffer space; Default: 16 k buffer size.

Definition at line 228 of file StreamBuffer.h.

Referenced by StreamBuffer::Istream::load().

void StreamBuffer::serialize ( DataIO & ioObject ) [inline]
 

Serialize the buffer using an IO object.

The streambuffer object will make use of a DataIO object, which can be specialized for streaming to any representation like e.g. disk files, Root files, Objectivity etc.

Parameters:
ioObject   Reference to data IO object.

Definition at line 545 of file StreamBuffer.h.

void StreamBuffer::setAnalyzer ( AnalyzeFunction fun = 0 ) [inline]
 

Enable user analysis function.

Definition at line 292 of file StreamBuffer.h.

void StreamBuffer::setBuffPointer ( long ptr ) [inline]
 

Retrieve current buffer pointer.

Definition at line 288 of file StreamBuffer.h.

void StreamBuffer::setMode ( Mode m ) [inline]
 

Set mode of the stream and allocate buffer.

Definition at line 267 of file StreamBuffer.h.

long StreamBuffer::size ( ) const [inline]
 

Total buffer size.

Definition at line 245 of file StreamBuffer.h.

StreamBuffer::SwapAction StreamBuffer::swapBuffer ( int siz ) const [inline, protected]
 

Check for byte swapping.

Definition at line 554 of file StreamBuffer.h.

Referenced by swapFromBuffer(), and swapToBuffer().

void StreamBuffer::swapFromBuffer ( void * target,
int siz ) [inline]
 

Swap buffers: int, long, short, float and double.

Definition at line 598 of file StreamBuffer.h.

void StreamBuffer::swapToBuffer ( const void * source,
int siz ) [inline]
 

Swap buffers: int, long, short, float and double.

Definition at line 579 of file StreamBuffer.h.

StreamBuffer & StreamBuffer::writeBytes ( const char * str,
long len ) [inline]
 

Write string to output stream.

Definition at line 302 of file StreamBuffer.h.


Friends And Related Function Documentation

class DataObject [friend]
 

DataObject is friend.

Definition at line 150 of file StreamBuffer.h.


Member Data Documentation

AnalyzeFunction StreamBuffer::m_analyzer [protected]
 

Hook function for analysis of data to the stream.

Definition at line 175 of file StreamBuffer.h.

char * StreamBuffer::m_buffer [protected]
 

Pointer to heap buffer.

Definition at line 163 of file StreamBuffer.h.

ContainedLinks StreamBuffer::m_containedLinks [protected]
 

Container with links to contained objects.

Definition at line 169 of file StreamBuffer.h.

IdentifiedLinks StreamBuffer::m_identifiedLinks [protected]
 

Container with links to contained objects.

Definition at line 172 of file StreamBuffer.h.

long StreamBuffer::m_length [protected]
 

Total buffer length.

Definition at line 160 of file StreamBuffer.h.

Mode StreamBuffer::m_mode [protected]
 

Boolean indicating wether the stream is in read or write mode.

Definition at line 154 of file StreamBuffer.h.

long StreamBuffer::m_pointer [protected]
 

Current buffer pointer.

Definition at line 157 of file StreamBuffer.h.

bool StreamBuffer::m_swapEnabled [protected]
 

Flag indicating swapping.

Definition at line 166 of file StreamBuffer.h.


The documentation for this class was generated from the following file:
Generated at Wed Nov 21 12:22:16 2001 by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000