Back to home page

EIC code displayed by LXR

 
 

    


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

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_TEmulatedCollectionProxy
0012 #define ROOT_TEmulatedCollectionProxy
0013 
0014 #include "TGenCollectionProxy.h"
0015 
0016 #include <vector>
0017 
0018 class TEmulatedCollectionProxy : public TGenCollectionProxy  {
0019 
0020    // Friend declaration
0021    friend class TCollectionProxy;
0022 
0023 public:
0024    // Container type definition
0025    typedef std::vector<char>  Cont_t;
0026    // Pointer to container type
0027    typedef Cont_t            *PCont_t;
0028 protected:
0029 
0030    // Some hack to avoid const-ness
0031    TGenCollectionProxy* InitializeEx(Bool_t silent) override;
0032 
0033    // Object input streamer
0034    void ReadItems(int nElements, TBuffer &b);
0035 
0036    // Object output streamer
0037    void WriteItems(int nElements, TBuffer &b);
0038 
0039    // Shrink the container
0040    void Shrink(UInt_t nCurr, UInt_t left, Bool_t force);
0041 
0042    // Expand the container
0043    void Expand(UInt_t nCurr, UInt_t left);
0044 
0045 private:
0046    TEmulatedCollectionProxy &operator=(const TEmulatedCollectionProxy &); // Not implemented.
0047 
0048 public:
0049    // Virtual copy constructor
0050    TVirtualCollectionProxy* Generate() const override;
0051 
0052    // Copy constructor
0053    TEmulatedCollectionProxy(const TEmulatedCollectionProxy& copy);
0054 
0055    // Initializing constructor
0056    TEmulatedCollectionProxy(const char* cl_name, Bool_t silent);
0057 
0058    // Standard destructor
0059    ~TEmulatedCollectionProxy() override;
0060 
0061    // Virtual constructor
0062    void* New() const override             {  return new Cont_t;         }
0063 
0064    // Virtual in-place constructor
0065    void* New(void* memory) const override {  return new(memory) Cont_t; }
0066 
0067    // Virtual constructor
0068    TClass::ObjectPtr NewObject() const override             {  return {new Cont_t, nullptr};         }
0069 
0070    // Virtual in-place constructor
0071    TClass::ObjectPtr NewObject(void* memory) const override {  return {new(memory) Cont_t, nullptr}; }
0072 
0073    // Virtual array constructor
0074    void* NewArray(Int_t nElements) const override             {  return new Cont_t[nElements]; }
0075 
0076    // Virtual in-place constructor
0077    void* NewArray(Int_t nElements, void* memory) const override {  return new(memory) Cont_t[nElements]; }
0078 
0079    // Virtual array constructor
0080    TClass::ObjectPtr NewObjectArray(Int_t nElements) const override  {  return {new Cont_t[nElements], nullptr}; }
0081 
0082    // Virtual in-place constructor
0083    TClass::ObjectPtr NewObjectArray(Int_t nElements, void* memory) const override {  return {new(memory) Cont_t[nElements], nullptr}; }
0084 
0085    // Virtual destructor
0086    void  Destructor(void* p, Bool_t dtorOnly = kFALSE) const override;
0087 
0088    // Virtual array destructor
0089    void  DeleteArray(void* p, Bool_t dtorOnly = kFALSE) const override;
0090 
0091    // TVirtualCollectionProxy overload: Return the sizeof the collection object.
0092    UInt_t Sizeof() const override { return sizeof(Cont_t); }
0093 
0094    // Return the address of the value at index 'idx'
0095    void *At(UInt_t idx) override;
0096 
0097    // Clear the container
0098    void Clear(const char *opt = "") override;
0099 
0100    // Resize the container
0101    void Resize(UInt_t n, Bool_t force_delete) override;
0102 
0103    // Return the current size of the container
0104    UInt_t Size() const override;
0105 
0106    // Block allocation of containees
0107    void* Allocate(UInt_t n, Bool_t forceDelete) override;
0108 
0109    // Block commit of containees
0110    void Commit(void* env) override;
0111 
0112    // Insert data into the container where data is a C-style array of the actual type contained in the collection
0113    // of the given size.   For associative container (map, etc.), the data type is the pair<key,value>.
0114    void  Insert(const void *data, void *container, size_t size) override;
0115 
0116    // Read portion of the streamer
0117    void ReadBuffer(TBuffer &buff, void *pObj) override;
0118    void ReadBuffer(TBuffer &buff, void *pObj, const TClass *onfile) override;
0119 
0120    // Streamer for I/O handling
0121    void Streamer(TBuffer &refBuffer) override;
0122 
0123    // Streamer I/O overload
0124    void Streamer(TBuffer &buff, void *pObj, int siz) override
0125    {
0126       TGenCollectionProxy::Streamer(buff,pObj,siz);
0127    }
0128 
0129    // Check validity of the proxy itself
0130    Bool_t IsValid() const;
0131 };
0132 
0133 #endif