The Gaudi Framework  v30r3 (a5ef0a68)
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 ) {}
79 
81  void load( StreamBuffer& stream ) override
82  {
83  // Generic implementation for istreams:
84  int len;
85  ( *m_stream ) >> len;
86  stream.erase();
87  stream.reserve( len );
88  m_stream->read( stream.data(), len );
89  }
90  };
92  class Ostream : public DataIO
93  {
95 
96  public:
98  Ostream( std::ostream& str ) : m_stream( &str ) {}
100  virtual ~Ostream() = default;
101 
103  void dump( StreamBuffer& stream ) override
104  {
105  // Generic implementation for ostreams:
106  ( *m_stream ) << stream.buffPointer();
107  m_stream->write( stream.data(), stream.buffPointer() );
108  }
109  };
110 
111 public:
117  enum State { INVALID = -1, VALID };
120  {
121  public:
123  long second;
124  long third;
125  ContainedLink() : first( 0 ), second( INVALID ), third( INVALID ) {}
126  ContainedLink( const ContainedLink& copy ) : first( copy.first ), second( copy.second ), third( copy.third ) {}
127  ContainedLink( ContainedObject* pObj, long hint, long link ) : first( pObj ), second( hint ), third( link ) {}
128  };
131  {
132  public:
133  DataObject* first = nullptr;
134  long second = INVALID;
135  IdentifiedLink() = default;
136  IdentifiedLink( const IdentifiedLink& copy ) = default;
137  IdentifiedLink( DataObject* pObj, long hint ) : first( pObj ), second( hint ) {}
138  };
139 
144  typedef void ( *AnalyzeFunction )( const void* data, int siz, const std::type_info& type );
146  friend class DataObject;
147 
148 protected:
151 
153  mutable long m_pointer = 0;
154 
156  mutable long m_length = 0;
157 
159  mutable char* m_buffer = nullptr;
160 
162  bool m_swapEnabled = true;
163 
165  mutable ContainedLinks m_containedLinks;
166 
168  mutable IdentifiedLinks m_identifiedLinks;
169 
172 
174  SwapAction swapBuffer( int siz ) const;
175 
179  template <class TYPE>
180  StreamBuffer& getObjectPointer( const DataObject* /*pObject*/, TYPE*& refpObject )
181  {
182  IdentifiedLink& link = m_identifiedLinks.back();
183  DataObject* pObj = link.first;
184  m_identifiedLinks.pop_back();
185  refpObject = dynamic_cast<TYPE*>( pObj );
186  return *this;
187  }
191  template <class TYPE>
192  StreamBuffer& getObjectPointer( const ContainedObject* /*pObject*/, TYPE*& refpObject )
193  {
194  ContainedLink& link = m_containedLinks.back();
195  ContainedObject* pObj = link.first;
196  m_containedLinks.pop_back();
197  refpObject = dynamic_cast<TYPE*>( pObj );
198  return *this;
199  }
200 
201 public:
203  StreamBuffer( bool do_swap = true ) : m_swapEnabled( do_swap ) {}
205  virtual ~StreamBuffer() { ::free( m_buffer ); }
207  const char* data() const { return m_buffer; }
209  char* data() { return m_buffer; }
211  void erase() { m_pointer = 0; }
213  char* adopt() const
214  {
215  char* ptr = m_buffer;
216  m_containedLinks.erase( m_containedLinks.begin(), m_containedLinks.end() );
217  m_identifiedLinks.erase( m_identifiedLinks.begin(), m_identifiedLinks.end() );
218  m_buffer = NULL; // char *
219  m_pointer = 0; // long
220  m_length = 0; // long
221  return ptr;
222  }
224  void reserve( long len )
225  {
226  if ( len > m_length ) {
227  m_length = ( len < 16384 ) ? 16384 : len;
228  m_buffer = (char*)::realloc( m_buffer, m_length );
229  }
230  }
232  void extend( long len )
233  {
234  if ( len + m_pointer > m_length ) {
235  // We have to be a bit generous here in order not to run too often
236  // into ::realloc().
237  long new_len = ( m_length < 16384 ) ? 16384 : 2 * m_length;
238  if ( m_length < len ) new_len += len;
239  reserve( new_len );
240  }
241  }
243  long size() const { return m_length; }
245  ContainedLinks& containedLinks() { return m_containedLinks; }
247  const ContainedLinks& containedLinks() const { return m_containedLinks; }
248 
250  IdentifiedLinks& identifiedLinks() { return m_identifiedLinks; }
252  const IdentifiedLinks& identifiedLinks() const { return m_identifiedLinks; }
253 
255  void setMode( Mode m )
256  {
257  m_mode = m;
258  m_pointer = 0;
259  m_containedLinks.erase( m_containedLinks.begin(), m_containedLinks.end() );
260  m_identifiedLinks.erase( m_identifiedLinks.begin(), m_identifiedLinks.end() );
261  }
262 
264  bool isReading() const { return m_mode == READING; }
265 
267  bool isWriting() const { return m_mode == WRITING; }
269  long buffPointer() const { return m_pointer; }
271  void setBuffPointer( long ptr ) { m_pointer = ptr; }
273  void setAnalyzer( AnalyzeFunction fun = nullptr ) { m_analyzer = fun; }
275  void swapToBuffer( const void* source, int siz );
276 
278  void swapFromBuffer( void* target, int siz );
279 
281  StreamBuffer& writeBytes( const char* str, long len )
282  {
283  extend( m_pointer + len + 4 );
284  *this << len;
285  std::copy_n( str, len, data() + buffPointer() );
286  m_pointer += len;
287  return *this;
288  }
289 
290  void getIdentifiedLink( DataObject*& pObject, long& hint )
291  {
292  IdentifiedLink& l = m_identifiedLinks.back();
293  pObject = l.first;
294  hint = l.second;
295  m_identifiedLinks.pop_back();
296  }
297  void addIdentifiedLink( const DataObject* pObject, long hint )
298  {
299  m_identifiedLinks.push_back( IdentifiedLink( (DataObject*)pObject, hint ) );
300  }
301 
302  void getContainedLink( ContainedObject*& pObject, long& hint, long& link )
303  {
304  ContainedLink& l = m_containedLinks.back();
305  pObject = l.first;
306  hint = l.second;
307  link = l.third;
308  m_containedLinks.pop_back();
309  }
310  void addContainedLink( const ContainedObject* pObject, long hint, long link )
311  {
312  m_containedLinks.push_back( ContainedLink( (ContainedObject*)pObject, hint, link ) );
313  }
314 
315 #ifdef USE_STREAM_ANALYSER
316 #define STREAM_ANALYSE( data, len ) \
317  if ( 0 != m_analyzer ) m_analyzer( &data, len, typeid( data ) )
318 #else
319 #define STREAM_ANALYSE( data, len )
320 #endif
321 
322 // Implement streamer macros for primivive data types.
323 #define IMPLEMENT_STREAMER( TYPE ) \
324  /* Output Streamer */ \
325  StreamBuffer& operator<<( TYPE data ) \
326  { \
327  swapToBuffer( &data, sizeof( data ) ); \
328  STREAM_ANALYSE( data, sizeof( data ) ); \
329  return *this; \
330  } \
331  /* Input Streamer */ \
332  StreamBuffer& operator>>( TYPE& data ) \
333  { \
334  swapFromBuffer( &data, sizeof( data ) ); \
335  return *this; \
336  }
337 // RootCint does not understand this macro....
338 // But we can easily live without it!
339 #undef IMPLEMENT_STREAMER
340 
343  {
344  swapToBuffer( &data, sizeof( data ) );
345  STREAM_ANALYSE( data, sizeof( data ) );
346  return *this;
347  }
350  {
351  swapFromBuffer( &data, sizeof( data ) );
352  return *this;
353  }
356  {
357  swapToBuffer( &data, sizeof( data ) );
358  STREAM_ANALYSE( data, sizeof( data ) );
359  return *this;
360  }
362  StreamBuffer& operator>>( int& data )
363  {
364  swapFromBuffer( &data, sizeof( data ) );
365  return *this;
366  }
368  StreamBuffer& operator<<( unsigned int data )
369  {
370  swapToBuffer( &data, sizeof( data ) );
371  STREAM_ANALYSE( data, sizeof( data ) );
372  return *this;
373  }
375  StreamBuffer& operator>>( unsigned int& data )
376  {
377  swapFromBuffer( &data, sizeof( data ) );
378  return *this;
379  }
381  StreamBuffer& operator<<( long data )
382  {
383  swapToBuffer( &data, sizeof( data ) );
384  STREAM_ANALYSE( data, sizeof( data ) );
385  return *this;
386  }
388  StreamBuffer& operator>>( long& data )
389  {
390  swapFromBuffer( &data, sizeof( data ) );
391  return *this;
392  }
394  StreamBuffer& operator<<( unsigned long data )
395  {
396  swapToBuffer( &data, sizeof( data ) );
397  STREAM_ANALYSE( data, sizeof( data ) );
398  return *this;
399  }
401  StreamBuffer& operator>>( unsigned long& data )
402  {
403  swapFromBuffer( &data, sizeof( data ) );
404  return *this;
405  }
407  StreamBuffer& operator<<( short data )
408  {
409  swapToBuffer( &data, sizeof( data ) );
410  STREAM_ANALYSE( data, sizeof( data ) );
411  return *this;
412  }
414  StreamBuffer& operator>>( short& data )
415  {
416  swapFromBuffer( &data, sizeof( data ) );
417  return *this;
418  }
420  StreamBuffer& operator<<( unsigned short data )
421  {
422  swapToBuffer( &data, sizeof( data ) );
423  STREAM_ANALYSE( data, sizeof( data ) );
424  return *this;
425  }
427  StreamBuffer& operator>>( unsigned short& data )
428  {
429  swapFromBuffer( &data, sizeof( data ) );
430  return *this;
431  }
433  StreamBuffer& operator<<( char data )
434  {
435  swapToBuffer( &data, sizeof( data ) );
436  STREAM_ANALYSE( data, sizeof( data ) );
437  return *this;
438  }
440  StreamBuffer& operator>>( char& data )
441  {
442  swapFromBuffer( &data, sizeof( data ) );
443  return *this;
444  }
446  StreamBuffer& operator<<( unsigned char data )
447  {
448  swapToBuffer( &data, sizeof( data ) );
449  STREAM_ANALYSE( data, sizeof( data ) );
450  return *this;
451  }
453  StreamBuffer& operator>>( unsigned char& data )
454  {
455  swapFromBuffer( &data, sizeof( data ) );
456  return *this;
457  }
459  StreamBuffer& operator<<( float data )
460  {
461  swapToBuffer( &data, sizeof( data ) );
462  STREAM_ANALYSE( data, sizeof( data ) );
463  return *this;
464  }
466  StreamBuffer& operator>>( float& data )
467  {
468  swapFromBuffer( &data, sizeof( data ) );
469  return *this;
470  }
472  StreamBuffer& operator<<( double data )
473  {
474  swapToBuffer( &data, sizeof( data ) );
475  STREAM_ANALYSE( data, sizeof( data ) );
476  return *this;
477  }
479  StreamBuffer& operator>>( double& data )
480  {
481  swapFromBuffer( &data, sizeof( data ) );
482  return *this;
483  }
485  StreamBuffer& operator>>( char* data )
486  {
487  long i, len;
488  *this >> len;
489  for ( i = 0, data[0] = 0; i < len; i++ ) {
490  data[i] = m_buffer[m_pointer++];
491  }
492  return *this;
493  }
495  StreamBuffer& operator<<( const char* data )
496  {
497  const char* ptr = 0 == data ? "" : data;
498  int len = strlen( ptr ) + 1;
499  if ( 0 == m_analyzer )
500  writeBytes( ptr, len );
501  else {
502  STREAM_ANALYSE( data, len );
503  }
504  return *this;
505  }
508  {
509  long i, len;
510  *this >> len;
511  for ( i = 0, data = ""; i < len; i++ ) {
512  data.append( 1, m_buffer[m_pointer++] );
513  }
514  return *this;
515  }
518  {
519  if ( 0 == m_analyzer ) {
520  const char* ptr = data.c_str();
521  long len = data.length();
522  writeBytes( ptr, len );
523  } else {
524  STREAM_ANALYSE( data, sizeof( data ) );
525  }
526  return *this;
527  }
534  template <class TYPE>
535  StreamBuffer& operator>>( TYPE*& refpObject )
536  {
537  return getObjectPointer( refpObject, refpObject );
538  }
539 
547  {
548  STREAM_ANALYSE( pObject, sizeof( pObject ) );
549  addContainedLink( pObject, INVALID, INVALID );
550  return *this;
551  }
552 
559  StreamBuffer& operator<<( const DataObject* pObject )
560  {
561  STREAM_ANALYSE( pObject, sizeof( pObject ) );
562  addIdentifiedLink( pObject, INVALID );
563  return *this;
564  }
565 
572  void serialize( DataIO& ioObject )
573  {
574  ioObject.serialize( *this );
575  m_pointer = 0;
576  }
577 };
578 
579 #undef STREAM_ANALYSE
580 
583 {
584  switch ( siz ) {
585  case 1:
586  return SINGLE_BYTE;
587  default:
588 #if defined( __alpha ) && !defined( __VMS )
589  // return m_swapEnabled ? SWAP : NOSWAP;
590  return NOSWAP;
591 #elif defined( __sun ) && defined( __SVR4 ) && defined( __i386 )
592  // return m_swapEnabled ? SWAP : NOSWAP;
593  return NOSWAP;
594 #elif defined( __APPLE__ )
595  // return m_swapEnabled ? SWAP : NOSWAP;
596  return SWAP;
597 #elif defined( __linux ) && !defined( __powerpc )
598  // return m_swapEnabled ? SWAP : NOSWAP;
599  return NOSWAP;
600 #elif defined( BORLAND ) || defined( _WIN32 ) || defined( WIN32 )
601  // return m_swapEnabled ? SWAP : NOSWAP;
602  return NOSWAP;
603 #else
604  return m_swapEnabled ? SWAP : NOSWAP;
605 // return NOSWAP;
606 #endif
607  }
608 }
609 
611 inline void StreamBuffer::swapToBuffer( const void* source, int siz )
612 {
613  char buff[8], *tar, *src = (char *)source;
614  extend( m_pointer + siz );
615  tar = (char*)m_buffer + m_pointer;
616  switch ( swapBuffer( siz ) ) {
617  case SINGLE_BYTE:
618  *tar = *src;
619  break;
620  case SWAP:
621 #ifdef __APPLE__
622  for ( int i = 0, j = siz - 1; i < siz; i++, j-- ) tar[j] = src[i];
623 #else
624  ::_swab( src, buff, siz );
625 #endif
626  src = buff;
627  /* FALLTHROUGH */
628  case NOSWAP:
629  std::copy_n( src, siz, tar );
630  break;
631  }
632  m_pointer += siz;
633 }
634 
636 inline void StreamBuffer::swapFromBuffer( void* target, int siz )
637 {
638  char* tar = (char*)target;
639  char* src = (char*)m_buffer + m_pointer;
640  switch ( swapBuffer( siz ) ) {
641  case SINGLE_BYTE:
642  *tar = *src;
643  break;
644  case SWAP:
645 #ifdef __APPLE__
646  for ( int i = 0, j = siz - 1; i < siz; i++, j-- ) tar[j] = src[i];
647 #else
648  ::_swab( src, tar, siz );
649 #endif
650  break;
651  case NOSWAP:
652  std::copy_n( src, siz, tar );
653  break;
654  }
655  m_pointer += siz;
656 }
657 
658 // Output serialize a vector of items
659 template <class T>
660 inline StreamBuffer& operator<<( StreamBuffer& s, const std::vector<T>& v )
661 {
662  s << v.size();
663  for ( const auto& i : v ) s << i;
664  return s;
665 }
666 
667 // Input serialize a vector of items
668 template <class T>
670 {
671  long i, len;
672  s >> len;
673  v.clear();
674  for ( i = 0; i < len; i++ ) {
675  T temp;
676  s >> temp;
677  v.push_back( temp );
678  }
679  return s;
680 }
681 
682 // Output serialize a list of items
683 template <class T>
684 inline StreamBuffer& operator<<( StreamBuffer& s, const std::list<T>& l )
685 {
686  s << l.size();
687  for ( const auto& i : l ) s << i;
688  return s;
689 }
690 
691 // Input serialize a list of items
692 template <class T>
694 {
695  long len;
696  s >> len;
697  l.clear();
698  for ( long i = 0; i < len; i++ ) {
699  T temp;
700  s >> temp;
701  l.push_back( temp );
702  }
703  return s;
704 }
705 #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:92
StreamBuffer(bool do_swap=true)
Standard constructor.
Definition: StreamBuffer.h:203
std::ostream * m_stream
Definition: StreamBuffer.h:94
Mode
Streamer mode.
Definition: StreamBuffer.h:113
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:495
long buffPointer() const
Retrieve current buffer pointer.
Definition: StreamBuffer.h:269
StreamBuffer & operator>>(long &data)
Input Streamer.
Definition: StreamBuffer.h:388
StreamBuffer & operator>>(unsigned short &data)
Input Streamer.
Definition: StreamBuffer.h:427
Ostream(std::ostream &str)
Standard constructor: pass reference to stream object.
Definition: StreamBuffer.h:98
StreamBuffer & operator<<(double data)
Output Streamer.
Definition: StreamBuffer.h:472
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:459
StreamBuffer & operator<<(const DataObject *pObject)
Streamer to write links to identified objects.
Definition: StreamBuffer.h:559
The stream buffer is a small object collecting object data.
Definition: StreamBuffer.h:41
StreamBuffer & operator>>(float &data)
Input Streamer.
Definition: StreamBuffer.h:466
SwapAction
Data Sawp actions.
Definition: StreamBuffer.h:115
ContainedLinks m_containedLinks
Container with links to contained objects.
Definition: StreamBuffer.h:165
Istream(std::istream &str)
Constructor.
Definition: StreamBuffer.h:78
AnalyzeFunction m_analyzer
Hook function for analysis of data to the stream.
Definition: StreamBuffer.h:171
virtual void dump(StreamBuffer &)
Template function to save stream data.
Definition: StreamBuffer.h:67
long m_length
Total buffer length.
Definition: StreamBuffer.h:156
IdentifiedLinks & identifiedLinks()
Access to identified links.
Definition: StreamBuffer.h:250
char * m_buffer
Pointer to heap buffer.
Definition: StreamBuffer.h:159
class MergingTransformer< Out(const vector_of_const_< In > void
void extend(long len)
Extend the buffer.
Definition: StreamBuffer.h:232
StreamBuffer & operator<<(const ContainedObject *pObject)
Streamer to write links to contained objects.
Definition: StreamBuffer.h:546
StreamBuffer & operator>>(char *data)
Streamer to read strings in (char*) format.
Definition: StreamBuffer.h:485
void swapToBuffer(const void *source, int siz)
Swap buffers: int, long, short, float and double.
Definition: StreamBuffer.h:611
T end(T...args)
bool isReading() const
Get stream buffer state.
Definition: StreamBuffer.h:264
std::vector< ContainedLink > ContainedLinks
Definition: StreamBuffer.h:140
StreamBuffer & operator<<(unsigned long data)
Output Streamer.
Definition: StreamBuffer.h:394
T copy_n(T...args)
StreamBuffer & operator<<(unsigned short data)
Output Streamer.
Definition: StreamBuffer.h:420
Reader for standard input streams.
Definition: StreamBuffer.h:71
const char * data() const
Read access to data buffer.
Definition: StreamBuffer.h:207
STL class.
void setAnalyzer(AnalyzeFunction fun=nullptr)
Enable user analysis function.
Definition: StreamBuffer.h:273
char * data()
write access to data buffer
Definition: StreamBuffer.h:209
void setBuffPointer(long ptr)
Retrieve current buffer pointer.
Definition: StreamBuffer.h:271
StreamBuffer & operator>>(unsigned char &data)
Input Streamer.
Definition: StreamBuffer.h:453
constexpr double second
STL class.
StreamBuffer & operator<<(int data)
Output Streamer.
Definition: StreamBuffer.h:355
StreamBuffer & operator>>(longlong &data)
Input Streamer.
Definition: StreamBuffer.h:349
void(* AnalyzeFunction)(const void *data, int siz, const std::type_info &type)
Definition of the buffer analyzer.
Definition: StreamBuffer.h:144
T push_back(T...args)
void reserve(long len)
Reserve buffer space; Default: 16 k buffer size.
Definition: StreamBuffer.h:224
Mode m_mode
Boolean indicating wether the stream is in read or write mode.
Definition: StreamBuffer.h:150
#define STREAM_ANALYSE(data, len)
Definition: StreamBuffer.h:319
const IdentifiedLinks & identifiedLinks() const
CONST Access to identified links.
Definition: StreamBuffer.h:252
ContainedLinks & containedLinks()
Access to contained links.
Definition: StreamBuffer.h:245
StreamBuffer & operator<<(long data)
Output Streamer.
Definition: StreamBuffer.h:381
constexpr double m
Definition: SystemOfUnits.h:94
T append(T...args)
StreamBuffer & operator<<(unsigned char data)
Output Streamer.
Definition: StreamBuffer.h:446
T erase(T...args)
T pop_back(T...args)
StreamBuffer & operator<<(longlong data)
Output Streamer.
Definition: StreamBuffer.h:342
StreamBuffer & operator<<(short data)
Output Streamer.
Definition: StreamBuffer.h:407
StreamBuffer & getObjectPointer(const ContainedObject *, TYPE *&refpObject)
Helper to distinguish between identified pointers and contained pointers.
Definition: StreamBuffer.h:192
StreamBuffer & operator<<(const std::string &data)
Streamer to write strings in (std::string) format.
Definition: StreamBuffer.h:517
void badStreamMode()
Throw Exception.
Definition: StreamBuffer.h:53
T clear(T...args)
void load(StreamBuffer &stream) override
Data load method.
Definition: StreamBuffer.h:81
STL class.
StreamBuffer & operator>>(char &data)
Input Streamer.
Definition: StreamBuffer.h:440
StreamBuffer & operator>>(unsigned long &data)
Input Streamer.
Definition: StreamBuffer.h:401
#define _swab(source, target, radix)
Definition: swab.h:7
void addIdentifiedLink(const DataObject *pObject, long hint)
Definition: StreamBuffer.h:297
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:103
bool isWriting() const
Get stream buffer state.
Definition: StreamBuffer.h:267
long m_pointer
Current buffer pointer.
Definition: StreamBuffer.h:153
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:117
T read(T...args)
StreamBuffer & writeBytes(const char *str, long len)
Write string to output stream.
Definition: StreamBuffer.h:281
virtual ~StreamBuffer()
Standard destructor.
Definition: StreamBuffer.h:205
void erase()
Reset the buffer.
Definition: StreamBuffer.h:211
StreamBuffer & operator<<(unsigned int data)
Output Streamer.
Definition: StreamBuffer.h:368
StreamBuffer & operator>>(std::string &data)
Streamer to read strings in (std::string) format.
Definition: StreamBuffer.h:507
StreamBuffer & operator<<(char data)
Output Streamer.
Definition: StreamBuffer.h:433
void setMode(Mode m)
Set mode of the stream and allocate buffer.
Definition: StreamBuffer.h:255
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:213
StreamBuffer & getObjectPointer(const DataObject *, TYPE *&refpObject)
Helper to distinguish between identified pointers and contained pointers.
Definition: StreamBuffer.h:180
StreamBuffer & operator>>(unsigned int &data)
Input Streamer.
Definition: StreamBuffer.h:375
IdentifiedLinks m_identifiedLinks
Container with links to contained objects.
Definition: StreamBuffer.h:168
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:30
STL class.
SwapAction swapBuffer(int siz) const
Check for byte swapping.
Definition: StreamBuffer.h:582
StreamBuffer & operator>>(double &data)
Input Streamer.
Definition: StreamBuffer.h:479
void addContainedLink(const ContainedObject *pObject, long hint, long link)
Definition: StreamBuffer.h:310
void getContainedLink(ContainedObject *&pObject, long &hint, long &link)
Definition: StreamBuffer.h:302
long size() const
Total buffer size.
Definition: StreamBuffer.h:243
StreamBuffer & operator>>(int &data)
Input Streamer.
Definition: StreamBuffer.h:362
std::vector< IdentifiedLink > IdentifiedLinks
Definition of the identifiable link set.
Definition: StreamBuffer.h:142
void serialize(DataIO &ioObject)
Serialize the buffer using an IO object.
Definition: StreamBuffer.h:572
const ContainedLinks & containedLinks() const
CONST Access to contained links.
Definition: StreamBuffer.h:247
bool m_swapEnabled
Flag indicating swapping.
Definition: StreamBuffer.h:162
StreamBuffer & operator>>(short &data)
Input Streamer.
Definition: StreamBuffer.h:414
void getIdentifiedLink(DataObject *&pObject, long &hint)
Definition: StreamBuffer.h:290
StreamBuffer & operator>>(TYPE *&refpObject)
Streamer to read links to contained or identified objects.
Definition: StreamBuffer.h:535
void swapFromBuffer(void *target, int siz)
Swap buffers: int, long, short, float and double.
Definition: StreamBuffer.h:636