Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TGenCollectionStreamer.h
Go to the documentation of this file.
1 // @(#)root/io:$Id$
2 // Author: Markus Frank 28/10/04
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2004, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 #ifndef ROOT_TGenCollectionStreamer
12 #define ROOT_TGenCollectionStreamer
13 
14 #include "TGenCollectionProxy.h"
16 
17 class TGenCollectionStreamer : public TGenCollectionProxy {
18 
19 protected:
20  void ReadMapHelper(StreamHelper *i, Value *v, Bool_t vsn3, TBuffer &b);
21  void ReadMap(int nElements, TBuffer &b, const TClass *onfileClass);
22  void ReadPairFromMap(int nElements, TBuffer &b);
23  void ReadObjects(int nElements, TBuffer &b, const TClass *onfileClass);
24  void ReadPrimitives(int nElements, TBuffer &b, const TClass *onfileClass);
25  void WriteMap(int nElements, TBuffer &b);
26  void WriteObjects(int nElements, TBuffer &b);
27  void WritePrimitives(int nElements, TBuffer &b);
28 
29 // typedef void (TGenCollectionStreamer::*ReadBufferConv_t)(TBuffer &b, void *obj, const TClass *onFileClass);
30 // ReadBufferConv_t fReadBufferConvFunc;
31 
32  typedef void (TGenCollectionStreamer::*ReadBuffer_t)(TBuffer &b, void *obj, const TClass *onFileClass);
33  ReadBuffer_t fReadBufferFunc;
34 
35  template <typename From, typename To> void ConvertBufferVectorPrimitives(TBuffer &b, void *obj, Int_t nElements);
36  template <typename To> void ConvertBufferVectorPrimitivesFloat16(TBuffer &b, void *obj, Int_t nElements);
37  template <typename To> void ConvertBufferVectorPrimitivesDouble32(TBuffer &b, void *obj, Int_t nElements);
38  template <typename To> void DispatchConvertBufferVectorPrimitives(TBuffer &b, void *obj, Int_t nElements, const TVirtualCollectionProxy *onfileProxy);
39  template <typename basictype> void ReadBufferVectorPrimitives(TBuffer &b, void *obj, const TClass *onFileClass);
40  void ReadBufferVectorPrimitivesFloat16(TBuffer &b, void *obj, const TClass *onFileClass);
41  void ReadBufferVectorPrimitivesDouble32(TBuffer &b, void *obj, const TClass *onFileClass);
42  void ReadBufferDefault(TBuffer &b, void *obj, const TClass *onFileClass);
43  void ReadBufferGeneric(TBuffer &b, void *obj, const TClass *onFileClass);
44 
45 private:
46  TGenCollectionStreamer &operator=(const TGenCollectionStreamer&); // Not implemented.
47 
48 public:
49  // Virtual copy constructor
50  virtual TVirtualCollectionProxy* Generate() const;
51 
52  // Copy constructor
53  TGenCollectionStreamer(const TGenCollectionStreamer& copy);
54 
55  // Initializing constructor
56  TGenCollectionStreamer(Info_t typ, size_t iter_size);
57  TGenCollectionStreamer(const ROOT::TCollectionProxyInfo &info, TClass *cl);
58 
59  // Standard destructor
60  virtual ~TGenCollectionStreamer();
61 
62  // Streamer I/O overload
63  virtual void Streamer(TBuffer &refBuffer);
64 
65  // Streamer I/O overload
66  virtual void StreamerAsMap(TBuffer &refBuffer);
67 
68  // Streamer I/O overload
69  virtual void Streamer(TBuffer &buff, void *pObj, int siz) {
70  TGenCollectionProxy::Streamer(buff, pObj, siz);
71  }
72 
73  // Routine to read the content of the buffer into 'obj'.
74  virtual void ReadBuffer(TBuffer &b, void *obj, const TClass *onfileClass);
75 
76  // Routine to read the content of the buffer into 'obj'.
77  virtual void ReadBuffer(TBuffer &b, void *obj);
78 };
79 
80 template <typename T>
81 struct AnyCollectionStreamer : public TGenCollectionStreamer {
82  AnyCollectionStreamer()
83  : TGenCollectionStreamer(typeid(T::Cont_t),sizeof(T::Iter_t)) {
84  fValDiff = sizeof(T::Value_t);
85  fValOffset = T::value_offset();
86  fSize.call = T::size;
87  fFirst.call = T::first;
88  fNext.call = T::next;
89  fClear.call = T::clear;
90  fResize = T::resize;
91  fCollect = T::collect;
92  fConstruct = T::construct;
93  fDestruct = T::destruct;
94  fFeed = T::feed;
95  CheckFunctions();
96  }
97  virtual ~AnyCollectionStreamer() { }
98 };
99 
100 // Forward declaration in the event of later separation
101 typedef TGenCollectionStreamer TGenMapStreamer;
102 
103 #endif