Gaudi Framework, version v22r0

Home   Generated: 9 Feb 2011

StreamBuffer Class Reference

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

#include <GaudiKernel/StreamBuffer.h>

Collaboration diagram for StreamBuffer:
Collaboration graph
[legend]

List of all members.

Classes

class  ContainedLink
 Definition of the contained link set. More...
class  DataIO
 A small base class to handle generic data streaming. More...
class  IdentifiedLink
 Definition of the contained link set. More...
class  Istream
 Reader for standard input streams. More...
class  Ostream
 Writer for standard output streams. More...

Public Types

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...
typedef std::vector
< ContainedLink
ContainedLinks
typedef std::vector
< IdentifiedLink
IdentifiedLinks
 Definition of the identifiable link set.
typedef void(* AnalyzeFunction )(const void *data, int siz, const std::type_info &type)
 Definition of the buffer analyzer.

Public Member Functions

 StreamBuffer (bool do_swap=true)
 Standard constructor.
virtual ~StreamBuffer ()
 Standard destructor.
const char * data () const
 Read access to data buffer.
char * data ()
 write access to data buffer
void erase ()
 Reset the buffer.
void reserve (long len)
 Reserve buffer space; Default: 16 k buffer size.
void extend (long len)
 Extend the buffer.
long size () const
 Total buffer size.
ContainedLinkscontainedLinks ()
 Access to contained links.
const ContainedLinkscontainedLinks () const
 CONST Access to contained links.
IdentifiedLinksidentifiedLinks ()
 Access to identified links.
const IdentifiedLinksidentifiedLinks () const
 CONST Access to identified links.
void setMode (Mode m)
 Set mode of the stream and allocate buffer.
bool isReading () const
 Get stream buffer state.
bool isWriting () const
 Get stream buffer state.
long buffPointer () const
 Retrieve current buffer pointer.
void setBuffPointer (long ptr)
 Retrieve current buffer pointer.
void setAnalyzer (AnalyzeFunction fun=0)
 Enable user analysis function.
void swapToBuffer (const void *source, int siz)
 Swap buffers: int, long, short, float and double.
void swapFromBuffer (void *target, int siz)
 Swap buffers: int, long, short, float and double.
StreamBufferwriteBytes (const char *str, long len)
 Write string to output stream.
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)
StreamBufferoperator<< (longlong data)
 Output Streamer.
StreamBufferoperator>> (longlong &data)
 Input Streamer.
StreamBufferoperator<< (int data)
 Output Streamer.
StreamBufferoperator>> (int &data)
 Input Streamer.
StreamBufferoperator<< (unsigned int data)
 Output Streamer.
StreamBufferoperator>> (unsigned int &data)
 Input Streamer.
StreamBufferoperator<< (long data)
 Output Streamer.
StreamBufferoperator>> (long &data)
 Input Streamer.
StreamBufferoperator<< (unsigned long data)
 Output Streamer.
StreamBufferoperator>> (unsigned long &data)
 Input Streamer.
StreamBufferoperator<< (short data)
 Output Streamer.
StreamBufferoperator>> (short &data)
 Input Streamer.
StreamBufferoperator<< (unsigned short data)
 Output Streamer.
StreamBufferoperator>> (unsigned short &data)
 Input Streamer.
StreamBufferoperator<< (char data)
 Output Streamer.
StreamBufferoperator>> (char &data)
 Input Streamer.
StreamBufferoperator<< (unsigned char data)
 Output Streamer.
StreamBufferoperator>> (unsigned char &data)
 Input Streamer.
StreamBufferoperator<< (float data)
 Output Streamer.
StreamBufferoperator>> (float &data)
 Input Streamer.
StreamBufferoperator<< (double data)
 Output Streamer.
StreamBufferoperator>> (double &data)
 Input Streamer.
StreamBufferoperator>> (char *data)
 Streamer to read strings in (char*) format.
StreamBufferoperator<< (const char *data)
 Streamer to write strings in (char*) format.
StreamBufferoperator>> (std::string &data)
 Streamer to read strings in (std::string) format.
StreamBufferoperator<< (const std::string &data)
 Streamer to write strings in (std::string) format.
template<class TYPE >
StreamBufferoperator>> (TYPE *&refpObject)
 Streamer to read links to contained or identified objects.
StreamBufferoperator<< (const ContainedObject *pObject)
 Streamer to write links to contained objects.
StreamBufferoperator<< (const DataObject *pObject)
 Streamer to write links to identified objects.
void serialize (DataIO &ioObject)
 Serialize the buffer using an IO object.

Protected Member Functions

