| The Gaudi Framework v32r1 (f65d50dc)

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 public:
48 DataIO() = default;
50 virtual ~DataIO() = default;
52 void badStreamMode() { throw( "Not acceptable stream mode!" ); }
54 virtual void serialize( StreamBuffer& stream ) {
55 if ( stream.isReading() )
56 load( stream );
57 else if ( stream.isWriting() )
58 dump( stream );
59 else
60 badStreamMode();
61 }
63 virtual void load( StreamBuffer& ) { badStreamMode(); }
65 virtual void dump( StreamBuffer& ) { badStreamMode(); }
66 };
67
69 class Istream : public DataIO {
71 std::istream* m_stream;
72
73 public:
75 Istream( std::istream& str ) : m_stream( &str ) {}
76
78 void load( StreamBuffer& stream ) override {
79 // Generic implementation for istreams:
80 int len;
81 ( *m_stream ) >> len;
82 stream.erase();
83 stream.reserve( len );
84 m_stream->read( stream.data(), len );
85 }
86 };
88 class Ostream : public DataIO {
89 std::ostream* m_stream;
90
91 public:
93 Ostream( std::ostream& str ) : m_stream( &str ) {}
95 virtual ~Ostream() = default;
96
98 void dump( StreamBuffer& stream ) override {
99 // Generic implementation for ostreams:
100 ( *m_stream ) << stream.buffPointer();
101 m_stream->write( stream.data(), stream.buffPointer() );
102 }
103 };
104
105 public:
107 enum Mode { UNINITIALIZED, READING, WRITING };
109 enum SwapAction { SINGLE_BYTE, SWAP, NOSWAP };
111 enum State { INVALID = -1, VALID };
113 class ContainedLink {
114 public:
115 ContainedObject* first;
116 long second;
117 long third;
118 ContainedLink() : first( 0 ), second( INVALID ), third( INVALID ) {}
119 ContainedLink( const ContainedLink& copy ) : first( copy.first ), second( copy.second ), third( copy.third ) {}
120 ContainedLink( ContainedObject* pObj, long hint, long link ) : first( pObj ), second( hint ), third( link ) {}
121 };
123 class IdentifiedLink {
124 public:
125 DataObject* first = nullptr;
126 long second = INVALID;
127 IdentifiedLink() = default;
128 IdentifiedLink( const IdentifiedLink& copy ) = default;
129 IdentifiedLink( DataObject* pObj, long hint ) : first( pObj ), second( hint ) {}
130 };
131
132 typedef std::vector<ContainedLink> ContainedLinks;
134 typedef std::vector<IdentifiedLink> IdentifiedLinks;
136 typedef void ( *AnalyzeFunction )( const void* data, int siz, const std::type_info& type );
138 friend class DataObject;
139
140 protected:
142 Mode m_mode = UNINITIALIZED;
143
145 mutable long m_pointer = 0;
146
148 mutable long m_length = 0;
149
151 mutable char* m_buffer = nullptr;
152
154 bool m_swapEnabled = true;
155
157 mutable ContainedLinks m_containedLinks;
158
160 mutable IdentifiedLinks m_identifiedLinks;
161
163 AnalyzeFunction m_analyzer = nullptr;
164
166 SwapAction swapBuffer( int siz ) const;
167
171 template <class TYPE>
172 StreamBuffer& getObjectPointer( const DataObject* /*pObject*/, TYPE*& refpObject ) {
173 IdentifiedLink& link = m_identifiedLinks.back();
174 DataObject* pObj = link.first;
175 m_identifiedLinks.pop_back();
176 refpObject = dynamic_cast<TYPE*>( pObj );
177 return *this;
178 }
182 template <class TYPE>
183 StreamBuffer& getObjectPointer( const ContainedObject* /*pObject*/, TYPE*& refpObject ) {
184 ContainedLink& link = m_containedLinks.back();
185 ContainedObject* pObj = link.first;
186 m_containedLinks.pop_back();
187 refpObject = dynamic_cast<TYPE*>( pObj );
188 return *this;
189 }
190
191 public:
193 StreamBuffer( bool do_swap = true ) : m_swapEnabled( do_swap ) {}
195 virtual ~StreamBuffer() { ::free( m_buffer ); }
197 const char* data() const { return m_buffer; }
199 char* data() { return m_buffer; }
201 void erase() { m_pointer = 0; }
203 char* adopt() const {
204 char* ptr = m_buffer;
205 m_containedLinks.erase( m_containedLinks.begin(), m_containedLinks.end() );
206 m_identifiedLinks.erase( m_identifiedLinks.begin(), m_identifiedLinks.end() );
207 m_buffer = NULL; // char *
208 m_pointer = 0; // long
209 m_length = 0; // long
210 return ptr;
211 }
213 void reserve( long len ) {
214 if ( len > m_length ) {
215 m_length = ( len < 16384 ) ? 16384 : len;
216 m_buffer = (char*)::realloc( m_buffer, m_length );
217 }
218 }
220 void extend( long len ) {
221 if ( len + m_pointer > m_length ) {
222 // We have to be a bit generous here in order not to run too often
223 // into ::realloc().
224 long new_len = ( m_length < 16384 ) ? 16384 : 2 * m_length;
225 if ( m_length < len ) new_len += len;
226 reserve( new_len );
227 }
228 }
230 long size() const { return m_length; }
232 ContainedLinks& containedLinks() { return m_containedLinks; }
234 const ContainedLinks& containedLinks() const { return m_containedLinks; }
235
237 IdentifiedLinks& identifiedLinks() { return m_identifiedLinks; }
239 const IdentifiedLinks& identifiedLinks() const { return m_identifiedLinks; }
240
242 void setMode( Mode m ) {
243 m_mode = m;
244 m_pointer = 0;
245 m_containedLinks.erase( m_containedLinks.begin(), m_containedLinks.end() );
246 m_identifiedLinks.erase( m_identifiedLinks.begin(), m_identifiedLinks.end() );
247 }
248
250 bool isReading() const { return m_mode == READING; }
251
253 bool isWriting() const { return m_mode == WRITING; }
255 long buffPointer() const { return m_pointer; }
257 void setBuffPointer( long ptr ) { m_pointer = ptr; }
259 void setAnalyzer( AnalyzeFunction fun = nullptr ) { m_analyzer = fun; }
261 void swapToBuffer( const void* source, int siz );
262
264 void swapFromBuffer( void* target, int siz );
265
267 StreamBuffer& writeBytes( const char* str, long len ) {
268 extend( m_pointer + len + 4 );
269 *this << len;
270 std::copy_n( str, len, data() + buffPointer() );
271 m_pointer += len;
272 return *this;
273 }
274
275 void getIdentifiedLink( DataObject*& pObject, long& hint ) {
276 IdentifiedLink& l = m_identifiedLinks.back();
277 pObject = l.first;
278 hint = l.second;
279 m_identifiedLinks.pop_back();
280 }
281 void addIdentifiedLink( const DataObject* pObject, long hint ) {
282 m_identifiedLinks.push_back( IdentifiedLink( (DataObject*)pObject, hint ) );
283 }
284
285 void getContainedLink( ContainedObject*& pObject, long& hint, long& link ) {
286 ContainedLink& l = m_containedLinks.back();
287 pObject = l.first;
288 hint = l.second;
289 link = l.third;
290 m_containedLinks.pop_back();
291 }
292 void addContainedLink( const ContainedObject* pObject, long hint, long link ) {
293 m_containedLinks.push_back( ContainedLink( (ContainedObject*)pObject, hint, link ) );
294 }
295
296 #ifdef USE_STREAM_ANALYSER
297 # define STREAM_ANALYSE( data, len ) \
298 if ( 0 != m_analyzer ) m_analyzer( &data, len, typeid( data ) )
299 #else
300 # define STREAM_ANALYSE( data, len )
301 #endif
302
303 // Implement streamer macros for primivive data types.
304 #define IMPLEMENT_STREAMER( TYPE ) \
305 /* Output Streamer */ \
306 StreamBuffer& operator<<( TYPE data ) { \
307 swapToBuffer( &data, sizeof( data ) ); \
308 STREAM_ANALYSE( data, sizeof( data ) ); \
309 return *this; \
310 } \
311 /* Input Streamer */ \
312 StreamBuffer& operator>>( TYPE& data ) { \
313 swapFromBuffer( &data, sizeof( data ) ); \
314 return *this; \
315 }
316 // RootCint does not understand this macro....
317 // But we can easily live without it!
318 #undef IMPLEMENT_STREAMER
319
321 StreamBuffer& operator<<( long long data ) {
322 swapToBuffer( &data, sizeof( data ) );
323 STREAM_ANALYSE( data, sizeof( data ) );
324 return *this;
325 }
327 StreamBuffer& operator>>( long long& data ) {
328 swapFromBuffer( &data, sizeof( data ) );
329 return *this;
330 }
332 StreamBuffer& operator<<( int data ) {
333 swapToBuffer( &data, sizeof( data ) );
334 STREAM_ANALYSE( data, sizeof( data ) );
335 return *this;
336 }
338 StreamBuffer& operator>>( int& data ) {
339 swapFromBuffer( &data, sizeof( data ) );
340 return *this;
341 }
343 StreamBuffer& operator<<( unsigned int data ) {
344 swapToBuffer( &data, sizeof( data ) );
345 STREAM_ANALYSE( data, sizeof( data ) );
346 return *this;
347 }
349 StreamBuffer& operator>>( unsigned int& data ) {
350 swapFromBuffer( &data, sizeof( data ) );
351 return *this;
352 }
354 StreamBuffer& operator<<( long data ) {
355 swapToBuffer( &data, sizeof( data ) );
356 STREAM_ANALYSE( data, sizeof( data ) );
357 return *this;
358 }
360 StreamBuffer& operator>>( long& data ) {
361 swapFromBuffer( &data, sizeof( data ) );
362 return *this;
363 }
365 StreamBuffer& operator<<( unsigned long data ) {
366 swapToBuffer( &data, sizeof( data ) );
367 STREAM_ANALYSE( data, sizeof( data ) );
368 return *this;
369 }
371 StreamBuffer& operator>>( unsigned long& data ) {
372 swapFromBuffer( &data, sizeof( data ) );
373 return *this;
374 }
376 StreamBuffer& operator<<( short data ) {
377 swapToBuffer( &data, sizeof( data ) );
378 STREAM_ANALYSE( data, sizeof( data ) );
379 return *this;
380 }
382 StreamBuffer& operator>>( short& data ) {
383 swapFromBuffer( &data, sizeof( data ) );
384 return *this;
385 }
387 StreamBuffer& operator<<( unsigned short data ) {
388 swapToBuffer( &data, sizeof( data ) );
389 STREAM_ANALYSE( data, sizeof( data ) );
390 return *this;
391 }
393 StreamBuffer& operator>>( unsigned short& data ) {
394 swapFromBuffer( &data, sizeof( data ) );
395 return *this;
396 }
398 StreamBuffer& operator<<( char data ) {
399 swapToBuffer( &data, sizeof( data ) );
400 STREAM_ANALYSE( data, sizeof( data ) );
401 return *this;
402 }
404 StreamBuffer& operator>>( char& data ) {
405 swapFromBuffer( &data, sizeof( data ) );
406 return *this;
407 }
409 StreamBuffer& operator<<( unsigned char data ) {
410 swapToBuffer( &data, sizeof( data ) );
411 STREAM_ANALYSE( data, sizeof( data ) );
412 return *this;
413 }
415 StreamBuffer& operator>>( unsigned char& data ) {
416 swapFromBuffer( &data, sizeof( data ) );
417 return *this;
418 }
420 StreamBuffer& operator<<( float data ) {
421 swapToBuffer( &data, sizeof( data ) );
422 STREAM_ANALYSE( data, sizeof( data ) );
423 return *this;
424 }
426 StreamBuffer& operator>>( float& data ) {
427 swapFromBuffer( &data, sizeof( data ) );
428 return *this;
429 }
431 StreamBuffer& operator<<( double data ) {
432 swapToBuffer( &data, sizeof( data ) );
433 STREAM_ANALYSE( data, sizeof( data ) );
434 return *this;
435 }
437 StreamBuffer& operator>>( double& data ) {
438 swapFromBuffer( &data, sizeof( data ) );
439 return *this;
440 }
442 StreamBuffer& operator>>( char* data ) {
443 long i, len;
444 *this >> len;
445 for ( i = 0, data[0] = 0; i < len; i++ ) { data[i] = m_buffer[m_pointer++]; }
446 return *this;
447 }
449 StreamBuffer& operator<<( const char* data ) {
450 const char* ptr = 0 == data ? "" : data;
451 int len = strlen( ptr ) + 1;
452 if ( 0 == m_analyzer )
453 writeBytes( ptr, len );
454 else {
455 STREAM_ANALYSE( data, len );
456 }
457 return *this;
458 }
460 StreamBuffer& operator>>( std::string& data ) {
461 long i, len;
462 *this >> len;
463 for ( i = 0, data = ""; i < len; i++ ) { data.append( 1, m_buffer[m_pointer++] ); }
464 return *this;
465 }
467 StreamBuffer& operator<<( const std::string& data ) {
468 if ( 0 == m_analyzer ) {
469 const char* ptr = data.c_str();
470 long len = data.length();
471 writeBytes( ptr, len );
472 } else {
473 STREAM_ANALYSE( data, sizeof( data ) );
474 }
475 return *this;
476 }
483 template <class TYPE>
484 StreamBuffer& operator>>( TYPE*& refpObject ) {
485 return getObjectPointer( refpObject, refpObject );
486 }
487
494 StreamBuffer& operator<<( const ContainedObject* pObject ) {
495 STREAM_ANALYSE( pObject, sizeof( pObject ) );
496 addContainedLink( pObject, INVALID, INVALID );
497 return *this;
498 }
499
506 StreamBuffer& operator<<( const DataObject* pObject ) {
507 STREAM_ANALYSE( pObject, sizeof( pObject ) );
508 addIdentifiedLink( pObject, INVALID );
509 return *this;
510 }
511
518 void serialize( DataIO& ioObject ) {
519 ioObject.serialize( *this );
520 m_pointer = 0;
521 }
522 };
523
524 #undef STREAM_ANALYSE
525
527 inline StreamBuffer::SwapAction StreamBuffer::swapBuffer( int siz ) const {
528 switch ( siz ) {
529 case 1:
530 return SINGLE_BYTE;
531 default:
532 #if defined( __alpha ) && !defined( __VMS )
533 // return m_swapEnabled ? SWAP : NOSWAP;
534 return NOSWAP;
535 #elif defined( __sun ) && defined( __SVR4 ) && defined( __i386 )
536 // return m_swapEnabled ? SWAP : NOSWAP;
537 return NOSWAP;
538 #elif defined( __APPLE__ )
539 // return m_swapEnabled ? SWAP : NOSWAP;
540 return SWAP;
541 #elif defined( __linux ) && !defined( __powerpc )
542 // return m_swapEnabled ? SWAP : NOSWAP;
543 return NOSWAP;
544 #elif defined( BORLAND ) || defined( _WIN32 ) || defined( WIN32 )
545 // return m_swapEnabled ? SWAP : NOSWAP;
546 return NOSWAP;
547 #else
548 return m_swapEnabled ? SWAP : NOSWAP;
549 // return NOSWAP;
550 #endif
551 }
552 }
553
555 inline void StreamBuffer::swapToBuffer( const void* source, int siz ) {
556 char buff[8], *tar, *src = (char*)source;
557 extend( m_pointer + siz );
558 tar = m_buffer + m_pointer;
559 switch ( swapBuffer( siz ) ) {
560 case SINGLE_BYTE:
561 *tar = *src;
562 break;
563 case SWAP:
564 #ifdef __APPLE__
565 for ( int i = 0, j = siz - 1; i < siz; i++, j-- ) tar[j] = src[i];
566 #else
567 ::_swab( src, buff, siz );
568 #endif
569 src = buff;
570 [[fallthrough]];
571 case NOSWAP:
572 std::copy_n( src, siz, tar );
573 break;
574 default:
575 break;
576 }
577 m_pointer += siz;
578 }
579
581 inline void StreamBuffer::swapFromBuffer( void* target, int siz ) {
582 char* tar = (char*)target;
583 char* src = m_buffer + m_pointer;
584 switch ( swapBuffer( siz ) ) {
585 case SINGLE_BYTE:
586 *tar = *src;
587 break;
588 case SWAP:
589 #ifdef __APPLE__
590 for ( int i = 0, j = siz - 1; i < siz; i++, j-- ) tar[j] = src[i];
591 #else
592 ::_swab( src, tar, siz );
593 #endif
594 break;
595 case NOSWAP:
596 std::copy_n( src, siz, tar );
597 break;
598 default:
599 break;
600 }
601 m_pointer += siz;
602 }
603
604 // Output serialize a vector of items
605 template <class T>
606 inline StreamBuffer& operator<<( StreamBuffer& s, const std::vector<T>& v ) {
607 s << v.size();
608 for ( const auto& i : v ) s << i;
609 return s;
610 }
611
612 // Input serialize a vector of items
613 template <class T>
614 inline StreamBuffer& operator>>( StreamBuffer& s, std::vector<T>& v ) {
615 long i, len;
616 s >> len;
617 v.clear();
618 for ( i = 0; i < len; i++ ) {
619 T temp;
620 s >> temp;
621 v.push_back( temp );
622 }
623 return s;
624 }
625
626 // Output serialize a list of items
627 template <class T>
628 inline StreamBuffer& operator<<( StreamBuffer& s, const std::list<T>& l ) {
629 s << l.size();
630 for ( const auto& i : l ) s << i;
631 return s;
632 }
633
634 // Input serialize a list of items
635 template <class T>
636 inline StreamBuffer& operator>>( StreamBuffer& s, std::list<T>& l ) {
637 long len;
638 s >> len;
639 l.clear();
640 for ( long i = 0; i < len; i++ ) {
641 T temp;
642 s >> temp;
643 l.push_back( temp );
644 }
645 return s;
646 }
647 #endif // GAUDIKERNEL_STREAMBUFFER_H
StreamBuffer::DataIO::load
virtual void load(StreamBuffer &)
Template function to load stream data.
Definition: StreamBuffer.h:63
StreamBuffer::operator>>
StreamBuffer & operator>>(long long &data)
Input Streamer.
Definition: StreamBuffer.h:327
StreamBuffer::isWriting
bool isWriting() const
Get stream buffer state.
Definition: StreamBuffer.h:253
StreamBuffer::identifiedLinks
const IdentifiedLinks & identifiedLinks() const
CONST Access to identified links.
Definition: StreamBuffer.h:239
StreamBuffer::ContainedLink
Definition of the contained link set.
Definition: StreamBuffer.h:113
StreamBuffer::Ostream
Writer for standard output streams.
Definition: StreamBuffer.h:88
StreamBuffer::StreamBuffer
StreamBuffer(bool do_swap=true)
Standard constructor.
Definition: StreamBuffer.h:193
StreamBuffer::Ostream::m_stream
std::ostream * m_stream
Definition: StreamBuffer.h:89
StreamBuffer::Mode
Mode
Streamer mode.
Definition: StreamBuffer.h:107
StreamBuffer::DataIO::serialize
virtual void serialize(StreamBuffer &stream)
Serialization method: loads/dumps streambuffer content.
Definition: StreamBuffer.h:54
StreamBuffer::operator<<
StreamBuffer & operator<<(const char *data)
Streamer to write strings in (char*) format.
Definition: StreamBuffer.h:449
Kernel.h
operator<<
StreamBuffer & operator<<(StreamBuffer &s, const std::vector< T > &v)
Definition: StreamBuffer.h:606
StreamBuffer::operator>>
StreamBuffer & operator>>(long &data)
Input Streamer.
Definition: StreamBuffer.h:360
StreamBuffer::operator>>
StreamBuffer & operator>>(unsigned short &data)
Input Streamer.
Definition: StreamBuffer.h:393
StreamBuffer::Ostream::Ostream
Ostream(std::ostream &str)
Standard constructor: pass reference to stream object.
Definition: StreamBuffer.h:93
StreamBuffer::operator<<
StreamBuffer & operator<<(double data)
Output Streamer.
Definition: StreamBuffer.h:431
StreamBuffer::Istream::m_stream
std::istream * m_stream
Reference to input stream.
Definition: StreamBuffer.h:71
StreamBuffer::DataIO::DataIO
DataIO()=default
Standard constructor.
StreamBuffer::SWAP
Definition: StreamBuffer.h:109
StreamBuffer::operator<<
StreamBuffer & operator<<(float data)
Output Streamer.
Definition: StreamBuffer.h:420
StreamBuffer::operator<<
StreamBuffer & operator<<(const DataObject *pObject)
Streamer to write links to identified objects.
Definition: StreamBuffer.h:506
StreamBuffer
The stream buffer is a small object collecting object data.
Definition: StreamBuffer.h:41
StreamBuffer::operator>>
StreamBuffer & operator>>(float &data)
Input Streamer.
Definition: StreamBuffer.h:426
StreamBuffer::SwapAction
SwapAction
Data Sawp actions.
Definition: StreamBuffer.h:109
StreamBuffer::m_containedLinks
ContainedLinks m_containedLinks
Container with links to contained objects.
Definition: StreamBuffer.h:157
StreamBuffer::ContainedLink::ContainedLink
ContainedLink()
Definition: StreamBuffer.h:118
StreamBuffer::ContainedLink::ContainedLink
ContainedLink(const ContainedLink &copy)
Definition: StreamBuffer.h:119
StreamBuffer::Istream::Istream
Istream(std::istream &str)
Constructor.
Definition: StreamBuffer.h:75
StreamBuffer::m_analyzer
AnalyzeFunction m_analyzer
Hook function for analysis of data to the stream.
Definition: StreamBuffer.h:163
StreamBuffer::DataIO::dump
virtual void dump(StreamBuffer &)
Template function to save stream data.
Definition: StreamBuffer.h:65
StreamBuffer::m_length
long m_length
Total buffer length.
Definition: StreamBuffer.h:148
StreamBuffer::swapBuffer
SwapAction swapBuffer(int siz) const
Check for byte swapping.
Definition: StreamBuffer.h:527
StreamBuffer::identifiedLinks
IdentifiedLinks & identifiedLinks()
Access to identified links.
Definition: StreamBuffer.h:237
StreamBuffer::Ostream::~Ostream
virtual ~Ostream()=default
Standard Destructor.
StreamBuffer::m_buffer
char * m_buffer
Pointer to heap buffer.
Definition: StreamBuffer.h:151
StreamBuffer::extend
void extend(long len)
Extend the buffer.
Definition: StreamBuffer.h:220
StreamBuffer::operator<<
StreamBuffer & operator<<(const ContainedObject *pObject)
Streamer to write links to contained objects.
Definition: StreamBuffer.h:494
StreamBuffer::operator>>
StreamBuffer & operator>>(char *data)
Streamer to read strings in (char*) format.
Definition: StreamBuffer.h:442
StreamBuffer::swapToBuffer
void swapToBuffer(const void *source, int siz)
Swap buffers: int, long, short, float and double.
Definition: StreamBuffer.h:555
std::vector::end
T end(T... args)
StreamBuffer::ContainedLinks
std::vector< ContainedLink > ContainedLinks
Definition: StreamBuffer.h:132
StreamBuffer::operator<<
StreamBuffer & operator<<(unsigned long data)
Output Streamer.
Definition: StreamBuffer.h:365
std::copy_n
T copy_n(T... args)
StreamBuffer::READING
Definition: StreamBuffer.h:107
StreamBuffer::operator<<
StreamBuffer & operator<<(unsigned short data)
Output Streamer.
Definition: StreamBuffer.h:387
StreamBuffer::Istream
Reader for standard input streams.
Definition: StreamBuffer.h:69
StreamBuffer::ContainedLink::first
ContainedObject * first
Definition: StreamBuffer.h:115
StreamBuffer::IdentifiedLink::second
long second
Definition: StreamBuffer.h:126
std::istream
STL class.
StreamBuffer::ContainedLink::third
long third
Definition: StreamBuffer.h:117
StreamBuffer::setAnalyzer
void setAnalyzer(AnalyzeFunction fun=nullptr)
Enable user analysis function.
Definition: StreamBuffer.h:259
StreamBuffer::data
char * data()
write access to data buffer
Definition: StreamBuffer.h:199
StreamBuffer::setBuffPointer
void setBuffPointer(long ptr)
Retrieve current buffer pointer.
Definition: StreamBuffer.h:257
std::type_info
StreamBuffer::operator>>
StreamBuffer & operator>>(unsigned char &data)
Input Streamer.
Definition: StreamBuffer.h:415
std::string
STL class.
StreamBuffer::operator<<
StreamBuffer & operator<<(int data)
Output Streamer.
Definition: StreamBuffer.h:332
StreamBuffer::AnalyzeFunction
void(* AnalyzeFunction)(const void *data, int siz, const std::type_info &type)
Definition of the buffer analyzer.
Definition: StreamBuffer.h:136
std::vector::push_back
T push_back(T... args)
StreamBuffer::reserve
void reserve(long len)
Reserve buffer space; Default: 16 k buffer size.
Definition: StreamBuffer.h:213
operator>>
StreamBuffer & operator>>(StreamBuffer &s, std::vector< T > &v)
Definition: StreamBuffer.h:614
StreamBuffer::m_mode
Mode m_mode
Boolean indicating wether the stream is in read or write mode.
Definition: StreamBuffer.h:142
STREAM_ANALYSE
#define STREAM_ANALYSE(data, len)
Definition: StreamBuffer.h:300
StreamBuffer::containedLinks
ContainedLinks & containedLinks()
Access to contained links.
Definition: StreamBuffer.h:232
StreamBuffer::operator<<
StreamBuffer & operator<<(long data)
Output Streamer.
Definition: StreamBuffer.h:354
Gaudi::Units::m
constexpr double m
Definition: SystemOfUnits.h:92
gaudirun.type
type
Definition: gaudirun.py:142
StreamBuffer::operator<<
StreamBuffer & operator<<(unsigned char data)
Output Streamer.
Definition: StreamBuffer.h:409
StreamBuffer::size
long size() const
Total buffer size.
Definition: StreamBuffer.h:230
std::vector::erase
T erase(T... args)
StreamBuffer::SINGLE_BYTE
Definition: StreamBuffer.h:109
std::vector::pop_back
T pop_back(T... args)
StreamBuffer::operator<<
StreamBuffer & operator<<(short data)
Output Streamer.
Definition: StreamBuffer.h:376
StreamBuffer::getObjectPointer
StreamBuffer & getObjectPointer(const ContainedObject *, TYPE *&refpObject)
Helper to distinguish between identified pointers and contained pointers.
Definition: StreamBuffer.h:183
StreamBuffer::ContainedLink::ContainedLink
ContainedLink(ContainedObject *pObj, long hint, long link)
Definition: StreamBuffer.h:120
StreamBuffer::operator<<
StreamBuffer & operator<<(const std::string &data)
Streamer to write strings in (std::string) format.
Definition: StreamBuffer.h:467
StreamBuffer::DataIO::badStreamMode
void badStreamMode()
Throw Exception.
Definition: StreamBuffer.h:52
std::vector::clear
T clear(T... args)
StreamBuffer::Istream::load
void load(StreamBuffer &stream) override
Data load method.
Definition: StreamBuffer.h:78
std::list
STL class.
StreamBuffer::operator>>
StreamBuffer & operator>>(char &data)
Input Streamer.
Definition: StreamBuffer.h:404
StreamBuffer::IdentifiedLink::first
DataObject * first
Definition: StreamBuffer.h:125
StreamBuffer::operator>>
StreamBuffer & operator>>(unsigned long &data)
Input Streamer.
Definition: StreamBuffer.h:371
_swab
#define _swab(source, target, radix)
Definition: swab.h:7
StreamBuffer::UNINITIALIZED
Definition: StreamBuffer.h:107
StreamBuffer::addIdentifiedLink
void addIdentifiedLink(const DataObject *pObject, long hint)
Definition: StreamBuffer.h:281
gaudirun.l
dictionary l
Definition: gaudirun.py:521
StreamBuffer::data
const char * data() const
Read access to data buffer.
Definition: StreamBuffer.h:197
StreamBuffer::isReading
bool isReading() const
Get stream buffer state.
Definition: StreamBuffer.h:250
ContainedObject
All classes that their objects may be contained in an LHCb ObjectContainer (e.g.
Definition: ContainedObject.h:31
StreamBuffer::DataIO::~DataIO
virtual ~DataIO()=default
Standard destructor.
std::vector::size
T size(T... args)
StreamBuffer::Ostream::dump
void dump(StreamBuffer &stream) override
Output dumper.
Definition: StreamBuffer.h:98
std::vector< ContainedLink >
StreamBuffer::m_pointer
long m_pointer
Current buffer pointer.
Definition: StreamBuffer.h:145
std::vector::begin
T begin(T... args)
std::ostream::write
T write(T... args)
StreamBuffer::containedLinks
const ContainedLinks & containedLinks() const
CONST Access to contained links.
Definition: StreamBuffer.h:234
StreamBuffer::DataIO
A small base class to handle generic data streaming.
Definition: StreamBuffer.h:45
std::vector::back
T back(T... args)
gaudirun.s
string s
Definition: gaudirun.py:316
StreamBuffer::State
State
Link state defintions.
Definition: StreamBuffer.h:111
std::istream::read
T read(T... args)
StreamBuffer::WRITING
Definition: StreamBuffer.h:107
StreamBuffer::writeBytes
StreamBuffer & writeBytes(const char *str, long len)
Write string to output stream.
Definition: StreamBuffer.h:267
StreamBuffer::~StreamBuffer
virtual ~StreamBuffer()
Standard destructor.
Definition: StreamBuffer.h:195
StreamBuffer::buffPointer
long buffPointer() const
Retrieve current buffer pointer.
Definition: StreamBuffer.h:255
StreamBuffer::erase
void erase()
Reset the buffer.
Definition: StreamBuffer.h:201
StreamBuffer::operator<<
StreamBuffer & operator<<(unsigned int data)
Output Streamer.
Definition: StreamBuffer.h:343
StreamBuffer::VALID
Definition: StreamBuffer.h:111
StreamBuffer::operator>>
StreamBuffer & operator>>(std::string &data)
Streamer to read strings in (std::string) format.
Definition: StreamBuffer.h:460
StreamBuffer::INVALID
Definition: StreamBuffer.h:111
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:203
StreamBuffer::IdentifiedLink
Definition of the contained link set.
Definition: StreamBuffer.h:123
StreamBuffer::operator<<
StreamBuffer & operator<<(char data)
Output Streamer.
Definition: StreamBuffer.h:398
StreamBuffer::setMode
void setMode(Mode m)
Set mode of the stream and allocate buffer.
Definition: StreamBuffer.h:242
StreamBuffer::NOSWAP
Definition: StreamBuffer.h:109
StreamBuffer::getObjectPointer
StreamBuffer & getObjectPointer(const DataObject *, TYPE *&refpObject)
Helper to distinguish between identified pointers and contained pointers.
Definition: StreamBuffer.h:172
StreamBuffer::ContainedLink::second
long second
Definition: StreamBuffer.h:116
StreamBuffer::operator>>
StreamBuffer & operator>>(unsigned int &data)
Input Streamer.
Definition: StreamBuffer.h:349
StreamBuffer::m_identifiedLinks
IdentifiedLinks m_identifiedLinks
Container with links to contained objects.
Definition: StreamBuffer.h:160
DataObject
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:30
std::ostream
STL class.
StreamBuffer::operator>>
StreamBuffer & operator>>(double &data)
Input Streamer.
Definition: StreamBuffer.h:437
StreamBuffer::addContainedLink
void addContainedLink(const ContainedObject *pObject, long hint, long link)
Definition: StreamBuffer.h:292
StreamBuffer::getContainedLink
void getContainedLink(ContainedObject *&pObject, long &hint, long &link)
Definition: StreamBuffer.h:285
swab.h
StreamBuffer::operator>>
StreamBuffer & operator>>(int &data)
Input Streamer.
Definition: StreamBuffer.h:338
StreamBuffer::IdentifiedLinks
std::vector< IdentifiedLink > IdentifiedLinks
Definition of the identifiable link set.
Definition: StreamBuffer.h:134
StreamBuffer::serialize
void serialize(DataIO &ioObject)
Serialize the buffer using an IO object.
Definition: StreamBuffer.h:518
StreamBuffer::m_swapEnabled
bool m_swapEnabled
Flag indicating swapping.
Definition: StreamBuffer.h:154
StreamBuffer::IdentifiedLink::IdentifiedLink
IdentifiedLink()=default
StreamBuffer::operator>>
StreamBuffer & operator>>(short &data)
Input Streamer.
Definition: StreamBuffer.h:382
StreamBuffer::getIdentifiedLink
void getIdentifiedLink(DataObject *&pObject, long &hint)
Definition: StreamBuffer.h:275
StreamBuffer::operator<<
StreamBuffer & operator<<(long long data)
Output Streamer.
Definition: StreamBuffer.h:321
StreamBuffer::operator>>
StreamBuffer & operator>>(TYPE *&refpObject)
Streamer to read links to contained or identified objects.
Definition: StreamBuffer.h:484
StreamBuffer::IdentifiedLink::IdentifiedLink
IdentifiedLink(DataObject *pObj, long hint)
Definition: StreamBuffer.h:129
StreamBuffer::swapFromBuffer
void swapFromBuffer(void *target, int siz)
Swap buffers: int, long, short, float and double.
Definition: StreamBuffer.h:581