TGenCollectionStreamer.h

Go to the documentation of this file.
00001 // @(#)root/io:$Id: TGenCollectionStreamer.h 36061 2010-10-04 16:05:51Z pcanal $
00002 // Author: Markus Frank  28/10/04
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2004, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 #ifndef ROOT_TGenCollectionStreamer
00012 #define ROOT_TGenCollectionStreamer
00013 
00014 //////////////////////////////////////////////////////////////////////////
00015 //                                                                      //
00016 // TGenCollectionStreamer
00017 //
00018 // Streamer around an arbitrary STL like container, which implements basic
00019 // container functionality.
00020 //
00021 //////////////////////////////////////////////////////////////////////////
00022 
00023 #include "TGenCollectionProxy.h"
00024 #include "TCollectionProxyFactory.h"
00025 
00026 class TGenCollectionStreamer : public TGenCollectionProxy {
00027 
00028 protected:
00029    void ReadMapHelper(StreamHelper *i, Value *v, Bool_t vsn3,  TBuffer &b);
00030    void ReadMap(int nElements, TBuffer &b);
00031    void ReadPairFromMap(int nElements, TBuffer &b);
00032    void ReadObjects(int nElements, TBuffer &b);
00033    void ReadPrimitives(int nElements, TBuffer &b);
00034    void WriteMap(int nElements, TBuffer &b);
00035    void WriteObjects(int nElements, TBuffer &b);
00036    void WritePrimitives(int nElements, TBuffer &b);
00037 
00038 //   typedef void (TGenCollectionStreamer::*ReadBufferConv_t)(TBuffer &b, void *obj, const TClass *onfileClass);
00039 //   ReadBufferConv_t fReadBufferConvFunc;
00040    
00041    typedef void (TGenCollectionStreamer::*ReadBuffer_t)(TBuffer &b, void *obj);
00042    ReadBuffer_t fReadBufferFunc;
00043    
00044    template <typename basictype> void ReadBufferVectorPrimitives(TBuffer &b, void *obj);
00045    void ReadBufferVectorPrimitivesFloat16(TBuffer &b, void *obj);
00046    void ReadBufferVectorPrimitivesDouble32(TBuffer &b, void *obj);
00047    void ReadBufferDefault(TBuffer &b, void *obj);
00048    void ReadBufferGeneric(TBuffer &b, void *obj);
00049       
00050 public:
00051    // Virtual copy constructor
00052    virtual TVirtualCollectionProxy* Generate() const;
00053 
00054    // Copy constructor
00055    TGenCollectionStreamer(const TGenCollectionStreamer& copy);
00056 
00057    // Initializing constructor
00058    TGenCollectionStreamer(Info_t typ, size_t iter_size);
00059    TGenCollectionStreamer(const ROOT::TCollectionProxyInfo &info, TClass *cl);
00060 
00061    // Standard destructor
00062    virtual ~TGenCollectionStreamer();
00063 
00064    // Streamer I/O overload
00065    virtual void Streamer(TBuffer &refBuffer);
00066 
00067    // Streamer I/O overload
00068    virtual void StreamerAsMap(TBuffer &refBuffer);
00069 
00070    // Streamer I/O overload
00071    virtual void Streamer(TBuffer &buff, void *pObj, int siz)  {
00072       TGenCollectionProxy::Streamer(buff, pObj, siz);
00073    }
00074 
00075    // Routine to read the content of the buffer into 'obj'.
00076    virtual void ReadBuffer(TBuffer &b, void *obj, const TClass *onfileClass);
00077 
00078    // Routine to read the content of the buffer into 'obj'.
00079    virtual void ReadBuffer(TBuffer &b, void *obj);
00080 };
00081 
00082 template <typename T>
00083 struct AnyCollectionStreamer : public TGenCollectionStreamer  {
00084    AnyCollectionStreamer()
00085       : TGenCollectionStreamer(typeid(T::Cont_t),sizeof(T::Iter_t))  {
00086       fValDiff        = sizeof(T::Value_t);
00087       fValOffset      = T::value_offset();
00088       fSize.call      = T::size;
00089       fFirst.call     = T::first;
00090       fNext.call      = T::next;
00091       fClear.call     = T::clear;
00092       fResize         = T::resize;
00093       fCollect.call   = T::collect;
00094       fConstruct      = T::construct;
00095       fDestruct       = T::destruct;
00096       fFeed           = T::feed;
00097       CheckFunctions();
00098    }
00099    virtual ~AnyCollectionStreamer() {  }
00100 };
00101 
00102 // Forward declaration in the event of later seperation
00103 typedef TGenCollectionStreamer TGenMapStreamer;
00104 
00105 #endif

Generated on Tue Jul 5 14:26:56 2011 for ROOT_528-00b_version by  doxygen 1.5.1