SwapAction swapBuffer (int siz) const
 Check for byte swapping.
template<class TYPE >
StreamBuffergetObjectPointer (const DataObject *pObject, TYPE *&refpObject)
 Helper to distinguis between identified pointers and contained pointers.
template<class TYPE >
StreamBuffergetObjectPointer (const ContainedObject *pObject, TYPE *&refpObject)
 Helper to distinguis between identified pointers and contained pointers.

Protected Attributes

Mode m_mode
 Boolean indicating wether the stream is in read or write mode.
long m_pointer
 Current buffer pointer.
long m_length
 Total buffer length.
char * m_buffer
 Pointer to heap buffer.
bool m_swapEnabled
 Flag indicating swapping.
ContainedLinks m_containedLinks
 Container with links to contained objects.
IdentifiedLinks m_identifiedLinks
 Container with links to contained objects.
AnalyzeFunction m_analyzer
 Hook function for analysis of data to the stream.

Friends

class DataObject
 DataObject is friend.

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:
M.Frank

Definition at line 40 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.

Definition at line 153 of file StreamBuffer.h.

Definition at line 149 of file StreamBuffer.h.

Definition of the identifiable link set.

Definition at line 151 of file StreamBuffer.h.


Member Enumeration Documentation

Streamer mode.

Enumerator:
UNINITIALIZED 
READING 
WRITING 

Definition at line 114 of file StreamBuffer.h.

Link state defintions.

Enumerator:
INVALID 
VALID 

Definition at line 118 of file StreamBuffer.h.

00118 {INVALID=-1, VALID };

Data Sawp actions.

Enumerator:
SINGLE_BYTE 
SWAP 
NOSWAP 

Definition at line 116 of file StreamBuffer.h.

00116 {SINGLE_BYTE, SWAP, NOSWAP};


Constructor & Destructor Documentation

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

Standard constructor.

Definition at line 207 of file StreamBuffer.h.

00208                                   :
00209     m_mode(UNINITIALIZED),
00210     m_pointer(0),
00211     m_length(0),
00212     m_buffer(0),
00213     m_swapEnabled(do_swap)
00214   {
00215     m_analyzer = 0;
  }

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

Standard destructor.

Definition at line 217 of file StreamBuffer.h.

00217                             {
00218     ::free( m_buffer );
00219   }


Member Function Documentation

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

Definition at line 332 of file StreamBuffer.h.

00332                                                                                  {
00333     m_containedLinks.push_back( ContainedLink((ContainedObject*)pObject, hint, link) );
00334   }

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

Definition at line 321 of file StreamBuffer.h.

00321                                                                   {
00322     m_identifiedLinks.push_back( IdentifiedLink((DataObject*)pObject, hint) );
00323   }

long StreamBuffer::buffPointer (  )  const [inline]

Retrieve current buffer pointer.

Definition at line 289 of file StreamBuffer.h.

00289                                 {
00290     return m_pointer;
00291   }

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

CONST Access to contained links.

Definition at line 258 of file StreamBuffer.h.

00258                                                  {
00259     return m_containedLinks;
00260   }

ContainedLinks& StreamBuffer::containedLinks (  )  [inline]

Access to contained links.

Definition at line 254 of file StreamBuffer.h.

00254                                      {
00255     return m_containedLinks;
00256   }

char* StreamBuffer::data (  )  [inline]

write access to data buffer

Definition at line 225 of file StreamBuffer.h.

00225                  {
00226     return m_buffer;
00227   }

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

Read access to data buffer.

Definition at line 221 of file StreamBuffer.h.

00221                                 {
00222     return m_buffer;
00223   }

void StreamBuffer::erase (  )  [inline]

Reset the buffer.

Definition at line 229 of file StreamBuffer.h.

00229                   {
00230     m_pointer = 0;
00231   }

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

Extend the buffer.

Definition at line 240 of file StreamBuffer.h.

00240                            {
00241     if ( len + m_pointer > m_length )    {
00242       // We have to be a bit generous here in order not to run too often
00243       // into ::realloc().
00244         long new_len = (m_length < 16384) ? 16384 : 2*m_length;
00245       if ( m_length < len ) new_len += len;
00246       reserve(new_len);
00247     }
00248   }

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

Definition at line 325 of file StreamBuffer.h.

00325                                                                               {
00326     ContainedLink& l = m_containedLinks.back();
00327     pObject = l.first;
00328     hint    = l.second;
00329     link    = l.third;
00330     m_containedLinks.pop_back();
00331   }

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

Definition at line 315 of file StreamBuffer.h.

