The Gaudi Framework  v29r0 (ff2e7097)
StreamBuffer.h
Go to the documentation of this file.
1 #ifndef GAUDIKERNEL_STREAMBUFFER_H
2 #define GAUDIKERNEL_STREAMBUFFER_H 1
3 
4 // STL include files
5 #include <algorithm>
6 #include <cstdlib>
7 #include <cstring>
8 #include <iostream>
9 #include <list>
10 #include <string>
11 #include <typeinfo>
12 #include <vector>
13 
14 #include "GaudiKernel/Kernel.h"
15 #include "GaudiKernel/swab.h"
16 
17 // forward declarations
18 class StreamBuffer;
19 class DataObject;
20 class ContainedObject;
21 
41 class StreamBuffer /* : public std::string */
42 {
43 public:
45  class DataIO
46  {
47  public:
49  DataIO() = default;
51  virtual ~DataIO() = default;
53  void badStreamMode() { throw( "Not acceptable stream mode!" ); }
55  virtual void serialize( StreamBuffer& stream )
56  {
57  if ( stream.isReading() )
58  load( stream );
59  else if ( stream.isWriting() )
60  dump( stream );
61  else
62  badStreamMode();
63  }
65  virtual void load( StreamBuffer& ) { badStreamMode(); }
67  virtual void dump( StreamBuffer& ) { badStreamMode(); }
68  };
69 
71  class Istream : public DataIO
72  {
75 
76  public:
78  Istream( std::istream& str ) : m_stream( &str ) {}
80  ~Istream() override = default;
81 
83  void load( StreamBuffer& stream ) override
84  {
85  // Generic implementation for istreams:
86  int len;
87  ( *m_stream ) >> len;
88  stream.erase();
89  stream.reserve( len );
90  m_stream->read( stream.data(), len );
91  }
92  };
94  class Ostream : public DataIO
95  {
97 
98  public:
100  Ostream( std::ostream& str ) : m_stream( &str ) {}
102  virtual ~Ostream() = default;
103 
105  void dump( StreamBuffer& stream ) override
106  {
107  // Generic implementation for ostreams:
108  ( *m_stream ) << stream.buffPointer();
109  m_stream->write( stream.data(), stream.buffPointer() );
110  }
111  };
112 
113 public:
119  enum State { INVALID = -1, VALID };
122  {
123  public:
125  long second;
126  long third;
127  ContainedLink() : first( 0 ), second( INVALID ), third( INVALID ) {}
128  ContainedLink( const ContainedLink& copy ) : first( copy.first ), second( copy.second ), third( copy.third ) {}
129  ContainedLink( ContainedObject* pObj, long hint, long link ) : first( pObj ), second( hint ), third( link ) {}
130  };
133  {
134  public:
135  DataObject* first = nullptr;
136  long second = INVALID;
137  IdentifiedLink() = default;
138  IdentifiedLink( const IdentifiedLink& copy ) = default;
139  IdentifiedLink( DataObject* pObj, long hint ) : first( pObj ), second( hint ) {}
140  };
141 
146  typedef void ( *AnalyzeFunction )( const void* data, int siz, const std::type_info& type );
148  friend class DataObject;
149 
150 protected:
153 
155  mutable long m_pointer = 0;
156 
158  mutable long m_length = 0;
159 
161  mutable char* m_buffer = nullptr;
162 
164  bool m_swapEnabled = true;
165 
167  mutable ContainedLinks m_containedLinks;
168 
170  mutable IdentifiedLinks m_identifiedLinks;
171 
174 
176  SwapAction swapBuffer( int siz ) const;
177 
181  template <class TYPE>
182  StreamBuffer& getObjectPointer( const DataObject* /*pObject*/, TYPE*& refpObject )
183  {
184  IdentifiedLink& link = m_identifiedLinks.back();
185  DataObject* pObj = link.first;
186  m_identifiedLinks.pop_back();
187  refpObject = dynamic_cast<TYPE*>( pObj );
188  return *this;
189  }
193  template <class TYPE>
194  StreamBuffer& getObjectPointer( const ContainedObject* /*pObject*/, TYPE*& refpObject )
195  {
196  ContainedLink& link = m_containedLinks.back();
197  ContainedObject* pObj = link.first;
198  m_containedLinks.pop_back();
199  refpObject = dynamic_cast<TYPE*>( pObj );
200  return *this;
201  }
202 
203 public:
205  StreamBuffer( bool do_swap = true ) : m_swapEnabled( do_swap ) {}
207  virtual ~StreamBuffer() { ::free( m_buffer ); }
209  const char* data() const { return m_buffer; }
211  char* data() { return m_buffer; }
213  void erase() { m_pointer = 0; }
215  char* adopt() const
216  {
217  char* ptr = m_buffer;
218  m_containedLinks.erase( m_containedLinks.begin(), m_containedLinks.end() );
219  m_identifiedLinks.erase( m_identifiedLinks.begin(), m_identifiedLinks.end() );
220  m_buffer = NULL; // char *
221  m_pointer = 0; // long
222  m_length = 0; // long
223  return ptr;
224  }
226  void reserve( long len )
227  {
228  if ( len > m_length ) {
229  m_length = ( len < 16384 ) ? 16384 : len;
230  m_buffer = (char*)::realloc( m_buffer, m_length );
231  }
232  }
234  void extend( long len )
235  {
236  if ( len + m_pointer > m_length ) {
237  // We have to be a bit generous here in order not to run too often
238  // into ::realloc().
239  long new_len = ( m_length < 16384 ) ? 16384 : 2 * m_length;
240  if ( m_length < len ) new_len += len;
241  reserve( new_len );
242  }
243  }
245  long size() const { return m_length; }
247  ContainedLinks& containedLinks() { return m_containedLinks; }
249  const ContainedLinks& containedLinks() const { return m_containedLinks; }
250 
252  IdentifiedLinks& identifiedLinks() { return m_identifiedLinks; }
254  const IdentifiedLinks& identifiedLinks() const { return m_identifiedLinks; }
255 
257  void setMode( Mode m )
258  {
259  m_mode = m;
260  m_pointer = 0;
261  m_containedLinks.erase( m_containedLinks.begin(), m_containedLinks.end() );
262  m_identifiedLinks.erase( m_identifiedLinks.begin(), m_identifiedLinks.end() );
263  }
264 
266  bool isReading() const { return m_mode == READING; }
267 
269  bool isWriting() const { return m_mode == WRITING; }
271  long buffPointer() const { return m_pointer; }
273  void setBuffPointer( long ptr ) { m_pointer = ptr; }
275  void setAnalyzer( AnalyzeFunction fun = nullptr ) { m_analyzer = fun; }
277  void swapToBuffer( const void* source, int siz );
278 
280  void swapFromBuffer( void* target, int siz );
281 
283  StreamBuffer& writeBytes( const char* str, long len )
284  {
285  extend( m_pointer + len + 4 );
286  *this << len;
287  std::copy_n( str, len, data() + buffPointer() );
288  m_pointer += len;
289  return *this;
290  }
291 
292  void getIdentifiedLink( DataObject*& pObject, long& hint )
293  {
294  IdentifiedLink& l = m_identifiedLinks.back();
295  pObject = l.first;
296  hint = l.second;
297  m_identifiedLinks.pop_back();
298  }
299  void addIdentifiedLink( const DataObject* pObject, long hint )
300  {
301  m_identifiedLinks.push_back( IdentifiedLink( (DataObject*)pObject, hint ) );
302  }
303 
304  void getContainedLink( ContainedObject*& pObject, long& hint, long& link )
305  {
306  ContainedLink& l = m_containedLinks.back();
307  pObject = l.first;
308  hint = l.second;
309  link = l.third;
310  m_containedLinks.pop_back();
311  }
312  void addContainedLink( const ContainedObject* pObject, long hint, long link )
313  {
314  m_containedLinks.push_back( ContainedLink( (ContainedObject*)pObject, hint, link ) );
315  }
316 
317 #ifdef USE_STREAM_ANALYSER
318 #define STREAM_ANALYSE( data, len ) \
319  if ( 0 != m_analyzer ) m_analyzer( &data, len, typeid( data ) )
320 #else
321 #define STREAM_ANALYSE( data, len )
322 #endif
323 
324 // Implement streamer macros for primivive data types.
325 #define IMPLEMENT_STREAMER( TYPE ) \
326  /* Output Streamer */ \
327  StreamBuffer& operator<<( TYPE data ) \
328  { \
329  swapToBuffer( &data, sizeof( data ) ); \
330  STREAM_ANALYSE( data, sizeof( data ) ); \
331  return *this; \
332  } \
333  /* Input Streamer */ \
334  StreamBuffer& operator>>( TYPE& data ) \
335  { \
336  swapFromBuffer( &data, sizeof( data ) ); \
337  return *this; \
338  }
339 // RootCint does not understand this macro....
340 // But we can easily live without it!
341 #undef IMPLEMENT_STREAMER
342 
345  {
346  swapToBuffer( &data, sizeof( data ) );
347  STREAM_ANALYSE( data, sizeof( data ) );
348  return *this;
349  }
352  {
353  swapFromBuffer( &data, sizeof( data ) );
354  return *this;
355  }
358  {
359  swapToBuffer( &data, sizeof( data ) );
360  STREAM_ANALYSE( data, sizeof( data ) );
361  return *this;
362  }
364  StreamBuffer& operator>>( int& data )
365  {
366  swapFromBuffer( &data, sizeof( data ) );
367  return *this;
368  }
370  StreamBuffer& operator<<( unsigned int data )
371  {
372  swapToBuffer( &data, sizeof( data ) );
373  STREAM_ANALYSE( data, sizeof( data ) );
374  return *this;
375  }
377  StreamBuffer& operator>>( unsigned int& data )
378  {
379  swapFromBuffer( &data, sizeof( data ) );
380  return *this;
381  }
383  StreamBuffer& operator<<( long data )
384  {
385  swapToBuffer( &data, sizeof( data ) );
386  STREAM_ANALYSE( data, sizeof( data ) );
387  return *this;
388  }
390  StreamBuffer& operator>>( long& data )
391  {
392  swapFromBuffer( &data, sizeof( data ) );
393  return *this;
394  }
396  StreamBuffer& operator<<( unsigned long data )
397  {
398  swapToBuffer( &data, sizeof( data ) );
399  STREAM_ANALYSE( data, sizeof( data ) );
400  return *this;
401  }
403  StreamBuffer& operator>>( unsigned long& data )
404  {
405  swapFromBuffer( &data, sizeof( data ) );
406  return *this;
407  }
409  StreamBuffer& operator<<( short data )
410  {
411  swapToBuffer( &data, sizeof( data ) );
412  STREAM_ANALYSE( data, sizeof( data ) );
413  return *this;
414  }
416  StreamBuffer& operator>>( short& data )
417  {
418  swapFromBuffer( &data, sizeof( data ) );
419  return *this;
420  }
422  StreamBuffer& operator<<( unsigned short data )
423  {
424  swapToBuffer( &data, sizeof( data ) );
425  STREAM_ANALYSE( data, sizeof( data ) );
426  return *this;
427  }
429  StreamBuffer& operator>>( unsigned short& data )
430  {
431  swapFromBuffer( &data, sizeof( data ) );
432  return *this;
433  }
435  StreamBuffer& operator<<( char data )
436  {
437  swapToBuffer( &data, sizeof( data ) );
438  STREAM_ANALYSE( data, sizeof( data ) );
439  return *this;
440  }
442  StreamBuffer& operator>>( char& data )
443  {
444  swapFromBuffer( &data, sizeof( data ) );
445  return *this;
446  }
448  StreamBuffer& operator<<( unsigned char data )
449  {
450  swapToBuffer( &data, sizeof( data ) );
451  STREAM_ANALYSE( data, sizeof( data ) );
452  return *this;
453  }
455  StreamBuffer& operator>>( unsigned char& data )
456  {
457  swapFromBuffer( &data, sizeof( data ) );
458  return *this;
459  }
461  StreamBuffer& operator<<( float data )
462  {
463  swapToBuffer( &data, sizeof( data ) );
464  STREAM_ANALYSE( data, sizeof( data ) );
465  return *this;
466  }
468  StreamBuffer& operator>>( float& data )
469  {
470  swapFromBuffer( &data, sizeof( data ) );
471  return *this;
472  }
474  StreamBuffer& operator<<( double data )
475  {
476  swapToBuffer( &data, sizeof( data ) );
477  STREAM_ANALYSE( data, sizeof( data ) );
478  return *this;
479  }
481  StreamBuffer& operator>>( double& data )
482  {
483  swapFromBuffer( &data, sizeof( data ) );
484  return *this;
485  }
487  StreamBuffer& operator>>( char* data )
488  {
489  long i, len;
490  *this >> len;
491  for ( i = 0, data[0] = 0; i < len; i++ ) {
492  data[i] = m_buffer[m_pointer++];
493  }
494  return *this;
495  }
497  StreamBuffer& operator<<( const char* data )
498  {
499  const char* ptr = 0 == data ? "" : data;
500  int len = strlen( ptr ) + 1;
501  if ( 0 == m_analyzer )
502  writeBytes( ptr, len );
503  else {
504  STREAM_ANALYSE( data, len );
505  }
506  return *this;
507  }
510  {
511  long i, len;
512  *this >> len;
513  for ( i = 0, data = ""; i < len; i++ ) {
514  data.append( 1, m_buffer[m_pointer++] );
515  }
516  return *this;
517  }
520  {
521  if ( 0 == m_analyzer ) {
522  const char* ptr = data.c_str();
523  long len = data.length();
524  writeBytes( ptr, len );
525  } else {
526  STREAM_ANALYSE( data, sizeof( data ) );
527  }
528  return *this;
529  }
536  template <class TYPE>
537  StreamBuffer& operator>>( TYPE*& refpObject )
538  {
539  return getObjectPointer( refpObject, refpObject );
540  }
541 
549  {
550  STREAM_ANALYSE( pObject, sizeof( pObject ) );
551  addContainedLink( pObject, INVALID, INVALID );
552  return *this;
553  }
554 
561  StreamBuffer& operator<<( const DataObject* pObject )
562  {
563  STREAM_ANALYSE( pObject, sizeof( pObject ) );
564  addIdentifiedLink( pObject, INVALID );
565  return *this;
566  }
567 
574  void serialize( DataIO& ioObject )
575  {
576  ioObject.serialize( *this );
577  m_pointer = 0;
578  }
579 };
580 
581 #undef STREAM_ANALYSE
582 
585 {
586  switch ( siz ) {
587  case 1:
588  return SINGLE_BYTE;
589  default:
590 #if defined( __alpha ) && !defined( __VMS )
591  // return m_swapEnabled ? SWAP : NOSWAP;
592  return NOSWAP;
593 #elif defined( __sun ) && defined( __SVR4 ) && defined( __i386 )
594  // return m_swapEnabled ? SWAP : NOSWAP;
595  return NOSWAP;
596 #elif defined( __APPLE__ )
597  // return m_swapEnabled ? SWAP : NOSWAP;
598  return SWAP;
599 #elif defined( __linux ) && !defined( __powerpc )
600  // return m_swapEnabled ? SWAP : NOSWAP;
601  return NOSWAP;
602 #elif defined( BORLAND ) || defined( _WIN32 ) || defined( WIN32 )
603  // return m_swapEnabled ? SWAP : NOSWAP;
604  return NOSWAP;
605 #else
606  return m_swapEnabled ? SWAP : NOSWAP;
607 // return NOSWAP;
608 #endif
609  }
610 }
611 
613 inline void StreamBuffer::swapToBuffer( const void* source, int siz )
614 {
615  char buff[8], *tar, *src = (char *)source;
616  extend( m_pointer + siz );
617  tar = (char*)m_buffer + m_pointer;
618  switch ( swapBuffer( siz ) ) {
619  case SINGLE_BYTE:
620  *tar = *src;
621  break;
622  case SWAP:
623 #ifdef __APPLE__
624  for ( int i = 0, j = siz - 1; i < siz; i++, j-- ) tar[j] = src[i];
625 #else
626  ::_swab( src, buff, siz );
627 #endif
628  src = buff;
629  /* FALLTHROUGH */
630  case NOSWAP:
631  std::copy_n( src, siz, tar );
632  break;
633  }
634  m_pointer += siz;
635 }
636 
638 inline void StreamBuffer::swapFromBuffer( void* target, int siz )
639 {
640  char* tar = (char*)target;
641  char* src = (char*)m_buffer + m_pointer;
642  switch ( swapBuffer( siz ) ) {
643  case SINGLE_BYTE:
644  *tar = *src;
645  break;
646  case SWAP:
647 #ifdef __APPLE__
648  for ( int i = 0, j = siz - 1; i < siz; i++, j-- ) tar[j] = src[i];
649 #else
650  ::_swab( src, tar, siz );
651 #endif
652  break;
653  case NOSWAP:
654  std::copy_n( src, siz, tar );
655  break;
656  }
657  m_pointer += siz;
658 }
659 
660 // Output serialize a vector of items
661 template <class T>
662 inline StreamBuffer& operator<<( StreamBuffer& s, const std::vector<T>& v )
663 {
664  s << v.size();
665  for ( const auto& i : v ) s << i;
666  return s;
667 }
668 
669 // Input serialize a vector of items
670 template <class T>
672 {
673  long i, len;
674  s >> len;
675  v.clear();
676  for ( i = 0; i < len; i++ ) {
677  T temp;
678  s >> temp;
679  v.push_back( temp );
680  }
681  return s;
682 }
683 
684 // Output serialize a list of items
685 template <class T>
686 inline StreamBuffer& operator<<( StreamBuffer& s, const std::list<T>& l )
687 {
688  s << l.size();
689  for ( const auto& i : l ) s << i;
690  return s;
691 }
692 
693 // Input serialize a list of items
694 template <class T>
696 {
697  long len;
698  s >> len;
699  l.clear();
700  for ( long i = 0; i < len; i++ ) {
701  T temp;
702  s >> temp;
703  l.push_back( temp );
704  }
705  return s;
706 }
707 #endif // GAUDIKERNEL_STREAMBUFFER_H
virtual void load(StreamBuffer &)
Template function to load stream data.
Definition: StreamBuffer.h:65
Writer for standard output streams.
Definition: StreamBuffer.h:94
StreamBuffer(bool do_swap=true)
Standard constructor.
Definition: StreamBuffer.h:205
std::ostream * m_stream
Definition: StreamBuffer.h:96
Mode
Streamer mode.
Definition: StreamBuffer.h:115
virtual void serialize(StreamBuffer &stream)
Serialization method: loads/dumps streambuffer content.
Definition: StreamBuffer.h:55
StreamBuffer & operator<<(const char *data)
Streamer to write strings in (char*) format.
Definition: StreamBuffer.h:497
long buffPointer() const
Retrieve current buffer pointer.
Definition: StreamBuffer.h:271
StreamBuffer & operator>>(long &data)
Input Streamer.
Definition: StreamBuffer.h:390
StreamBuffer & operator>>(unsigned short &data)
Input Streamer.
Definition: StreamBuffer.h:429
Ostream(std::ostream &str)
Standard constructor: pass reference to stream object.
Definition: StreamBuffer.h:100
StreamBuffer & operator<<(double data)
Output Streamer.
Definition: StreamBuffer.h:474
std::istream * m_stream
Reference to input stream.
Definition: StreamBuffer.h:74
DataIO()=default
Standard constructor.
StreamBuffer & operator<<(float data)
Output Streamer.
Definition: StreamBuffer.h:461
StreamBuffer & operator<<(const DataObject *pObject)
Streamer to write links to identified objects.
Definition: StreamBuffer.h:561
The stream buffer is a small object collecting object data.
Definition: StreamBuffer.h:41
StreamBuffer & operator>>(float &data)
Input Streamer.
Definition: StreamBuffer.h:468
SwapAction
Data Sawp actions.
Definition: StreamBuffer.h:117
ContainedLinks m_containedLinks
Container with links to contained objects.
Definition: StreamBuffer.h:167
Istream(std::istream &str)
Constructor.
Definition: StreamBuffer.h:78
AnalyzeFunction m_analyzer
Hook function for analysis of data to the stream.
Definition: StreamBuffer.h:173
virtual void dump(StreamBuffer &)
Template function to save stream data.
Definition: StreamBuffer.h:67
long m_length
Total buffer length.
Definition: StreamBuffer.h:158
IdentifiedLinks & identifiedLinks()
Access to identified links.
Definition: StreamBuffer.h:252
char * m_buffer
Pointer to heap buffer.
Definition: StreamBuffer.h:161
class MergingTransformer< Out(const vector_of_const_< In > void
void extend(long len)
Extend the buffer.
Definition: StreamBuffer.h:234
StreamBuffer & operator<<(const ContainedObject *pObject)
Streamer to write links to contained objects.
Definition: StreamBuffer.h:548
StreamBuffer & operator>>(char *data)
Streamer to read strings in (char*) format.
Definition: StreamBuffer.h:487
void swapToBuffer(const void *source, int siz)
Swap buffers: int, long, short, float and double.
Definition: StreamBuffer.h:613
T end(T...args)
bool isReading() const
Get stream buffer state.
Definition: StreamBuffer.h:266
std::vector< ContainedLink > ContainedLinks
Definition: StreamBuffer.h:142
StreamBuffer & operator<<(unsigned long data)
Output Streamer.
Definition: StreamBuffer.h:396
T copy_n(T...args)
StreamBuffer & operator<<(unsigned short data)
Output Streamer.
Definition: StreamBuffer.h:422
Reader for standard input streams.
Definition: StreamBuffer.h:71
const char * data() const
Read access to data buffer.
Definition: StreamBuffer.h:209
STL class.
void setAnalyzer(AnalyzeFunction fun=nullptr)
Enable user analysis function.
Definition: StreamBuffer.h:275
char * data()
write access to data buffer
Definition: StreamBuffer.h:211
void setBuffPointer(long ptr)
Retrieve current buffer pointer.
Definition: StreamBuffer.h:273
StreamBuffer & operator>>(unsigned char &data)
Input Streamer.
Definition: StreamBuffer.h:455
constexpr double second
STL class.
StreamBuffer & operator<<(int data)
Output Streamer.
Definition: StreamBuffer.h:357
StreamBuffer & operator>>(longlong &data)
Input Streamer.
Definition: StreamBuffer.h:351
void(* AnalyzeFunction)(const void *data, int siz, const std::type_info &type)
Definition of the buffer analyzer.
Definition: StreamBuffer.h:146
T push_back(T...args)
void reserve(long len)
Reserve buffer space; Default: 16 k buffer size.
Definition: StreamBuffer.h:226
Mode m_mode
Boolean indicating wether the stream is in read or write mode.
Definition: StreamBuffer.h:152
#define STREAM_ANALYSE(data, len)
Definition: StreamBuffer.h:321
const IdentifiedLinks & identifiedLinks() const
CONST Access to identified links.
Definition: StreamBuffer.h:254
ContainedLinks & containedLinks()
Access to contained links.
Definition: StreamBuffer.h:247
StreamBuffer & operator<<(long data)
Output Streamer.
Definition: StreamBuffer.h:383
constexpr double m
Definition: SystemOfUnits.h:94
T append(T...args)
StreamBuffer & operator<<(unsigned char data)
Output Streamer.
Definition: StreamBuffer.h:448
T erase(T...args)
T pop_back(T...args)
StreamBuffer & operator<<(longlong data)
Output Streamer.
Definition: StreamBuffer.h:344
StreamBuffer & operator<<(short data)
Output Streamer.
Definition: StreamBuffer.h:409
StreamBuffer & getObjectPointer(const ContainedObject *, TYPE *&refpObject)
Helper to distinguish between identified pointers and contained pointers.
Definition: StreamBuffer.h:194
StreamBuffer & operator<<(const std::string &data)
Streamer to write strings in (std::string) format.
Definition: StreamBuffer.h:519
void badStreamMode()
Throw Exception.
Definition: StreamBuffer.h:53
T clear(T...args)
void load(StreamBuffer &stream) override
Data load method.
Definition: StreamBuffer.h:83
STL class.
StreamBuffer & operator>>(char &data)
Input Streamer.
Definition: StreamBuffer.h:442
StreamBuffer & operator>>(unsigned long &data)
Input Streamer.
Definition: StreamBuffer.h:403
#define _swab(source, target, radix)
Definition: swab.h:7
void addIdentifiedLink(const DataObject *pObject, long hint)
Definition: StreamBuffer.h:299
dictionary l
Definition: gaudirun.py:440
All classes that their objects may be contained in an LHCb ObjectContainer (e.g.
virtual ~DataIO()=default
Standard destructor.
T length(T...args)
void dump(StreamBuffer &stream) override
Output dumper.
Definition: StreamBuffer.h:105
bool isWriting() const
Get stream buffer state.
Definition: StreamBuffer.h:269
long m_pointer
Current buffer pointer.
Definition: StreamBuffer.h:155
T begin(T...args)
T write(T...args)
A small base class to handle generic data streaming.
Definition: StreamBuffer.h:45
T c_str(T...args)
double fun(const std::vector< double > &x)
Definition: PFuncTest.cpp:26
T back(T...args)
string s
Definition: gaudirun.py:253
State
Link state defintions.
Definition: StreamBuffer.h:119
T read(T...args)
StreamBuffer & writeBytes(const char *str, long len)
Write string to output stream.
Definition: StreamBuffer.h:283
virtual ~StreamBuffer()
Standard destructor.
Definition: StreamBuffer.h:207
void erase()
Reset the buffer.
Definition: StreamBuffer.h:213
StreamBuffer & operator<<(unsigned int data)
Output Streamer.
Definition: StreamBuffer.h:370
StreamBuffer & operator>>(std::string &data)
Streamer to read strings in (std::string) format.
Definition: StreamBuffer.h:509
StreamBuffer & operator<<(char data)
Output Streamer.
Definition: StreamBuffer.h:435
void setMode(Mode m)
Set mode of the stream and allocate buffer.
Definition: StreamBuffer.h:257
char * adopt() const
Remove the data buffer and pass it to client. It&#39;s the client responsability to free the memory...
Definition: StreamBuffer.h:215
StreamBuffer & getObjectPointer(const DataObject *, TYPE *&refpObject)
Helper to distinguish between identified pointers and contained pointers.
Definition: StreamBuffer.h:182
StreamBuffer & operator>>(unsigned int &data)
Input Streamer.
Definition: StreamBuffer.h:377
IdentifiedLinks m_identifiedLinks
Container with links to contained objects.
Definition: StreamBuffer.h:170
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:29
STL class.
SwapAction swapBuffer(int siz) const
Check for byte swapping.
Definition: StreamBuffer.h:584
StreamBuffer & operator>>(double &data)
Input Streamer.
Definition: StreamBuffer.h:481
void addContainedLink(const ContainedObject *pObject, long hint, long link)
Definition: StreamBuffer.h:312
void getContainedLink(ContainedObject *&pObject, long &hint, long &link)
Definition: StreamBuffer.h:304
long size() const
Total buffer size.
Definition: StreamBuffer.h:245
StreamBuffer & operator>>(int &data)
Input Streamer.
Definition: StreamBuffer.h:364
std::vector< IdentifiedLink > IdentifiedLinks
Definition of the identifiable link set.
Definition: StreamBuffer.h:144
void serialize(DataIO &ioObject)
Serialize the buffer using an IO object.
Definition: StreamBuffer.h:574
const ContainedLinks & containedLinks() const
CONST Access to contained links.
Definition: StreamBuffer.h:249
bool m_swapEnabled
Flag indicating swapping.
Definition: StreamBuffer.h:164
StreamBuffer & operator>>(short &data)
Input Streamer.
Definition: StreamBuffer.h:416
void getIdentifiedLink(DataObject *&pObject, long &hint)
Definition: StreamBuffer.h:292
StreamBuffer & operator>>(TYPE *&refpObject)
Streamer to read links to contained or identified objects.
Definition: StreamBuffer.h:537
void swapFromBuffer(void *target, int siz)
Swap buffers: int, long, short, float and double.
Definition: StreamBuffer.h:638