Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:11:36

0001 // @(#)root/io:$Id$
0002 // Author: Markus Frank  28/10/04
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2004, Rene Brun and Fons Rademakers.               *
0006  * All rights reserved.                                                  *
0007  *                                                                       *
0008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0010  *************************************************************************/
0011 #ifndef ROOT_TCollectionProxyFactory
0012 #define ROOT_TCollectionProxyFactory
0013 
0014 //////////////////////////////////////////////////////////////////////////
0015 //                                                                      //
0016 //  Small helper to save proxy environment in the event of
0017 //  recursive calls.
0018 //
0019 //////////////////////////////////////////////////////////////////////////
0020 
0021 #include "TCollectionProxyInfo.h"
0022 
0023 #include "TClassStreamer.h"
0024 
0025 #include "TMemberStreamer.h"
0026 
0027 #include "TGenCollectionProxy.h"
0028 
0029 // Forward declarations
0030 class TBuffer;
0031 class TGenCollectionProxy;
0032 class TGenCollectionStreamer;
0033 class TVirtualCollectionProxy;
0034 class TEmulatedCollectionProxy;
0035 
0036 #if defined(_WIN32)
0037    #if _MSC_VER<1300
0038       #define TYPENAME
0039       #define R__VCXX6
0040    #else
0041       #define TYPENAME typename
0042    #endif
0043 #else
0044    #define TYPENAME typename
0045 #endif
0046 
0047 
0048 /** \class TCollectionProxyFactory TCollectionProxyFactory.h
0049  TCollectionProxyFactory
0050  Interface to collection proxy and streamer generator.
0051  Proxy around an arbitrary container, which implements basic
0052  functionality and iteration. The purpose of this implementation
0053  is to shield any generated dictionary implementation from the
0054  underlying streamer/proxy implementation and only expose
0055  the creation functions.
0056 
0057  In particular this is used to implement splitting and abstract
0058  element access of any container. Access to compiled code is necessary
0059  to implement the abstract iteration sequence and functionality like
0060  size(), clear(), resize(). resize() may be a void operation.
0061 
0062  \author  M.Frank
0063  \version 1.0
0064 */
0065 class TCollectionProxyFactory  {
0066 public:
0067 
0068    typedef TVirtualCollectionProxy Proxy_t;
0069 #ifdef R__HPUX
0070    typedef const std::type_info&      Info_t;
0071 #else
0072    typedef const std::type_info& Info_t;
0073 #endif
0074 
0075    /// Generate emulated collection proxy for a given class
0076    static TVirtualCollectionProxy* GenEmulatedProxy(const char* class_name, Bool_t silent);
0077 
0078    /// Generate emulated class streamer for a given collection class
0079    static TClassStreamer* GenEmulatedClassStreamer(const char* class_name, Bool_t silent);
0080 
0081    /// Generate emulated member streamer for a given collection class
0082    static TMemberStreamer* GenEmulatedMemberStreamer(const char* class_name, Bool_t silent);
0083 
0084 
0085    /// Generate proxy from static functions
0086    static Proxy_t* GenExplicitProxy( const ::ROOT::TCollectionProxyInfo &info, TClass *cl );
0087 
0088    /// Generate proxy from template
0089    template <class T> static Proxy_t* GenProxy(const T &arg, TClass *cl)  {
0090       return GenExplicitProxy( ::ROOT::TCollectionProxyInfo::Get(arg), cl );
0091    }
0092 
0093    /// Generate streamer from static functions
0094    static TGenCollectionStreamer*
0095       GenExplicitStreamer( const ::ROOT::TCollectionProxyInfo &info, TClass *cl );
0096 
0097    /// Generate class streamer from static functions
0098    static TClassStreamer*
0099       GenExplicitClassStreamer( const ::ROOT::TCollectionProxyInfo &info, TClass *cl );
0100 
0101    /// Generate class streamer from template
0102    template <class T> static TClassStreamer* GenClassStreamer(const T &arg, TClass *cl)  {
0103       return GenExplicitClassStreamer(::ROOT::TCollectionProxyInfo::Get(arg), cl);
0104    }
0105 
0106    /// Generate member streamer from static functions
0107    static TMemberStreamer*
0108       GenExplicitMemberStreamer(const ::ROOT::TCollectionProxyInfo &info, TClass *cl);
0109 
0110    /// Generate member streamer from template
0111    template <class T> static TMemberStreamer* GenMemberStreamer(const T &arg, TClass *cl)  {
0112       return GenExplicitMemberStreamer(::ROOT::TCollectionProxyInfo::Get(arg), cl);
0113    }
0114 };
0115 
0116 /**
0117  \class TCollectionStreamer TCollectionProxyFactory.h
0118  \ingroup IO
0119 
0120  Class streamer object to implement TClassStreamer functionality for I/O emulation.
0121 
0122  @author  M.Frank
0123  @version 1.0
0124 */
0125 class TCollectionStreamer   {
0126 private:
0127    TCollectionStreamer& operator=(const TCollectionStreamer&) = delete;
0128 
0129 protected:
0130    TGenCollectionProxy* fStreamer;   ///< Pointer to worker streamer
0131 
0132    /// Issue Error about invalid proxy
0133    void InvalidProxyError();
0134 
0135 public:
0136    /// Initializing constructor
0137    TCollectionStreamer();
0138    /// Copy constructor
0139    TCollectionStreamer(const TCollectionStreamer& c);
0140    /// Standard destructor
0141    virtual ~TCollectionStreamer();
0142    /// Attach worker proxy
0143    void AdoptStreamer(TGenCollectionProxy* streamer);
0144    /// Streamer for I/O handling
0145    void Streamer(TBuffer &refBuffer, void *obj, int siz, TClass *onFileClass );
0146 };
0147 
0148 /**
0149  \class TCollectionClassStreamer TCollectionProxyFactory.h
0150  \ingroup IO
0151 
0152  Class streamer object to implement TClassStreamer functionality
0153  for I/O emulation.
0154  \author  M.Frank
0155  \version 1.0
0156 */
0157 class TCollectionClassStreamer : public TClassStreamer, public TCollectionStreamer {
0158  protected:
0159    TCollectionClassStreamer &operator=(const TCollectionClassStreamer &rhs) = delete;
0160    /// Copy constructor
0161    TCollectionClassStreamer(const TCollectionClassStreamer& c)
0162       : TClassStreamer(c), TCollectionStreamer(c)      {                        }
0163 
0164 public:
0165    /// Initializing constructor
0166    TCollectionClassStreamer() : TClassStreamer(nullptr) {                        }
0167    /// Standard destructor
0168    ~TCollectionClassStreamer() override                  {                        }
0169    /// Streamer for I/O handling
0170    void operator()(TBuffer &buff, void *obj) override { Streamer(buff,obj,0,fOnFileClass); }
0171 
0172    void Stream(TBuffer &b, void *obj, const TClass *onfileClass) override
0173    {
0174       if (b.IsReading()) {
0175          TGenCollectionProxy *proxy = TCollectionStreamer::fStreamer;
0176          if (!onfileClass || onfileClass == proxy->GetCollectionClass()) {
0177             proxy->ReadBuffer(b,obj);
0178          } else {
0179             proxy->ReadBuffer(b,obj,onfileClass);
0180          }
0181       } else {
0182          // fStreamer->WriteBuffer(b,objp,onfileClass);
0183          Streamer(b,obj,0,(TClass*)onfileClass);
0184       }
0185    }
0186 
0187    /// Virtual copy constructor.
0188    TClassStreamer *Generate() const override {
0189       return new TCollectionClassStreamer(*this);
0190    }
0191 
0192    TGenCollectionProxy *GetXYZ() { return TCollectionStreamer::fStreamer; }
0193 
0194 };
0195 
0196 /**
0197  \class TCollectionMemberStreamer TCollectionProxyFactory.h
0198  \ingroup IO
0199 
0200  Class streamer object to implement TMemberStreamer functionality
0201  for I/O emulation.
0202  \author  M.Frank
0203  \version 1.0
0204   */
0205 class TCollectionMemberStreamer : public TMemberStreamer, public TCollectionStreamer {
0206 private:
0207    TCollectionMemberStreamer &operator=(const TCollectionMemberStreamer &rhs) = delete;
0208 public:
0209    /// Initializing constructor
0210    TCollectionMemberStreamer() : TMemberStreamer(nullptr) { }
0211    /// Copy constructor
0212    TCollectionMemberStreamer(const TCollectionMemberStreamer& c)
0213       : TMemberStreamer(c), TCollectionStreamer(c)   { }
0214    /// Standard destructor
0215    ~TCollectionMemberStreamer() override             { }
0216    /// Streamer for I/O handling
0217    void operator()(TBuffer &buff,void *obj, Int_t siz = 0) override
0218    { Streamer(buff, obj, siz, nullptr); /* FIXME */ }
0219 };
0220 
0221 #endif