| The Gaudi Framework v29r1 (5cd95fa2)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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 {
74 std::istream* m_stream;
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 {
96 std::ostream* m_stream;
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:
115 enum Mode { UNINITIALIZED, READING, WRITING };
117 enum SwapAction { SINGLE_BYTE, SWAP, NOSWAP };
119 enum State { INVALID = -1, VALID };
121 class ContainedLink
122 {
123 public:
124 ContainedObject* first;
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 };
132 class IdentifiedLink
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
142 typedef std::vector<ContainedLink> ContainedLinks;
144 typedef std::vector<IdentifiedLink> IdentifiedLinks;
146 typedef void ( *AnalyzeFunction )( const void* data, int siz, const std::type_info& type );
148 friend class DataObject;
149
150 protected:
152 Mode m_mode = UNINITIALIZED;
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
173 AnalyzeFunction m_analyzer = nullptr;
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
344 StreamBuffer& operator<<( longlong data )
345 {
346 swapToBuffer( &data, sizeof( data ) );
347 STREAM_ANALYSE( data, sizeof( data ) );
348 return *this;
349 }
351 StreamBuffer& operator>>( longlong& data )
352 {
353 swapFromBuffer( &data, sizeof( data ) );
354 return *this;
355 }
357 StreamBuffer& operator<<( int data )
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 }
509 StreamBuffer& operator>>( std::string& data )
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 }
519 StreamBuffer& operator<<( const std::string& data )
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
548 StreamBuffer& operator<<( const ContainedObject* pObject )
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
584 inline StreamBuffer::SwapAction StreamBuffer::swapBuffer( int siz ) const
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>
671 inline StreamBuffer& operator>>( StreamBuffer& s, std::vector<T>& v )
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>
695 inline StreamBuffer& operator>>( StreamBuffer& s, std::list<T>& l )
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
StreamBuffer::DataIO::load
virtual void load(StreamBuffer &)
Template function to load stream data.
Definition: StreamBuffer.h:65
StreamBuffer::ContainedLink
Definition of the contained link set.
Definition: StreamBuffer.h:121
StreamBuffer::Ostream
Writer for standard output streams.
Definition: StreamBuffer.h:94
StreamBuffer::StreamBuffer
StreamBuffer(bool do_swap=true)
Standard constructor.
Definition: StreamBuffer.h:205
StreamBuffer::Ostream::m_stream
std::ostream * m_stream
Definition: StreamBuffer.h:96
StreamBuffer::Mode
Mode
Streamer mode.
Definition: StreamBuffer.h:115
StreamBuffer::DataIO::serialize
virtual void serialize(StreamBuffer &stream)
Serialization method: loads/dumps streambuffer content.
Definition: StreamBuffer.h:55
StreamBuffer::operator<<
StreamBuffer & operator<<(const char *data)
Streamer to write strings in (char*) format.
Definition: StreamBuffer.h:497
Kernel.h
StreamBuffer::buffPointer
long buffPointer() const
Retrieve current buffer pointer.
Definition: StreamBuffer.h:271
StreamBuffer::operator>>
StreamBuffer & operator>>(long &data)
Input Streamer.
Definition: StreamBuffer.h:390
StreamBuffer::operator>>
StreamBuffer & operator>>(unsigned short &data)
Input Streamer.
Definition: StreamBuffer.h:429
StreamBuffer::Ostream::Ostream
Ostream(std::ostream &str)
Standard constructor: pass reference to stream object.
Definition: StreamBuffer.h:100
StreamBuffer::operator<<
StreamBuffer & operator<<(double data)
Output Streamer.
Definition: StreamBuffer.h:474
StreamBuffer::Istream::m_stream
std::istream * m_stream
Reference to input stream.
Definition: StreamBuffer.h:74
StreamBuffer::DataIO::DataIO
DataIO()=default
Standard constructor.
StreamBuffer::SWAP
Definition: StreamBuffer.h:117
StreamBuffer::operator<<
StreamBuffer & operator<<(float data)
Output Streamer.
Definition: StreamBuffer.h:461
StreamBuffer::operator<<
StreamBuffer & operator<<(const DataObject *pObject)
Streamer to write links to identified objects.
Definition: StreamBuffer.h:561
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:468
StreamBuffer::SwapAction
SwapAction
Data Sawp actions.
Definition: StreamBuffer.h:117
StreamBuffer::m_containedLinks
ContainedLinks m_containedLinks
Container with links to contained objects.
Definition: StreamBuffer.h:167
StreamBuffer::ContainedLink::ContainedLink
ContainedLink()
Definition: StreamBuffer.h:127
StreamBuffer::ContainedLink::ContainedLink
ContainedLink(const ContainedLink &copy)
Definition: StreamBuffer.h:128
StreamBuffer::Istream::Istream
Istream(std::istream &str)
Constructor.
Definition: StreamBuffer.h:78
StreamBuffer::m_analyzer
AnalyzeFunction m_analyzer
Hook function for analysis of data to the stream.
Definition: StreamBuffer.h:173
StreamBuffer::DataIO::dump
virtual void dump(StreamBuffer &)
Template function to save stream data.
Definition: StreamBuffer.h:67
StreamBuffer::m_length
long m_length
Total buffer length.
Definition: StreamBuffer.h:158
StreamBuffer::identifiedLinks
IdentifiedLinks & identifiedLinks()
Access to identified links.
Definition: StreamBuffer.h:252
StreamBuffer::m_buffer
char * m_buffer
Pointer to heap buffer.
Definition: StreamBuffer.h:161
Gaudi::Functional::void
class MergingTransformer< Out(const vector_of_const_< In > void
Definition: MergingTransformer.h:23
StreamBuffer::extend
void extend(long len)
Extend the buffer.
Definition: StreamBuffer.h:234
StreamBuffer::operator<<
StreamBuffer & operator<<(const ContainedObject *pObject)
Streamer to write links to contained objects.
Definition: StreamBuffer.h:548
StreamBuffer::operator>>
StreamBuffer & operator>>(char *data)
Streamer to read strings in (char*) format.
Definition: StreamBuffer.h:487
StreamBuffer::swapToBuffer
void swapToBuffer(const void *source, int siz)
Swap buffers: int, long, short, float and double.
Definition: StreamBuffer.h:613
std::vector::end
T end(T...args)
StreamBuffer::isReading
bool isReading() const
Get stream buffer state.
Definition: StreamBuffer.h:266
StreamBuffer::ContainedLinks
std::vector< ContainedLink > ContainedLinks
Definition: StreamBuffer.h:142
StreamBuffer::operator<<
StreamBuffer & operator<<(unsigned long data)
Output Streamer.
Definition: StreamBuffer.h:396
std::copy_n
T copy_n(T...args)
StreamBuffer::READING
Definition: StreamBuffer.h:115
StreamBuffer::operator<<
StreamBuffer & operator<<(unsigned short data)
Output Streamer.
Definition: StreamBuffer.h:422
StreamBuffer::Istream
Reader for standard input streams.
Definition: StreamBuffer.h:71
StreamBuffer::ContainedLink::first
ContainedObject * first
Definition: StreamBuffer.h:124
StreamBuffer::data
const char * data() const
Read access to data buffer.
Definition: StreamBuffer.h:209
StreamBuffer::IdentifiedLink::second
long second
Definition: StreamBuffer.h:136
std::istream
STL class.
StreamBuffer::ContainedLink::third
long third
Definition: StreamBuffer.h:126
StreamBuffer::setAnalyzer
void setAnalyzer(AnalyzeFunction fun=nullptr)
Enable user analysis function.
Definition: StreamBuffer.h:275
StreamBuffer::data
char * data()
write access to data buffer
Definition: StreamBuffer.h:211
StreamBuffer::setBuffPointer
void setBuffPointer(long ptr)
Retrieve current buffer pointer.
Definition: StreamBuffer.h:273
std::type_info
StreamBuffer::operator>>
StreamBuffer & operator>>(unsigned char &data)
Input Streamer.
Definition: StreamBuffer.h:455
Gaudi::Units::second
constexpr double second
Definition: SystemOfUnits.h:123
std::string
STL class.
StreamBuffer::operator<<
StreamBuffer & operator<<(int data)
Output Streamer.
Definition: StreamBuffer.h:357
StreamBuffer::operator>>
StreamBuffer & operator>>(longlong &data)
Input Streamer.
Definition: StreamBuffer.h:351
StreamBuffer::AnalyzeFunction
void(* AnalyzeFunction)(const void *data, int siz, const std::type_info &type)
Definition of the buffer analyzer.
Definition: StreamBuffer.h:146
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:226
StreamBuffer::m_mode
Mode m_mode
Boolean indicating wether the stream is in read or write mode.
Definition: StreamBuffer.h:152
STREAM_ANALYSE
#define STREAM_ANALYSE(data, len)
Definition: StreamBuffer.h:321
StreamBuffer::identifiedLinks
const IdentifiedLinks & identifiedLinks() const
CONST Access to identified links.
Definition: StreamBuffer.h:254
StreamBuffer::containedLinks
ContainedLinks & containedLinks()
Access to contained links.
Definition: StreamBuffer.h:247
__longlong
Definition: Kernel.h:56
StreamBuffer::operator<<
StreamBuffer & operator<<(long data)
Output Streamer.
Definition: StreamBuffer.h:383
Gaudi::Units::m
constexpr double m
Definition: SystemOfUnits.h:94
std::string::append
T append(T...args)
gaudirun.type
type
Definition: gaudirun.py:133
StreamBuffer::operator<<
StreamBuffer & operator<<(unsigned char data)
Output Streamer.
Definition: StreamBuffer.h:448
std::vector::erase
T erase(T...args)
StreamBuffer::SINGLE_BYTE
Definition: StreamBuffer.h:117
std::vector::pop_back
T pop_back(T...args)
StreamBuffer::operator<<
StreamBuffer & operator<<(longlong data)
Output Streamer.
Definition: StreamBuffer.h:344
StreamBuffer::operator<<
StreamBuffer & operator<<(short data)
Output Streamer.
Definition: StreamBuffer.h:409
StreamBuffer::getObjectPointer
StreamBuffer & getObjectPointer(const ContainedObject *, TYPE *&refpObject)
Helper to distinguish between identified pointers and contained pointers.
Definition: StreamBuffer.h:194
StreamBuffer::ContainedLink::ContainedLink
ContainedLink(ContainedObject *pObj, long hint, long link)
Definition: StreamBuffer.h:129
StreamBuffer::operator<<
StreamBuffer & operator<<(const std::string &data)
Streamer to write strings in (std::string) format.
Definition: StreamBuffer.h:519
StreamBuffer::DataIO::badStreamMode
void badStreamMode()
Throw Exception.
Definition: StreamBuffer.h:53
std::vector::clear
T clear(T...args)
StreamBuffer::Istream::load
void load(StreamBuffer &stream) override
Data load method.
Definition: StreamBuffer.h:83
std::list
STL class.
StreamBuffer::operator>>
StreamBuffer & operator>>(char &data)
Input Streamer.
Definition: StreamBuffer.h:442
StreamBuffer::IdentifiedLink::first
DataObject * first
Definition: StreamBuffer.h:135
StreamBuffer::operator>>
StreamBuffer & operator>>(unsigned long &data)
Input Streamer.
Definition: StreamBuffer.h:403
_swab
#define _swab(source, target, radix)
Definition: swab.h:7
StreamBuffer::UNINITIALIZED
Definition: StreamBuffer.h:115
StreamBuffer::addIdentifiedLink
void addIdentifiedLink(const DataObject *pObject, long hint)
Definition: StreamBuffer.h:299
gaudirun.l
dictionary l
Definition: gaudirun.py:440
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::string::length
T length(T...args)
StreamBuffer::Ostream::dump
void dump(StreamBuffer &stream) override
Output dumper.
Definition: StreamBuffer.h:105
std::vector< ContainedLink >
StreamBuffer::isWriting
bool isWriting() const
Get stream buffer state.
Definition: StreamBuffer.h:269
StreamBuffer::m_pointer
long m_pointer
Current buffer pointer.
Definition: StreamBuffer.h:155
std::vector::begin
T begin(T...args)
std::ostream::write
T write(T...args)
StreamBuffer::DataIO
A small base class to handle generic data streaming.
Definition: StreamBuffer.h:45
std::string::c_str
T c_str(T...args)
fun
double fun(const std::vector< double > &x)
Definition: PFuncTest.cpp:26
std::vector::back
T back(T...args)
gaudirun.s
string s
Definition: gaudirun.py:253
StreamBuffer::State
State
Link state defintions.
Definition: StreamBuffer.h:119
std::istream::read
T read(T...args)
StreamBuffer::WRITING
Definition: StreamBuffer.h:115
StreamBuffer::writeBytes
StreamBuffer & writeBytes(const char *str, long len)
Write string to output stream.
Definition: StreamBuffer.h:283
StreamBuffer::~StreamBuffer
virtual ~StreamBuffer()
Standard destructor.
Definition: StreamBuffer.h:207
StreamBuffer::erase
void erase()
Reset the buffer.
Definition: StreamBuffer.h:213
StreamBuffer::operator<<
StreamBuffer & operator<<(unsigned int data)
Output Streamer.
Definition: StreamBuffer.h:370
StreamBuffer::VALID
Definition: StreamBuffer.h:119
StreamBuffer::operator>>
StreamBuffer & operator>>(std::string &data)
Streamer to read strings in (std::string) format.
Definition: StreamBuffer.h:509
StreamBuffer::INVALID
Definition: StreamBuffer.h:119
StreamBuffer::IdentifiedLink
Definition of the contained link set.
Definition: StreamBuffer.h:132
StreamBuffer::operator<<
StreamBuffer & operator<<(char data)
Output Streamer.
Definition: StreamBuffer.h:435
StreamBuffer::setMode
void setMode(Mode m)
Set mode of the stream and allocate buffer.
Definition: StreamBuffer.h:257
StreamBuffer::NOSWAP
Definition: StreamBuffer.h:117
StreamBuffer::adopt
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
StreamBuffer & getObjectPointer(const DataObject *, TYPE *&refpObject)
Helper to distinguish between identified pointers and contained pointers.
Definition: StreamBuffer.h:182
StreamBuffer::ContainedLink::second
long second
Definition: StreamBuffer.h:125
StreamBuffer::operator>>
StreamBuffer & operator>>(unsigned int &data)
Input Streamer.
Definition: StreamBuffer.h:377
StreamBuffer::m_identifiedLinks
IdentifiedLinks m_identifiedLinks
Container with links to contained objects.
Definition: StreamBuffer.h:170
DataObject
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:29
std::ostream
STL class.
StreamBuffer::swapBuffer
SwapAction swapBuffer(int siz) const
Check for byte swapping.
Definition: StreamBuffer.h:584
StreamBuffer::operator>>
StreamBuffer & operator>>(double &data)
Input Streamer.
Definition: StreamBuffer.h:481
StreamBuffer::addContainedLink
void addContainedLink(const ContainedObject *pObject, long hint, long link)
Definition: StreamBuffer.h:312
StreamBuffer::getContainedLink
void getContainedLink(ContainedObject *&pObject, long &hint, long &link)
Definition: StreamBuffer.h:304
StreamBuffer::size
long size() const
Total buffer size.
Definition: StreamBuffer.h:245
swab.h
StreamBuffer::operator>>
StreamBuffer & operator>>(int &data)
Input Streamer.
Definition: StreamBuffer.h:364
StreamBuffer::IdentifiedLinks
std::vector< IdentifiedLink > IdentifiedLinks
Definition of the identifiable link set.
Definition: StreamBuffer.h:144
StreamBuffer::serialize
void serialize(DataIO &ioObject)
Serialize the buffer using an IO object.
Definition: StreamBuffer.h:574
StreamBuffer::containedLinks
const ContainedLinks & containedLinks() const
CONST Access to contained links.
Definition: StreamBuffer.h:249
StreamBuffer::m_swapEnabled
bool m_swapEnabled
Flag indicating swapping.
Definition: StreamBuffer.h:164
StreamBuffer::operator>>
StreamBuffer & operator>>(short &data)
Input Streamer.
Definition: StreamBuffer.h:416
StreamBuffer::getIdentifiedLink
void getIdentifiedLink(DataObject *&pObject, long &hint)
Definition: StreamBuffer.h:292
StreamBuffer::operator>>
StreamBuffer & operator>>(TYPE *&refpObject)
Streamer to read links to contained or identified objects.
Definition: StreamBuffer.h:537
StreamBuffer::IdentifiedLink::IdentifiedLink
IdentifiedLink(DataObject *pObj, long hint)
Definition: StreamBuffer.h:139
StreamBuffer::swapFromBuffer
void swapFromBuffer(void *target, int siz)
Swap buffers: int, long, short, float and double.
Definition: StreamBuffer.h:638