00315                                                               {
00316     IdentifiedLink& l = m_identifiedLinks.back();
00317     pObject = l.first;
00318     hint    = l.second;
00319     m_identifiedLinks.pop_back();
00320   }

template<class TYPE >
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 198 of file StreamBuffer.h.

00198                                                                                                           {
00199     ContainedLink& link = m_containedLinks.back();
00200     ContainedObject* pObj = link.first;
00201     m_containedLinks.pop_back();
00202     refpObject = dynamic_cast<TYPE*>(pObj);
00203     return *this;
00204   }

template<class TYPE >
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 188 of file StreamBuffer.h.

00188                                                                                                      {
00189     IdentifiedLink& link = m_identifiedLinks.back();
00190     DataObject* pObj = link.first;
00191     m_identifiedLinks.pop_back();
00192     refpObject = dynamic_cast<TYPE*>(pObj);
00193     return *this;
00194   }

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

CONST Access to identified links.

Definition at line 267 of file StreamBuffer.h.

00267                                                    {
00268     return m_identifiedLinks;
00269   }

IdentifiedLinks& StreamBuffer::identifiedLinks (  )  [inline]

Access to identified links.

Definition at line 263 of file StreamBuffer.h.

00263                                        {
00264     return m_identifiedLinks;
00265   }

bool StreamBuffer::isReading (  )  const [inline]

Get stream buffer state.

Definition at line 280 of file StreamBuffer.h.

00280                                 {
00281     return m_mode == READING;
00282   }

bool StreamBuffer::isWriting (  )  const [inline]

Get stream buffer state.

Definition at line 285 of file StreamBuffer.h.

00285                                 {
00286     return m_mode == WRITING;
00287   }

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 549 of file StreamBuffer.h.

00549                                                         {
00550     STREAM_ANALYSE(pObject, sizeof(pObject));
00551     addIdentifiedLink(pObject, INVALID);
00552     return *this;
00553   }

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 537 of file StreamBuffer.h.

00537                                                              {
00538     STREAM_ANALYSE(pObject, sizeof(pObject));
00539     addContainedLink(pObject, INVALID, INVALID);
00540     return *this;
00541   }

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

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

Definition at line 510 of file StreamBuffer.h.

00510                                                     {
00511     if ( 0 == m_analyzer)   {
00512       const char* ptr = data.c_str();
00513       long len = data.length();
00514       writeBytes(ptr, len);
00515     }
00516     else    {
00517       STREAM_ANALYSE(data, sizeof(data));
00518     }
00519     return *this;
00520   }

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

Streamer to write strings in (char*) format.

Definition at line 490 of file StreamBuffer.h.

00490                                                  {
00491     const char* ptr = 0 == data ? "" : data;
00492     int len = strlen(ptr)+1;
00493     if ( 0 == m_analyzer )
00494       writeBytes(ptr, len);
00495     else  {
00496       STREAM_ANALYSE(data, len);
00497     }
00498     return *this;
00499   }

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

Output Streamer.

Definition at line 470 of file StreamBuffer.h.

00470                                               {
00471     swapToBuffer(&data, sizeof(data));
00472     STREAM_ANALYSE(data, sizeof(data));
00473     return *this;
00474   }

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

Output Streamer.

Definition at line 459 of file StreamBuffer.h.

00459                                              {
00460     swapToBuffer(&data, sizeof(data));
00461     STREAM_ANALYSE(data, sizeof(data));
00462     return *this;
00463   }

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

Output Streamer.

Definition at line 448 of file StreamBuffer.h.

00448                                                      {
00449     swapToBuffer(&data, sizeof(data));
00450     STREAM_ANALYSE(data, sizeof(data));
00451     return *this;
00452   }

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

Output Streamer.

Definition at line 437 of file StreamBuffer.h.

00437                                             {
00438     swapToBuffer(&data, sizeof(data));
00439     STREAM_ANALYSE(data, sizeof(data));
00440     return *this;
00441   }

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

Output Streamer.

Definition at line 426 of file StreamBuffer.h.

00426                                                       {
00427     swapToBuffer(&data, sizeof(data));
00428     STREAM_ANALYSE(data, sizeof(data));
00429     return *this;
00430   }

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

Output Streamer.

Definition at line 415 of file StreamBuffer.h.

00415                                              {
00416     swapToBuffer(&data, sizeof(data));
00417     STREAM_ANALYSE(data, sizeof(data));
00418     return *this;
00419   }

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

Output Streamer.

Definition at line 404 of file StreamBuffer.h.

00404                                                      {
00405     swapToBuffer(&data, sizeof(data));
00406     STREAM_ANALYSE(data, sizeof(data));
00407     return *this;
00408   }

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

