Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  v28r2p1 (f1a77ff4)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 <list>
6 #include <vector>
7 #include <algorithm>
8 #include <string>
9 #include <iostream>
10 #include <cstring>
11 #include <cstdlib>
12 #include <typeinfo>
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 public:
44  class DataIO {
45  public:
47  DataIO() = default;
49  virtual ~DataIO() = default;
51  void badStreamMode() {
52  throw("Not acceptable stream mode!");
53  }
55  virtual void serialize(StreamBuffer& stream) {
56  if (stream.isReading())
57  load(stream);
58  else if (stream.isWriting())
59  dump(stream);
60  else
61  badStreamMode();
62  }
64  virtual void load(StreamBuffer&) {
65  badStreamMode();
66  }
68  virtual void dump(StreamBuffer&) {
69  badStreamMode();
70  }
71  };
72 
74  class Istream : public DataIO {
77  public:
79  Istream(std::istream& str) : m_stream(&str) {
80  }
82  ~Istream() override = default;
83 
85  void load(StreamBuffer& stream) override {
86  // Generic implementation for istreams:
87  int len;
88  (*m_stream) >> len;
89  stream.erase();
90  stream.reserve(len);
91  m_stream->read(stream.data(),len);
92  }
93  };
95  class Ostream : public DataIO {
97  public:
99  Ostream(std::ostream& str) : m_stream(&str) {
100  }
102  virtual ~Ostream() = default;
103 
105  void dump(StreamBuffer& stream) override {
106  // Generic implementation for ostreams:
107  (*m_stream) << stream.buffPointer();
108  m_stream->write(stream.data(), stream.buffPointer());
109  }
110  };
111 public:
117  enum State {INVALID=-1, VALID };
120  public:
122  long second;
123  long third;
124  ContainedLink() : first(0), second(INVALID), third(INVALID) {
125  }
127  : first(copy.first), second(copy.second), third(copy.third) {
128  }
129  ContainedLink(ContainedObject* pObj, long hint, long link)
130  : first(pObj), second(hint), third(link) {
131  }
132  };
135  public:
136  DataObject* first = nullptr;
137  long second = INVALID;
138  IdentifiedLink() = default;
139  IdentifiedLink(const IdentifiedLink& copy) = default;
140  IdentifiedLink(DataObject* pObj, long hint)
141  : first(pObj), second(hint) {
142  }
143  };
144 
149  typedef void (*AnalyzeFunction)(const void* data, int siz, const std::type_info& type);
151  friend class DataObject;
152 
153 protected:
156 
158  mutable long m_pointer = 0;
159 
161  mutable long m_length = 0;
162 
164  mutable char* m_buffer = nullptr;
165 
167  bool m_swapEnabled = true;
168 
170  mutable ContainedLinks m_containedLinks;
171 
173  mutable IdentifiedLinks m_identifiedLinks;
174 
177 
179  SwapAction swapBuffer(int siz) const;
180 
184  template <class TYPE> StreamBuffer& getObjectPointer(const DataObject* /*pObject*/, TYPE*& refpObject) {
185  IdentifiedLink& link = m_identifiedLinks.back();
186  DataObject* pObj = link.first;
187  m_identifiedLinks.pop_back();
188  refpObject = dynamic_cast<TYPE*>(pObj);
189  return *this;
190  }
194  template <class TYPE> StreamBuffer& getObjectPointer(const ContainedObject* /*pObject*/, TYPE*& refpObject) {
195  ContainedLink& link = m_containedLinks.back();
196  ContainedObject* pObj = link.first;
197  m_containedLinks.pop_back();
198  refpObject = dynamic_cast<TYPE*>(pObj);
199  return *this;
200  }
201 public:
203  StreamBuffer(bool do_swap=true) :
204  m_swapEnabled(do_swap) {
205  }
207  virtual ~StreamBuffer() {
208  ::free( m_buffer );
209  }
211  const char* data() const {
212  return m_buffer;
213  }
215  char* data() {
216  return m_buffer;
217  }
219  void erase() {
220  m_pointer = 0;
221  }
223  char* adopt() const {
224  char* ptr = m_buffer;
225  m_containedLinks.erase (m_containedLinks.begin(), m_containedLinks.end());
226  m_identifiedLinks.erase(m_identifiedLinks.begin(),m_identifiedLinks.end());
227  m_buffer = NULL; //char *
228  m_pointer = 0; // long
229  m_length = 0; // long
230  return ptr;
231  }
233  void reserve(long len) {
234  if ( len > m_length ) {
235  m_length = (len < 16384) ? 16384 : len;
236  m_buffer = (char*)::realloc (m_buffer,m_length);
237  }
238  }
240  void extend(long len) {
241  if ( len + m_pointer > m_length ) {
242  // We have to be a bit generous here in order not to run too often
243  // into ::realloc().
244  long new_len = (m_length < 16384) ? 16384 : 2*m_length;
245  if ( m_length < len ) new_len += len;
246  reserve(new_len);
247  }
248  }
250  long size () const {
251  return m_length;
252  }
254  ContainedLinks& containedLinks() {
255  return m_containedLinks;
256  }
258  const ContainedLinks& containedLinks() const {
259  return m_containedLinks;
260  }
261 
263  IdentifiedLinks& identifiedLinks() {
264  return m_identifiedLinks;
265  }
267  const IdentifiedLinks& identifiedLinks() const {
268  return m_identifiedLinks;
269  }
270 
272  void setMode(Mode m) {
273  m_mode = m;
274  m_pointer = 0;
275  m_containedLinks.erase (m_containedLinks.begin(), m_containedLinks.end());
276  m_identifiedLinks.erase(m_identifiedLinks.begin(),m_identifiedLinks.end());
277  }
278 
280  bool isReading() const {
281  return m_mode == READING;
282  }
283 
285  bool isWriting() const {
286  return m_mode == WRITING;
287  }
289  long buffPointer() const {
290  return m_pointer;
291  }
293  void setBuffPointer(long ptr) {
294  m_pointer = ptr;
295  }
298  m_analyzer = fun;
299  }
301  void swapToBuffer(const void* source, int siz);
302 
304  void swapFromBuffer(void* target, int siz);
305 
307  StreamBuffer& writeBytes (const char* str, long len) {
308  extend( m_pointer+len+4 );
309  *this << len;
310  std::copy_n(str,len, data()+buffPointer());
311  m_pointer += len;
312  return *this;
313  }
314 
315  void getIdentifiedLink (DataObject*& pObject, long& hint) {
316  IdentifiedLink& l = m_identifiedLinks.back();
317  pObject = l.first;
318  hint = l.second;
319  m_identifiedLinks.pop_back();
320  }
321  void addIdentifiedLink (const DataObject* pObject, long hint) {
322  m_identifiedLinks.push_back( IdentifiedLink((DataObject*)pObject, hint) );
323  }
324 
325  void getContainedLink (ContainedObject*& pObject, long& hint, long& link) {
326  ContainedLink& l = m_containedLinks.back();
327  pObject = l.first;
328  hint = l.second;
329  link = l.third;
330  m_containedLinks.pop_back();
331  }
332  void addContainedLink (const ContainedObject* pObject, long hint, long link) {
333  m_containedLinks.push_back( ContainedLink((ContainedObject*)pObject, hint, link) );
334  }
335 
336 #ifdef USE_STREAM_ANALYSER
337  #define STREAM_ANALYSE(data, len) if ( 0 != m_analyzer ) m_analyzer(&data, len, typeid(data))
338 #else
339  #define STREAM_ANALYSE(data, len)
340 #endif
341 
342  // Implement streamer macros for primivive data types.
343 #define IMPLEMENT_STREAMER(TYPE) \
344  /* Output Streamer */ \
345  StreamBuffer& operator<<(TYPE data) { \
346  swapToBuffer(&data, sizeof(data)); \
347  STREAM_ANALYSE(data, sizeof(data)); \
348  return *this; \
349  } \
350  /* Input Streamer */ \
351  StreamBuffer& operator>>(TYPE & data) { \
352  swapFromBuffer(&data, sizeof(data)); \
353  return *this; \
354  }
355 // RootCint does not understand this macro....
356 // But we can easily live without it!
357 #undef IMPLEMENT_STREAMER
358 
361  swapToBuffer(&data, sizeof(data));
362  STREAM_ANALYSE(data, sizeof(data));
363  return *this;
364  }
367  swapFromBuffer(&data, sizeof(data));
368  return *this;
369  }
372  swapToBuffer(&data, sizeof(data));
373  STREAM_ANALYSE(data, sizeof(data));
374  return *this;
375  }
377  StreamBuffer& operator>>(int & data) {
378  swapFromBuffer(&data, sizeof(data));
379  return *this;
380  }
382  StreamBuffer& operator<<(unsigned int data) {
383  swapToBuffer(&data, sizeof(data));
384  STREAM_ANALYSE(data, sizeof(data));
385  return *this;
386  }
388  StreamBuffer& operator>>(unsigned int & data) {
389  swapFromBuffer(&data, sizeof(data));
390  return *this;
391  }
393  StreamBuffer& operator<<(long data) {
394  swapToBuffer(&data, sizeof(data));
395  STREAM_ANALYSE(data, sizeof(data));
396  return *this;
397  }
399  StreamBuffer& operator>>(long & data) {
400  swapFromBuffer(&data, sizeof(data));
401  return *this;
402  }
404  StreamBuffer& operator<<(unsigned long data) {
405  swapToBuffer(&data, sizeof(data));
406  STREAM_ANALYSE(data, sizeof(data));
407  return *this;
408  }
410  StreamBuffer& operator>>(unsigned long & data) {
411  swapFromBuffer(&data, sizeof(data));
412  return *this;
413  }
415  StreamBuffer& operator<<(short data) {
416  swapToBuffer(&data, sizeof(data));
417  STREAM_ANALYSE(data, sizeof(data));
418  return *this;
419  }
421  StreamBuffer& operator>>(short & data) {
422  swapFromBuffer(&data, sizeof(data));
423  return *this;
424  }
426  StreamBuffer& operator<<(unsigned short data) {
427  swapToBuffer(&data, sizeof(data));
428  STREAM_ANALYSE(data, sizeof(data));
429  return *this;
430  }
432  StreamBuffer& operator>>(unsigned short & data) {
433  swapFromBuffer(&data, sizeof(data));
434  return *this;
435  }
437  StreamBuffer& operator<<(char data) {
438  swapToBuffer(&data, sizeof(data));
439  STREAM_ANALYSE(data, sizeof(data));
440  return *this;
441  }
443  StreamBuffer& operator>>(char & data) {
444  swapFromBuffer(&data, sizeof(data));
445  return *this;
446  }
448  StreamBuffer& operator<<(unsigned char data) {
449  swapToBuffer(&data, sizeof(data));
450  STREAM_ANALYSE(data, sizeof(data));
451  return *this;
452  }
454  StreamBuffer& operator>>(unsigned char & data) {
455  swapFromBuffer(&data, sizeof(data));
456  return *this;
457  }
459  StreamBuffer& operator<<(float data) {
460  swapToBuffer(&data, sizeof(data));
461  STREAM_ANALYSE(data, sizeof(data));
462  return *this;
463  }
465  StreamBuffer& operator>>(float & data) {
466  swapFromBuffer(&data, sizeof(data));
467  return *this;
468  }
470  StreamBuffer& operator<<(double data) {
471  swapToBuffer(&data, sizeof(data));
472  STREAM_ANALYSE(data, sizeof(data));
473  return *this;
474  }
476  StreamBuffer& operator>>(double & data) {
477  swapFromBuffer(&data, sizeof(data));
478  return *this;
479  }
481  StreamBuffer& operator>>(char* data) {
482  long i, len;
483  *this >> len;
484  for ( i = 0, data[0]=0; i < len; i++ ) {
485  data[i] = m_buffer[m_pointer++];
486  }
487  return *this;
488  }
490  StreamBuffer& operator<<(const char *data) {
491  const char* ptr = 0 == data ? "" : data;
492  int len = strlen(ptr)+1;
493  if ( 0 == m_analyzer )
494  writeBytes(ptr, len);
495  else {
496  STREAM_ANALYSE(data, len);
497  }
498  return *this;
499  }
502  long i, len;
503  *this >> len;
504  for ( i = 0, data = ""; i < len; i++ ) {
505  data.append( 1, m_buffer[m_pointer++] );
506  }
507  return *this;
508  }
511  if ( 0 == m_analyzer) {
512  const char* ptr = data.c_str();
513  long len = data.length();
514  writeBytes(ptr, len);
515  }
516  else {
517  STREAM_ANALYSE(data, sizeof(data));
518  }
519  return *this;
520  }
527  template<class TYPE> StreamBuffer& operator>>(TYPE*& refpObject) {
528  return getObjectPointer(refpObject, refpObject);
529  }
530 
538  STREAM_ANALYSE(pObject, sizeof(pObject));
539  addContainedLink(pObject, INVALID, INVALID);
540  return *this;
541  }
542 
549  StreamBuffer& operator<<(const DataObject* pObject) {
550  STREAM_ANALYSE(pObject, sizeof(pObject));
551  addIdentifiedLink(pObject, INVALID);
552  return *this;
553  }
554 
561  void serialize(DataIO& ioObject) {
562  ioObject.serialize ( *this );
563  m_pointer = 0;
564  }
565 };
566 
567 #undef STREAM_ANALYSE
568 
571  switch(siz) {
572  case 1:
573  return SINGLE_BYTE;
574  default:
575 #if defined(__alpha) && !defined(__VMS)
576 // return m_swapEnabled ? SWAP : NOSWAP;
577  return NOSWAP;
578 #elif defined(__sun) && defined(__SVR4) && defined(__i386)
579 // return m_swapEnabled ? SWAP : NOSWAP;
580  return NOSWAP;
581 #elif defined(__APPLE__)
582 // return m_swapEnabled ? SWAP : NOSWAP;
583  return SWAP;
584 #elif defined(__linux) && !defined(__powerpc)
585 // return m_swapEnabled ? SWAP : NOSWAP;
586  return NOSWAP;
587 #elif defined(BORLAND) || defined(_WIN32) || defined(WIN32)
588 // return m_swapEnabled ? SWAP : NOSWAP;
589  return NOSWAP;
590 #else
591  return m_swapEnabled ? SWAP : NOSWAP;
592 // return NOSWAP;
593 #endif
594  }
595 }
596 
598 inline void StreamBuffer::swapToBuffer(const void* source, int siz) {
599  char buff[8], *tar, *src = (char*)source;
600  extend (m_pointer+siz);
601  tar = (char*)m_buffer+m_pointer;
602  switch ( swapBuffer(siz) ) {
603  case SINGLE_BYTE:
604  *tar = *src;
605  break;
606  case SWAP:
607 #ifdef __APPLE__
608  for(int i = 0,j = siz-1;i<siz;i++,j--) tar[j] = src[i];
609 #else
610  ::_swab (src, buff, siz);
611 #endif
612  src = buff;
613  /* no break */
614  case NOSWAP:
615  std::copy_n(src,siz,tar);
616  break;
617  }
618  m_pointer += siz;
619 }
620 
622 inline void StreamBuffer::swapFromBuffer(void* target, int siz) {
623  char* tar = (char*)target;
624  char* src = (char*)m_buffer+m_pointer;
625  switch ( swapBuffer(siz) ) {
626  case SINGLE_BYTE:
627  *tar = *src;
628  break;
629  case SWAP:
630 #ifdef __APPLE__
631  for(int i = 0,j = siz-1;i<siz;i++,j--) tar[j] = src[i];
632 #else
633  ::_swab (src, tar, siz);
634 #endif
635  break;
636  case NOSWAP:
637  std::copy_n(src,siz,tar);
638  break;
639  }
640  m_pointer += siz;
641 }
642 
643 // Output serialize a vector of items
644 template <class T> inline
645 StreamBuffer& operator << (StreamBuffer& s, const std::vector<T>& v) {
646  s << v.size();
647  for ( const auto& i : v ) s << i;
648  return s;
649 }
650 
651 // Input serialize a vector of items
652 template <class T> inline
654  long i, len;
655  s >> len;
656  v.clear();
657  for ( i = 0; i < len; i++ ) {
658  T temp;
659  s >> temp;
660  v.push_back(temp);
661  }
662  return s;
663 }
664 
665 // Output serialize a list of items
666 template <class T> inline
667 StreamBuffer& operator << (StreamBuffer& s, const std::list<T>& l) {
668  s << l.size();
669  for ( const auto& i : l ) s << i ;
670  return s;
671 }
672 
673 // Input serialize a list of items
674 template <class T> inline
676  long len;
677  s >> len;
678  l.clear();
679  for ( long i = 0; i < len; i++ ) {
680  T temp;
681  s >> temp;
682  l.push_back(temp);
683  }
684  return s;
685 }
686 #endif // GAUDIKERNEL_STREAMBUFFER_H
virtual void load(StreamBuffer &)
Template function to load stream data.
Definition: StreamBuffer.h:64
Writer for standard output streams.
Definition: StreamBuffer.h:95
StreamBuffer(bool do_swap=true)
Standard constructor.
Definition: StreamBuffer.h:203
std::ostream * m_stream
Definition: StreamBuffer.h:96
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:490
long buffPointer() const
Retrieve current buffer pointer.
Definition: StreamBuffer.h:289
StreamBuffer & operator>>(long &data)
Input Streamer.
Definition: StreamBuffer.h:399
StreamBuffer & operator>>(unsigned short &data)
Input Streamer.
Definition: StreamBuffer.h:432
Ostream(std::ostream &str)
Standard constructor: pass reference to stream object.
Definition: StreamBuffer.h:99
StreamBuffer & operator<<(double data)
Output Streamer.
Definition: StreamBuffer.h:470
std::istream * m_stream
Reference to input stream.
Definition: StreamBuffer.h:76
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:549
The stream buffer is a small object collecting object data.
Definition: StreamBuffer.h:41
StreamBuffer & operator>>(float &data)
Input Streamer.
Definition: StreamBuffer.h:465
SwapAction
Data Sawp actions.
Definition: StreamBuffer.h:115
ContainedLinks m_containedLinks
Container with links to contained objects.
Definition: StreamBuffer.h:170
Istream(std::istream &str)
Constructor.
Definition: StreamBuffer.h:79
AnalyzeFunction m_analyzer
Hook function for analysis of data to the stream.
Definition: StreamBuffer.h:176
virtual void dump(StreamBuffer &)
Template function to save stream data.
Definition: StreamBuffer.h:68
long m_length
Total buffer length.
Definition: StreamBuffer.h:161
IdentifiedLinks & identifiedLinks()
Access to identified links.
Definition: StreamBuffer.h:263
char * m_buffer
Pointer to heap buffer.
Definition: StreamBuffer.h:164
class MergingTransformer< Out(const vector_of_const_< In > void
void extend(long len)
Extend the buffer.
Definition: StreamBuffer.h:240
StreamBuffer & operator<<(const ContainedObject *pObject)
Streamer to write links to contained objects.
Definition: StreamBuffer.h:537
StreamBuffer & operator>>(char *data)
Streamer to read strings in (char*) format.
Definition: StreamBuffer.h:481
void swapToBuffer(const void *source, int siz)
Swap buffers: int, long, short, float and double.
Definition: StreamBuffer.h:598
T end(T...args)
bool isReading() const
Get stream buffer state.
Definition: StreamBuffer.h:280
std::vector< ContainedLink > ContainedLinks
Definition: StreamBuffer.h:145
StreamBuffer & operator<<(unsigned long data)
Output Streamer.
Definition: StreamBuffer.h:404
T copy_n(T...args)
StreamBuffer & operator<<(unsigned short data)
Output Streamer.
Definition: StreamBuffer.h:426
Reader for standard input streams.
Definition: StreamBuffer.h:74
const char * data() const
Read access to data buffer.
Definition: StreamBuffer.h:211
STL class.
void setAnalyzer(AnalyzeFunction fun=nullptr)
Enable user analysis function.
Definition: StreamBuffer.h:297
char * data()
write access to data buffer
Definition: StreamBuffer.h:215
void setBuffPointer(long ptr)
Retrieve current buffer pointer.
Definition: StreamBuffer.h:293
StreamBuffer & operator>>(unsigned char &data)
Input Streamer.
Definition: StreamBuffer.h:454
constexpr double second
STL class.
StreamBuffer & operator<<(int data)
Output Streamer.
Definition: StreamBuffer.h:371
StreamBuffer & operator>>(longlong &data)
Input Streamer.
Definition: StreamBuffer.h:366
T push_back(T...args)
void reserve(long len)
Reserve buffer space; Default: 16 k buffer size.
Definition: StreamBuffer.h:233
Mode m_mode
Boolean indicating wether the stream is in read or write mode.
Definition: StreamBuffer.h:155
#define STREAM_ANALYSE(data, len)
Definition: StreamBuffer.h:339
const IdentifiedLinks & identifiedLinks() const
CONST Access to identified links.
Definition: StreamBuffer.h:267
ContainedLinks & containedLinks()
Access to contained links.
Definition: StreamBuffer.h:254
StreamBuffer & operator<<(long data)
Output Streamer.
Definition: StreamBuffer.h:393
constexpr double m
Definition: SystemOfUnits.h:93
T append(T...args)
StreamBuffer & operator<<(unsigned char data)
Output Streamer.
Definition: StreamBuffer.h:448
T erase(T...args)
T pop_back(T...args)
StreamBuffer & operator<<(longlong data)
Output Streamer.
Definition: StreamBuffer.h:360
StreamBuffer & operator<<(short data)
Output Streamer.
Definition: StreamBuffer.h:415
StreamBuffer & getObjectPointer(const ContainedObject *, TYPE *&refpObject)
Helper to distinguish between identified pointers and contained pointers.
Definition: StreamBuffer.h:194
StreamBuffer & operator<<(const std::string &data)
Streamer to write strings in (std::string) format.
Definition: StreamBuffer.h:510
void badStreamMode()
Throw Exception.
Definition: StreamBuffer.h:51
T clear(T...args)
void load(StreamBuffer &stream) override
Data load method.
Definition: StreamBuffer.h:85
STL class.
StreamBuffer & operator>>(char &data)
Input Streamer.
Definition: StreamBuffer.h:443
StreamBuffer & operator>>(unsigned long &data)
Input Streamer.
Definition: StreamBuffer.h:410
#define _swab(source, target, radix)
Definition: swab.h:7
void addIdentifiedLink(const DataObject *pObject, long hint)
Definition: StreamBuffer.h:321
dictionary l
Definition: gaudirun.py:421
All classes that their objects may be contained in an LHCb ObjectContainer (e.g.
virtual ~DataIO()=default
Standard destructor.
T length(T...args)
void dump(StreamBuffer &stream) override
Output dumper.
Definition: StreamBuffer.h:105
bool isWriting() const
Get stream buffer state.
Definition: StreamBuffer.h:285
long m_pointer
Current buffer pointer.
Definition: StreamBuffer.h:158
T begin(T...args)
T write(T...args)
A small base class to handle generic data streaming.
Definition: StreamBuffer.h:44
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:245
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:307
virtual ~StreamBuffer()
Standard destructor.
Definition: StreamBuffer.h:207
void erase()
Reset the buffer.
Definition: StreamBuffer.h:219
StreamBuffer & operator<<(unsigned int data)
Output Streamer.
Definition: StreamBuffer.h:382
void(* AnalyzeFunction)(const void *data, int siz, const std::type_info &type)
Definition of the buffer analyzer.
Definition: StreamBuffer.h:149
StreamBuffer & operator>>(std::string &data)
Streamer to read strings in (std::string) format.
Definition: StreamBuffer.h:501
StreamBuffer & operator<<(char data)
Output Streamer.
Definition: StreamBuffer.h:437
void setMode(Mode m)
Set mode of the stream and allocate buffer.
Definition: StreamBuffer.h:272
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:223
StreamBuffer & getObjectPointer(const DataObject *, TYPE *&refpObject)
Helper to distinguish between identified pointers and contained pointers.
Definition: StreamBuffer.h:184
StreamBuffer & operator>>(unsigned int &data)
Input Streamer.
Definition: StreamBuffer.h:388
IdentifiedLinks m_identifiedLinks
Container with links to contained objects.
Definition: StreamBuffer.h:173
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:570
StreamBuffer & operator>>(double &data)
Input Streamer.
Definition: StreamBuffer.h:476
void addContainedLink(const ContainedObject *pObject, long hint, long link)
Definition: StreamBuffer.h:332
void getContainedLink(ContainedObject *&pObject, long &hint, long &link)
Definition: StreamBuffer.h:325
long size() const
Total buffer size.
Definition: StreamBuffer.h:250
StreamBuffer & operator>>(int &data)
Input Streamer.
Definition: StreamBuffer.h:377
std::vector< IdentifiedLink > IdentifiedLinks
Definition of the identifiable link set.
Definition: StreamBuffer.h:147
void serialize(DataIO &ioObject)
Serialize the buffer using an IO object.
Definition: StreamBuffer.h:561
const ContainedLinks & containedLinks() const
CONST Access to contained links.
Definition: StreamBuffer.h:258
bool m_swapEnabled
Flag indicating swapping.
Definition: StreamBuffer.h:167
StreamBuffer & operator>>(short &data)
Input Streamer.
Definition: StreamBuffer.h:421
void getIdentifiedLink(DataObject *&pObject, long &hint)
Definition: StreamBuffer.h:315
StreamBuffer & operator>>(TYPE *&refpObject)
Streamer to read links to contained or identified objects.
Definition: StreamBuffer.h:527
void swapFromBuffer(void *target, int siz)
Swap buffers: int, long, short, float and double.
Definition: StreamBuffer.h:622