TEmulatedCollectionProxy.h

Go to the documentation of this file.
00001 // @(#)root/io:$Id: TEmulatedCollectionProxy.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_TEmulatedCollectionProxy
00012 #define ROOT_TEmulatedCollectionProxy
00013 
00014 //////////////////////////////////////////////////////////////////////////
00015 //                                                                      //
00016 // TEmulatedCollectionProxy
00017 //
00018 // Streamer around an arbitrary STL like container, which implements basic
00019 // container functionality.
00020 //
00021 // Note:
00022 // Although this class contains all the setup necessary to deal
00023 // with maps, the map-like functionality is NOT supported.
00024 // For optimization reasons this functionality is put into
00025 // the class TEmulatedMapProxy.
00026 //
00027 //////////////////////////////////////////////////////////////////////////
00028 
00029 #include "TGenCollectionProxy.h"
00030 
00031 class TEmulatedCollectionProxy : public TGenCollectionProxy  {
00032 
00033    // Friend declaration
00034    friend class TCollectionProxy;
00035 
00036 public:
00037    // Container type definition
00038    typedef std::vector<char>  Cont_t;
00039    // Pointer to container type
00040    typedef Cont_t            *PCont_t;
00041 protected:
00042 
00043    // Some hack to avoid const-ness
00044    virtual TGenCollectionProxy* InitializeEx();
00045 
00046    // Object input streamer
00047    void ReadItems(int nElements, TBuffer &b);
00048 
00049    // Object output streamer
00050    void WriteItems(int nElements, TBuffer &b);
00051 
00052    // Shrink the container
00053    void Shrink(UInt_t nCurr, UInt_t left, Bool_t force);
00054 
00055    // Expand the container
00056    void Expand(UInt_t nCurr, UInt_t left);
00057 
00058 public:
00059    // Virtual copy constructor
00060    virtual TVirtualCollectionProxy* Generate() const;
00061 
00062    // Copy constructor
00063    TEmulatedCollectionProxy(const TEmulatedCollectionProxy& copy);
00064 
00065    // Initializing constructor
00066    TEmulatedCollectionProxy(const char* cl_name);
00067 
00068    // Standard destructor
00069    virtual ~TEmulatedCollectionProxy();
00070 
00071    // Virtual constructor
00072    virtual void* New()   const             {  return new Cont_t;         }
00073 
00074    // Virtual in-place constructor
00075    virtual void* New(void* memory)   const {  return new(memory) Cont_t; }
00076 
00077    // Virtual array constructor
00078    virtual void* NewArray(Int_t nElements)   const             {  return new Cont_t[nElements];         }
00079 
00080    // Virtual in-place constructor
00081    virtual void* NewArray(Int_t nElements, void* memory)   const {  return new(memory) Cont_t[nElements]; }
00082 
00083    // Virtual destructor
00084    virtual void  Destructor(void* p, Bool_t dtorOnly = kFALSE);
00085 
00086    // Virtual array destructor
00087    virtual void  DeleteArray(void* p, Bool_t dtorOnly = kFALSE);
00088 
00089    // TVirtualCollectionProxy overload: Return the sizeof the collection object.
00090    virtual UInt_t Sizeof() const           {  return sizeof(Cont_t);     }
00091 
00092    // Return the address of the value at index 'idx'
00093    virtual void *At(UInt_t idx);
00094 
00095    // Clear the container
00096    virtual void Clear(const char *opt = "");
00097 
00098    // Resize the container
00099    virtual void Resize(UInt_t n, Bool_t force_delete);
00100 
00101    // Return the current size of the container
00102    virtual UInt_t Size() const;
00103 
00104    // Block allocation of containees
00105    virtual void* Allocate(UInt_t n, Bool_t forceDelete);
00106 
00107    // Block commit of containees
00108    virtual void Commit(void* env);
00109 
00110    // Read portion of the streamer
00111    virtual void ReadBuffer(TBuffer &buff, void *pObj);
00112    virtual void ReadBuffer(TBuffer &buff, void *pObj, const TClass *onfile);
00113 
00114    // Streamer for I/O handling
00115    virtual void Streamer(TBuffer &refBuffer);
00116 
00117    // Streamer I/O overload
00118    virtual void Streamer(TBuffer &buff, void *pObj, int siz) {
00119       TGenCollectionProxy::Streamer(buff,pObj,siz);
00120    }
00121    
00122    // Check validity of the proxy itself
00123    Bool_t IsValid() const;
00124 };
00125 
00126 #endif

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