Output Streamer.

Definition at line 393 of file StreamBuffer.h.

00393                                             {
00394     swapToBuffer(&data, sizeof(data));
00395     STREAM_ANALYSE(data, sizeof(data));
00396     return *this;
00397   }

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

Output Streamer.

Definition at line 382 of file StreamBuffer.h.

00382                                                     {
00383     swapToBuffer(&data, sizeof(data));
00384     STREAM_ANALYSE(data, sizeof(data));
00385     return *this;
00386   }

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

Output Streamer.

Definition at line 371 of file StreamBuffer.h.

00371                                            {
00372     swapToBuffer(&data, sizeof(data));
00373     STREAM_ANALYSE(data, sizeof(data));
00374     return *this;
00375   }

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

Output Streamer.

Definition at line 360 of file StreamBuffer.h.

00360                                                 {
00361     swapToBuffer(&data, sizeof(data));
00362     STREAM_ANALYSE(data, sizeof(data));
00363     return *this;
00364   }

template<class TYPE >
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 527 of file StreamBuffer.h.

00527                                                                           {
00528     return getObjectPointer(refpObject, refpObject);
00529   }

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

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

Definition at line 501 of file StreamBuffer.h.

00501                                               {
00502     long i, len;
00503     *this >> len;
00504     for ( i = 0, data = ""; i < len; i++ )    {
00505       data.append( 1, m_buffer[m_pointer++] );
00506     }
00507     return *this;
00508   }

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

Streamer to read strings in (char*) format.

Definition at line 481 of file StreamBuffer.h.

00481                                           {
00482     long i, len;
00483     *this >> len;
00484     for ( i = 0, data[0]=0; i < len; i++ )    {
00485       data[i] = m_buffer[m_pointer++];
00486     }
00487     return *this;
00488   }

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

Input Streamer.

Definition at line 476 of file StreamBuffer.h.

00476                                               {
00477     swapFromBuffer(&data, sizeof(data));
00478     return *this;
00479   }

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

Input Streamer.

Definition at line 465 of file StreamBuffer.h.

00465                                              {
00466     swapFromBuffer(&data, sizeof(data));
00467     return *this;
00468   }

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

Input Streamer.

Definition at line 454 of file StreamBuffer.h.

00454                                                      {
00455     swapFromBuffer(&data, sizeof(data));
00456     return *this;
00457   }

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

Input Streamer.

Definition at line 443 of file StreamBuffer.h.

00443                                             {
00444     swapFromBuffer(&data, sizeof(data));
00445     return *this;
00446   }

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

Input Streamer.

Definition at line 432 of file StreamBuffer.h.

00432                                                       {
00433     swapFromBuffer(&data, sizeof(data));
00434     return *this;
00435   }

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

Input Streamer.

Definition at line 421 of file StreamBuffer.h.

00421                                              {
00422     swapFromBuffer(&data, sizeof(data));
00423     return *this;
00424   }

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

Input Streamer.

Definition at line 410 of file StreamBuffer.h.

00410                                                      {
00411     swapFromBuffer(&data, sizeof(data));
00412     return *this;
00413   }

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

Input Streamer.

Definition at line 399 of file StreamBuffer.h.

00399                                             {
00400     swapFromBuffer(&data, sizeof(data));
00401     return *this;
00402   }

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

Input Streamer.

Definition at line 388 of file StreamBuffer.h.

00388                                                     {
00389     swapFromBuffer(&data, sizeof(data));
00390     return *this;
00391   }

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

Input Streamer.

Definition at line 377 of file StreamBuffer.h.

00377                                            {
00378     swapFromBuffer(&data, sizeof(data));
00379     return *this;
00380   }

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

Input Streamer.

Definition at line 366 of file StreamBuffer.h.

00366                                                 {
00367     swapFromBuffer(&data, sizeof(data));
00368     return *this;
00369   }

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

Reserve buffer space; Default: 16 k buffer size.

Definition at line 233 of file StreamBuffer.h.

00233                            {
00234     if ( len > m_length )   {
00235       m_length = (len < 16384) ? 16384 : len;
00236       m_buffer = (char*)::realloc (m_buffer,m_length);
00237     }
00238   }

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 561 of file StreamBuffer.h.

00561                                      {
00562     ioObject.serialize ( *this );
00563     m_pointer = 0;
00564   }

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

Enable user analysis function.

Definition at line 297 of file StreamBuffer.h.

00297                                            {
00298     m_analyzer = fun;
00299   }

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

Retrieve current buffer pointer.

Definition at line 293 of file StreamBuffer.h.

