Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  v36r16 (ea80daf8)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
StreamBuffer.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2021 CERN for the benefit of the LHCb and ATLAS collaborations *
3 * *
4 * This software is distributed under the terms of the Apache version 2 licence, *
5 * copied verbatim in the file "LICENSE". *
6 * *
7 * In applying this licence, CERN does not waive the privileges and immunities *
8 * granted to it by virtue of its status as an Intergovernmental Organization *
9 * or submit itself to any jurisdiction. *
10 \***********************************************************************************/
11 #ifndef GAUDIKERNEL_STREAMBUFFER_H
12 #define GAUDIKERNEL_STREAMBUFFER_H 1
13 
14 // STL include files
15 #include <algorithm>
16 #include <cstdlib>
17 #include <cstring>
18 #include <iostream>
19 #include <list>
20 #include <string>
21 #include <typeinfo>
22 #include <vector>
23 
24 #include "GaudiKernel/Kernel.h"
25 #include "GaudiKernel/swab.h"
26 
27 // forward declarations
28 class StreamBuffer;
29 class DataObject;
30 class ContainedObject;
31 
51 class StreamBuffer /* : public std::string */
52 {
53 public:
55  class DataIO {
56  public:
58  DataIO() = default;
60  virtual ~DataIO() = default;
62  void badStreamMode() { throw( "Not acceptable stream mode!" ); }
64  virtual void serialize( StreamBuffer& stream ) {
65  if ( stream.isReading() )
66  load( stream );
67  else if ( stream.isWriting() )
68  dump( stream );
69  else
70  badStreamMode();
71  }
73  virtual void load( StreamBuffer& ) { badStreamMode(); }
75  virtual void dump( StreamBuffer& ) { badStreamMode(); }
76  };
77 
79  class Istream : public DataIO {
82 
83  public:
85  Istream( std::istream& str ) : m_stream( &str ) {}
86 
88  void load( StreamBuffer& stream ) override {
89  // Generic implementation for istreams:
90  int len;
91  ( *m_stream ) >> len;
92  stream.erase();
93  stream.reserve( len );
94  m_stream->read( stream.data(), len );
95  }
96  };
98  class Ostream : public DataIO {
100 
101  public:
103  Ostream( std::ostream& str ) : m_stream( &str ) {}
105  virtual ~Ostream() = default;
106 
108  void dump( StreamBuffer& stream ) override {
109  // Generic implementation for ostreams:
110  ( *m_stream ) << stream.buffPointer();
111  m_stream->write( stream.data(), stream.buffPointer() );
112  }
113  };
114 
115 public:
121  enum State { INVALID = -1, VALID };
124  public:
125  ContainedObject* first = nullptr;
126  long second = INVALID;
127  long third = INVALID;
128  ContainedLink() = default;
129  ContainedLink( ContainedObject* pObj, long hint, long link ) : first( pObj ), second( hint ), third( link ) {}
130  ContainedLink& operator=( const ContainedLink& copy ) = default;
131  };
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 
168 
171 
174 
176  SwapAction swapBuffer( int siz ) const;
177 
181  template <class TYPE>
182  StreamBuffer& getObjectPointer( const DataObject* /*pObject*/, TYPE*& refpObject ) {
184  DataObject* pObj = link.first;
186  refpObject = dynamic_cast<TYPE*>( pObj );
187  return *this;
188  }
192  template <class TYPE>
193  StreamBuffer& getObjectPointer( const ContainedObject* /*pObject*/, TYPE*& refpObject ) {
195  ContainedObject* pObj = link.first;
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  char* ptr = m_buffer;
217  m_buffer = NULL; // char *
218  m_pointer = 0; // long
219  m_length = 0; // long
220  return ptr;
221  }
223  void reserve( long len ) {
224  if ( len > m_length ) {
225  m_length = ( len < 16384 ) ? 16384 : len;
226  m_buffer = (char*)::realloc( m_buffer, m_length );
227  }
228  }
230  void extend( long len ) {
231  if ( len + m_pointer > m_length ) {
232  // We have to be a bit generous here in order not to run too often
233  // into ::realloc().
234  long new_len = ( m_length < 16384 ) ? 16384 : 2 * m_length;
235  if ( m_length < len ) new_len += len;
236  reserve( new_len );
237  }
238  }
240  long size() const { return m_length; }
244  const ContainedLinks& containedLinks() const { return m_containedLinks; }
245 
250 
252  void setMode( Mode m ) {
253  m_mode = m;
254  m_pointer = 0;
257  }
258 
260  bool isReading() const { return m_mode == READING; }
261 
263  bool isWriting() const { return m_mode == WRITING; }
265  long buffPointer() const { return m_pointer; }
267  void setBuffPointer( long ptr ) { m_pointer = ptr; }
269  void setAnalyzer( AnalyzeFunction fun = nullptr ) { m_analyzer = fun; }
271  void swapToBuffer( const void* source, int siz );
272 
274  void swapFromBuffer( void* target, int siz );
275 
277  StreamBuffer& writeBytes( const char* str, long len ) {
278  extend( m_pointer + len + 4 );
279  *this << len;
280  std::copy_n( str, len, data() + buffPointer() );
281  m_pointer += len;
282  return *this;
283  }
284 
285  void getIdentifiedLink( DataObject*& pObject, long& hint ) {
287  pObject = l.first;
288  hint = l.second;
290  }
291  void addIdentifiedLink( const DataObject* pObject, long hint ) {
293  }
294 
295  void getContainedLink( ContainedObject*& pObject, long& hint, long& link ) {
297  pObject = l.first;
298  hint = l.second;
299  link = l.third;
301  }
302  void addContainedLink( const ContainedObject* pObject, long hint, long link ) {
303  m_containedLinks.push_back( ContainedLink( (ContainedObject*)pObject, hint, link ) );
304  }
305 
306 #ifdef USE_STREAM_ANALYSER
307 # define STREAM_ANALYSE( data, len ) \
308  if ( 0 != m_analyzer ) m_analyzer( &data, len, typeid( data ) )
309 #else
310 # define STREAM_ANALYSE( data, len )
311 #endif
312 
313 // Implement streamer macros for primivive data types.
314 #define IMPLEMENT_STREAMER( TYPE ) \
315  /* Output Streamer */ \
316  StreamBuffer& operator<<( TYPE data ) { \
317  swapToBuffer( &data, sizeof( data ) ); \
318  STREAM_ANALYSE( data, sizeof( data ) ); \
319  return *this; \
320  } \
321  /* Input Streamer */ \
322  StreamBuffer& operator>>( TYPE& data ) { \
323  swapFromBuffer( &data, sizeof( data ) ); \
324  return *this; \
325  }
326 // RootCint does not understand this macro....
327 // But we can easily live without it!
328 #undef IMPLEMENT_STREAMER
329 
331  StreamBuffer& operator<<( long long data ) {
332  swapToBuffer( &data, sizeof( data ) );
333  STREAM_ANALYSE( data, sizeof( data ) );
334  return *this;
335  }
337  StreamBuffer& operator>>( long long& data ) {
338  swapFromBuffer( &data, sizeof( data ) );
339  return *this;
340  }
343  swapToBuffer( &data, sizeof( data ) );
344  STREAM_ANALYSE( data, sizeof( data ) );
345  return *this;
346  }
349  swapFromBuffer( &data, sizeof( data ) );
350  return *this;
351  }
353  StreamBuffer& operator<<( unsigned int data ) {
354  swapToBuffer( &data, sizeof( data ) );
355  STREAM_ANALYSE( data, sizeof( data ) );
356  return *this;
357  }
359  StreamBuffer& operator>>( unsigned int& data ) {
360  swapFromBuffer( &data, sizeof( data ) );
361  return *this;
362  }
365  swapToBuffer( &data, sizeof( data ) );
366  STREAM_ANALYSE( data, sizeof( data ) );
367  return *this;
368  }
371  swapFromBuffer( &data, sizeof( data ) );
372  return *this;
373  }
375  StreamBuffer& operator<<( unsigned long data ) {
376  swapToBuffer( &data, sizeof( data ) );
377  STREAM_ANALYSE( data, sizeof( data ) );
378  return *this;
379  }
381  StreamBuffer& operator>>( unsigned long& data ) {
382  swapFromBuffer( &data, sizeof( data ) );
383  return *this;
384  }
387  swapToBuffer( &data, sizeof( data ) );
388  STREAM_ANALYSE( data, sizeof( data ) );
389  return *this;
390  }
393  swapFromBuffer( &data, sizeof( data ) );
394  return *this;
395  }
397  StreamBuffer& operator<<( unsigned short data ) {
398  swapToBuffer( &data, sizeof( data ) );
399  STREAM_ANALYSE( data, sizeof( data ) );
400  return *this;
401  }
403  StreamBuffer& operator>>( unsigned short& data ) {
404  swapFromBuffer( &data, sizeof( data ) );
405  return *this;
406  }
409  swapToBuffer( &data, sizeof( data ) );
410  STREAM_ANALYSE( data, sizeof( data ) );
411  return *this;
412  }
415  swapFromBuffer( &data, sizeof( data ) );
416  return *this;
417  }
419  StreamBuffer& operator<<( unsigned char data ) {
420  swapToBuffer( &data, sizeof( data ) );
421  STREAM_ANALYSE( data, sizeof( data ) );
422  return *this;
423  }
425  StreamBuffer& operator>>( unsigned char& data ) {
426  swapFromBuffer( &data, sizeof( data ) );
427  return *this;
428  }
431  swapToBuffer( &data, sizeof( data ) );
432  STREAM_ANALYSE( data, sizeof( data ) );
433  return *this;
434  }
437  swapFromBuffer( &data, sizeof( data ) );
438  return *this;
439  }
442  swapToBuffer( &data, sizeof( data ) );
443  STREAM_ANALYSE( data, sizeof( data ) );
444  return *this;
445  }
448  swapFromBuffer( &data, sizeof( data ) );
449  return *this;
450  }
453  long i, len;
454  *this >> len;
455  for ( i = 0, data[0] = 0; i < len; i++ ) { data[i] = m_buffer[m_pointer++]; }
456  return *this;
457  }
459  StreamBuffer& operator<<( const char* data ) {
460  const char* ptr = 0 == data ? "" : data;
461  size_t len = strlen( ptr ) + 1;
462  if ( 0 == m_analyzer )
463  writeBytes( ptr, len );
464  else {
465  STREAM_ANALYSE( data, len );
466  }
467  return *this;
468  }
471  long i, len;
472  *this >> len;
473  for ( i = 0, data = ""; i < len; i++ ) { data.append( 1, m_buffer[m_pointer++] ); }
474  return *this;
475  }
478  if ( 0 == m_analyzer ) {
479  const char* ptr = data.c_str();
480  long len = data.length();
481  writeBytes( ptr, len );
482  } else {
483  STREAM_ANALYSE( data, sizeof( data ) );
484  }
485  return *this;
486  }
493  template <class TYPE>
494  StreamBuffer& operator>>( TYPE*& refpObject ) {
495  return getObjectPointer( refpObject, refpObject );
496  }
497 
505  STREAM_ANALYSE( pObject, sizeof( pObject ) );
506  addContainedLink( pObject, INVALID, INVALID );
507  return *this;
508  }
509 
516  StreamBuffer& operator<<( const DataObject* pObject ) {
517  STREAM_ANALYSE( pObject, sizeof( pObject ) );
518  addIdentifiedLink( pObject, INVALID );
519  return *this;
520  }
521 
528  void serialize( DataIO& ioObject ) {
529  ioObject.serialize( *this );
530  m_pointer = 0;
531  }
532 };
533 
534 #undef STREAM_ANALYSE
535 
538  switch ( siz ) {
539  case 1:
540  return SINGLE_BYTE;
541  default:
542 #if defined( __alpha ) && !defined( __VMS )
543  // return m_swapEnabled ? SWAP : NOSWAP;
544  return NOSWAP;
545 #elif defined( __sun ) && defined( __SVR4 ) && defined( __i386 )
546  // return m_swapEnabled ? SWAP : NOSWAP;
547  return NOSWAP;
548 #elif defined( __APPLE__ )
549  // return m_swapEnabled ? SWAP : NOSWAP;
550  return SWAP;
551 #elif defined( __linux ) && !defined( __powerpc )
552  // return m_swapEnabled ? SWAP : NOSWAP;
553  return NOSWAP;
554 #elif defined( BORLAND ) || defined( _WIN32 ) || defined( WIN32 )
555  // return m_swapEnabled ? SWAP : NOSWAP;
556  return NOSWAP;
557 #else
558  return m_swapEnabled ? SWAP : NOSWAP;
559 // return NOSWAP;
560 #endif
561  }
562 }
563 
565 inline void StreamBuffer::swapToBuffer( const void* source, int siz ) {
566  char buff[8], *tar, *src = (char*)source;
567  extend( m_pointer + siz );
568  tar = m_buffer + m_pointer;
569  switch ( swapBuffer( siz ) ) {
570  case SINGLE_BYTE:
571  *tar = *src;
572  break;
573  case SWAP:
574 #ifdef __APPLE__
575  for ( int i = 0, j = siz - 1; i < siz; i++, j-- ) tar[j] = src[i];
576 #else
577  ::_swab( src, buff, siz );
578 #endif
579  src = buff;
580  [[fallthrough]];
581  case NOSWAP:
582  std::copy_n( src, siz, tar );
583  break;
584  default:
585  break;
586  }
587  m_pointer += siz;
588 }
589 
591 inline void StreamBuffer::swapFromBuffer( void* target, int siz ) {
592  char* tar = (char*)target;
593  char* src = m_buffer + m_pointer;
594  switch ( swapBuffer( siz ) ) {
595  case SINGLE_BYTE:
596  *tar = *src;
597  break;
598  case SWAP:
599 #ifdef __APPLE__
600  for ( int i = 0, j = siz - 1; i < siz; i++, j-- ) tar[j] = src[i];
601 #else
602  ::_swab( src, tar, siz );
603 #endif
604  break;
605  case NOSWAP:
606  std::copy_n( src, siz, tar );
607  break;
608  default:
609  break;
610  }
611  m_pointer += siz;
612 }
613 
614 // Output serialize a vector of items
615 template <class T>
617  s << v.size();
618  for ( const auto& i : v ) s << i;
619  return s;
620 }
621 
622 // Input serialize a vector of items
623 template <class T>
625  long i, len;
626  s >> len;
627  v.clear();
628  for ( i = 0; i < len; i++ ) {
629  T temp;
630  s >> temp;
631  v.push_back( temp );
632  }
633  return s;
634 }
635 
636 // Output serialize a list of items
637 template <class T>
639  s << l.size();
640  for ( const auto& i : l ) s << i;
641  return s;
642 }
643 
644 // Input serialize a list of items
645 template <class T>
647  long len;
648  s >> len;
649  l.clear();
650  for ( long i = 0; i < len; i++ ) {
651  T temp;
652  s >> temp;
653  l.push_back( temp );
654  }
655  return s;
656 }
657 #endif // GAUDIKERNEL_STREAMBUFFER_H
StreamBuffer::operator<<
StreamBuffer & operator<<(const char *data)
Streamer to write strings in (char*) format.
Definition: StreamBuffer.h:459
StreamBuffer::Istream::m_stream
std::istream * m_stream
Reference to input stream.
Definition: StreamBuffer.h:81
StreamBuffer::identifiedLinks
IdentifiedLinks & identifiedLinks()
Access to identified links.
Definition: StreamBuffer.h:247
StreamBuffer::operator<<
StreamBuffer & operator<<(const std::string &data)
Streamer to write strings in (std::string) format.
Definition: StreamBuffer.h:477
StreamBuffer::operator>>
StreamBuffer & operator>>(int &data)
Input Streamer.
Definition: StreamBuffer.h:348
StreamBuffer::containedLinks
const ContainedLinks & containedLinks() const
CONST Access to contained links.
Definition: StreamBuffer.h:244
StreamBuffer::setBuffPointer
void setBuffPointer(long ptr)
Retrieve current buffer pointer.
Definition: StreamBuffer.h:267
StreamBuffer::adopt
char * adopt() const
Remove the data buffer and pass it to client. It's the client responsability to free the memory.
Definition: StreamBuffer.h:213
Write.stream
stream
Definition: Write.py:32
StreamBuffer::operator>>
StreamBuffer & operator>>(unsigned char &data)
Input Streamer.
Definition: StreamBuffer.h:425
StreamBuffer::operator<<
StreamBuffer & operator<<(float data)
Output Streamer.
Definition: StreamBuffer.h:430
StreamBuffer::addIdentifiedLink
void addIdentifiedLink(const DataObject *pObject, long hint)
Definition: StreamBuffer.h:291
StreamBuffer::m_buffer
char * m_buffer
Pointer to heap buffer.
Definition: StreamBuffer.h:161
std::string
STL class.
StreamBuffer::StreamBuffer
StreamBuffer(bool do_swap=true)
Standard constructor.
Definition: StreamBuffer.h:203
StreamBuffer::DataIO::~DataIO
virtual ~DataIO()=default
Standard destructor.
StreamBuffer::SWAP
@ SWAP
Definition: StreamBuffer.h:119
std::list
STL class.
StreamBuffer::operator<<
StreamBuffer & operator<<(short data)
Output Streamer.
Definition: StreamBuffer.h:386
StreamBuffer::Ostream::~Ostream
virtual ~Ostream()=default
Standard Destructor.
StreamBuffer::serialize
void serialize(DataIO &ioObject)
Serialize the buffer using an IO object.
Definition: StreamBuffer.h:528
StreamBuffer::m_containedLinks
ContainedLinks m_containedLinks
Container with links to contained objects.
Definition: StreamBuffer.h:167
gaudirun.s
string s
Definition: gaudirun.py:348
StreamBuffer::swapBuffer
SwapAction swapBuffer(int siz) const
Check for byte swapping.
Definition: StreamBuffer.h:537
std::vector< ContainedLink >
StreamBuffer::DataIO::badStreamMode
void badStreamMode()
Throw Exception.
Definition: StreamBuffer.h:62
std::type_info
StreamBuffer::DataIO::load
virtual void load(StreamBuffer &)
Template function to load stream data.
Definition: StreamBuffer.h:73
StreamBuffer::extend
void extend(long len)
Extend the buffer.
Definition: StreamBuffer.h:230
StreamBuffer::operator<<
StreamBuffer & operator<<(const DataObject *pObject)
Streamer to write links to identified objects.
Definition: StreamBuffer.h:516
StreamBuffer::operator<<
StreamBuffer & operator<<(unsigned short data)
Output Streamer.
Definition: StreamBuffer.h:397
StreamBuffer::m_mode
Mode m_mode
Boolean indicating wether the stream is in read or write mode.
Definition: StreamBuffer.h:152
StreamBuffer::operator<<
StreamBuffer & operator<<(unsigned long data)
Output Streamer.
Definition: StreamBuffer.h:375
StreamBuffer::SwapAction
SwapAction
Data Sawp actions.
Definition: StreamBuffer.h:119
StreamBuffer::buffPointer
long buffPointer() const
Retrieve current buffer pointer.
Definition: StreamBuffer.h:265
StreamBuffer::m_analyzer
AnalyzeFunction m_analyzer
Hook function for analysis of data to the stream.
Definition: StreamBuffer.h:173
std::vector::back
T back(T... args)
std::istream::read
T read(T... args)
StreamBuffer::operator<<
StreamBuffer & operator<<(const ContainedObject *pObject)
Streamer to write links to contained objects.
Definition: StreamBuffer.h:504
StreamBuffer::Istream::Istream
Istream(std::istream &str)
Constructor.
Definition: StreamBuffer.h:85
StreamBuffer::operator<<
StreamBuffer & operator<<(double data)
Output Streamer.
Definition: StreamBuffer.h:441
StreamBuffer::swapFromBuffer
void swapFromBuffer(void *target, int siz)
Swap buffers: int, long, short, float and double.
Definition: StreamBuffer.h:591
swab.h
StreamBuffer::m_swapEnabled
bool m_swapEnabled
Flag indicating swapping.
Definition: StreamBuffer.h:164
StreamBuffer::AnalyzeFunction
void(* AnalyzeFunction)(const void *data, int siz, const std::type_info &type)
Definition of the buffer analyzer.
Definition: StreamBuffer.h:146
std::ostream::write
T write(T... args)
StreamBuffer
Definition: StreamBuffer.h:52
StreamBuffer::READING
@ READING
Definition: StreamBuffer.h:117
StreamBuffer::Ostream
Writer for standard output streams.
Definition: StreamBuffer.h:98
std::vector::push_back
T push_back(T... args)
StreamBuffer::DataIO::serialize
virtual void serialize(StreamBuffer &stream)
Serialization method: loads/dumps streambuffer content.
Definition: StreamBuffer.h:64
compareOutputFiles.target
target
Definition: compareOutputFiles.py:498
StreamBuffer::operator>>
StreamBuffer & operator>>(unsigned short &data)
Input Streamer.
Definition: StreamBuffer.h:403
StreamBuffer::IdentifiedLinks
std::vector< IdentifiedLink > IdentifiedLinks
Definition of the identifiable link set.
Definition: StreamBuffer.h:144
std::copy_n
T copy_n(T... args)
StreamBuffer::swapToBuffer
void swapToBuffer(const void *source, int siz)
Swap buffers: int, long, short, float and double.
Definition: StreamBuffer.h:565
Gaudi::Units::m
constexpr double m
Definition: SystemOfUnits.h:108
StreamBuffer::State
State
Link state defintions.
Definition: StreamBuffer.h:121
ProduceConsume.j
j
Definition: ProduceConsume.py:101
std::ostream
STL class.
StreamBuffer::Istream::load
void load(StreamBuffer &stream) override
Data load method.
Definition: StreamBuffer.h:88
StreamBuffer::SINGLE_BYTE
@ SINGLE_BYTE
Definition: StreamBuffer.h:119
StreamBuffer::writeBytes
StreamBuffer & writeBytes(const char *str, long len)
Write string to output stream.
Definition: StreamBuffer.h:277
StreamBuffer::getObjectPointer
StreamBuffer & getObjectPointer(const ContainedObject *, TYPE *&refpObject)
Helper to distinguish between identified pointers and contained pointers.
Definition: StreamBuffer.h:193
operator<<
StreamBuffer & operator<<(StreamBuffer &s, const std::vector< T > &v)
Definition: StreamBuffer.h:616
StreamBuffer::operator>>
StreamBuffer & operator>>(unsigned long &data)
Input Streamer.
Definition: StreamBuffer.h:381
StreamBuffer::getObjectPointer
StreamBuffer & getObjectPointer(const DataObject *, TYPE *&refpObject)
Helper to distinguish between identified pointers and contained pointers.
Definition: StreamBuffer.h:182
StreamBuffer::containedLinks
ContainedLinks & containedLinks()
Access to contained links.
Definition: StreamBuffer.h:242
std::vector::erase
T erase(T... args)
StreamBuffer::isWriting
bool isWriting() const
Get stream buffer state.
Definition: StreamBuffer.h:263
StreamBuffer::operator<<
StreamBuffer & operator<<(char data)
Output Streamer.
Definition: StreamBuffer.h:408
StreamBuffer::identifiedLinks
const IdentifiedLinks & identifiedLinks() const
CONST Access to identified links.
Definition: StreamBuffer.h:249
StreamBuffer::setMode
void setMode(Mode m)
Set mode of the stream and allocate buffer.
Definition: StreamBuffer.h:252
StreamBuffer::operator<<
StreamBuffer & operator<<(long data)
Output Streamer.
Definition: StreamBuffer.h:364
StreamBuffer::size
long size() const
Total buffer size.
Definition: StreamBuffer.h:240
StreamBuffer::setAnalyzer
void setAnalyzer(AnalyzeFunction fun=nullptr)
Enable user analysis function.
Definition: StreamBuffer.h:269
StreamBuffer::data
char * data()
write access to data buffer
Definition: StreamBuffer.h:209
StreamBuffer::data
const char * data() const
Read access to data buffer.
Definition: StreamBuffer.h:207
StreamBuffer::isReading
bool isReading() const
Get stream buffer state.
Definition: StreamBuffer.h:260
StreamBuffer::~StreamBuffer
virtual ~StreamBuffer()
Standard destructor.
Definition: StreamBuffer.h:205
StreamBuffer::DataIO::dump
virtual void dump(StreamBuffer &)
Template function to save stream data.
Definition: StreamBuffer.h:75
std::vector::pop_back
T pop_back(T... args)
StreamBuffer::reserve
void reserve(long len)
Reserve buffer space; Default: 16 k buffer size.
Definition: StreamBuffer.h:223
StreamBuffer::operator<<
StreamBuffer & operator<<(int data)
Output Streamer.
Definition: StreamBuffer.h:342
StreamBuffer::operator>>
StreamBuffer & operator>>(char *data)
Streamer to read strings in (char*) format.
Definition: StreamBuffer.h:452
StreamBuffer::operator>>
StreamBuffer & operator>>(float &data)
Input Streamer.
Definition: StreamBuffer.h:436
StreamBuffer::operator>>
StreamBuffer & operator>>(std::string &data)
Streamer to read strings in (std::string) format.
Definition: StreamBuffer.h:470
StreamBuffer::operator<<
StreamBuffer & operator<<(long long data)
Output Streamer.
Definition: StreamBuffer.h:331
StreamBuffer::operator>>
StreamBuffer & operator>>(long &data)
Input Streamer.
Definition: StreamBuffer.h:370
HistoDumpEx.v
v
Definition: HistoDumpEx.py:27
StreamBuffer::UNINITIALIZED
@ UNINITIALIZED
Definition: StreamBuffer.h:117
StreamBuffer::Istream
Reader for standard input streams.
Definition: StreamBuffer.h:79
StreamBuffer::Ostream::dump
void dump(StreamBuffer &stream) override
Output dumper.
Definition: StreamBuffer.h:108
gaudirun.type
type
Definition: gaudirun.py:162
StreamBuffer::operator>>
StreamBuffer & operator>>(double &data)
Input Streamer.
Definition: StreamBuffer.h:447
StreamBuffer::Mode
Mode
Streamer mode.
Definition: StreamBuffer.h:117
gaudirun.l
dictionary l
Definition: gaudirun.py:582
std::vector::begin
T begin(T... args)
Kernel.h
StreamBuffer::operator>>
StreamBuffer & operator>>(short &data)
Input Streamer.
Definition: StreamBuffer.h:392
StreamBuffer::m_length
long m_length
Total buffer length.
Definition: StreamBuffer.h:158
StreamBuffer::m_pointer
long m_pointer
Current buffer pointer.
Definition: StreamBuffer.h:155
StreamBuffer::getIdentifiedLink
void getIdentifiedLink(DataObject *&pObject, long &hint)
Definition: StreamBuffer.h:285
StreamBuffer::erase
void erase()
Reset the buffer.
Definition: StreamBuffer.h:211
StreamBuffer::VALID
@ VALID
Definition: StreamBuffer.h:121
DataObject
Definition: DataObject.h:40
StreamBuffer::DataIO
A small base class to handle generic data streaming.
Definition: StreamBuffer.h:55
StreamBuffer::operator>>
StreamBuffer & operator>>(TYPE *&refpObject)
Streamer to read links to contained or identified objects.
Definition: StreamBuffer.h:494
operator>>
StreamBuffer & operator>>(StreamBuffer &s, std::vector< T > &v)
Definition: StreamBuffer.h:624
StreamBuffer::DataIO::DataIO
DataIO()=default
Standard constructor.
StreamBuffer::operator<<
StreamBuffer & operator<<(unsigned char data)
Output Streamer.
Definition: StreamBuffer.h:419
StreamBuffer::operator>>
StreamBuffer & operator>>(unsigned int &data)
Input Streamer.
Definition: StreamBuffer.h:359
std::vector::end
T end(T... args)
_swab
#define _swab(source, target, radix)
Definition: swab.h:17
StreamBuffer::addContainedLink
void addContainedLink(const ContainedObject *pObject, long hint, long link)
Definition: StreamBuffer.h:302
std::istream
STL class.
StreamBuffer::Ostream::m_stream
std::ostream * m_stream
Definition: StreamBuffer.h:99
StreamBuffer::NOSWAP
@ NOSWAP
Definition: StreamBuffer.h:119
STREAM_ANALYSE
#define STREAM_ANALYSE(data, len)
Definition: StreamBuffer.h:310
StreamBuffer::operator>>
StreamBuffer & operator>>(long long &data)
Input Streamer.
Definition: StreamBuffer.h:337
StreamBuffer::operator>>
StreamBuffer & operator>>(char &data)
Input Streamer.
Definition: StreamBuffer.h:414
StreamBuffer::WRITING
@ WRITING
Definition: StreamBuffer.h:117
StreamBuffer::ContainedLinks
std::vector< ContainedLink > ContainedLinks
Definition: StreamBuffer.h:142
ContainedObject
Definition: ContainedObject.h:41
StreamBuffer::m_identifiedLinks
IdentifiedLinks m_identifiedLinks
Container with links to contained objects.
Definition: StreamBuffer.h:170
StreamBuffer::getContainedLink
void getContainedLink(ContainedObject *&pObject, long &hint, long &link)
Definition: StreamBuffer.h:295
StreamBuffer::operator<<
StreamBuffer & operator<<(unsigned int data)
Output Streamer.
Definition: StreamBuffer.h:353
StreamBuffer::INVALID
@ INVALID
Definition: StreamBuffer.h:121
StreamBuffer::Ostream::Ostream
Ostream(std::ostream &str)
Standard constructor: pass reference to stream object.
Definition: StreamBuffer.h:103