00293                                   {
00294     m_pointer = ptr;
00295   }

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

Set mode of the stream and allocate buffer.

Definition at line 272 of file StreamBuffer.h.

long StreamBuffer::size (  )  const [inline]

Total buffer size.

Definition at line 250 of file StreamBuffer.h.

00250                         {
00251     return m_length;
00252   }

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

Check for byte swapping.

Definition at line 570 of file StreamBuffer.h.

00570                                                                         {
00571   switch(siz)   {
00572   case 1:
00573     return SINGLE_BYTE;
00574   default:
00575 #if defined(__alpha) && !defined(__VMS)
00576 //    return m_swapEnabled ? SWAP : NOSWAP;
00577     return NOSWAP;
00578 #elif defined(__sun) && defined(__SVR4) && defined(__i386)
00579 //    return m_swapEnabled ? SWAP : NOSWAP;
00580     return NOSWAP;
00581 #elif defined(__APPLE__)
00582 //    return m_swapEnabled ? SWAP : NOSWAP;
00583     return SWAP;
00584 #elif defined(__linux) && !defined(__powerpc)
00585 //    return m_swapEnabled ? SWAP : NOSWAP;
00586     return NOSWAP;
00587 #elif defined(BORLAND) || defined(_WIN32) || defined(WIN32)
00588 //    return m_swapEnabled ? SWAP : NOSWAP;
00589     return NOSWAP;
00590 #else
00591     return m_swapEnabled ? SWAP : NOSWAP;
00592 //    return NOSWAP;
00593 #endif
00594   }
00595 }

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

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

Swap bytes from the stream buffer to target buffer with arbitray size.

Definition at line 621 of file StreamBuffer.h.

00621                                                                 {
00622   char* tar = (char*)target;
00623   char* src = (char*)m_buffer+m_pointer;
00624   switch ( swapBuffer(siz) )   {
00625   case SINGLE_BYTE:
00626     *tar = *src;
00627     break;
00628   case SWAP:
00629 #ifdef __APPLE__
00630     for(int i = 0,j = siz-1;i<siz;i++,j--) tar[j] = src[i];
00631 #else
00632     ::_swab (src, tar, siz);
00633 #endif
00634     break;
00635   case NOSWAP:
00636     ::memcpy(tar, src, siz);
00637     break;
00638   }
00639   m_pointer += siz;
00640 }

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

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

Swap bytes from a source buffer to the stream buffer with arbitray size.

Definition at line 598 of file StreamBuffer.h.

00598                                                                     {
00599   char buff[8], *tar, *src = (char*)source;
00600   extend (m_pointer+siz);
00601   tar = (char*)m_buffer+m_pointer;
00602   switch ( swapBuffer(siz) )   {
00603   case SINGLE_BYTE:
00604     *tar = *src;
00605     break;
00606   case SWAP:
00607 #ifdef __APPLE__
00608     for(int i = 0,j = siz-1;i<siz;i++,j--) tar[j] = src[i];
00609 #else
00610     ::_swab (src, buff, siz);
00611 #endif
00612     src = buff;
00613   case NOSWAP:
00614     memcpy(tar, src, siz);
00615     break;
00616   }
00617   m_pointer += siz;
00618 }

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

Write string to output stream.

Definition at line 307 of file StreamBuffer.h.

00307                                                            {
00308     extend( m_pointer+len+4 );
00309     *this << len;
00310     memcpy(data()+buffPointer(), str, len);
00311     m_pointer += len;
00312     return *this;
00313   }


Friends And Related Function Documentation

friend class DataObject [friend]

DataObject is friend.

Definition at line 155 of file StreamBuffer.h.


Member Data Documentation

Hook function for analysis of data to the stream.

Definition at line 180 of file StreamBuffer.h.

char* StreamBuffer::m_buffer [protected]

Pointer to heap buffer.

Definition at line 168 of file StreamBuffer.h.

Container with links to contained objects.

Definition at line 174 of file StreamBuffer.h.

Container with links to contained objects.

Definition at line 177 of file StreamBuffer.h.

Total buffer length.

Definition at line 165 of file StreamBuffer.h.

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

Definition at line 159 of file StreamBuffer.h.

Current buffer pointer.

Definition at line 162 of file StreamBuffer.h.

bool StreamBuffer::m_swapEnabled [protected]

Flag indicating swapping.

Definition at line 171 of file StreamBuffer.h.


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

Generated at Wed Feb 9 16:31:55 2011 for Gaudi Framework, version v22r0 by Doxygen version 1.6.2 written by Dimitri van Heesch, © 1997-2004