ROOT logo
// @(#)root/io:$Id: TEmulatedCollectionProxy.h 31136 2009-11-12 21:25:38Z pcanal $
// Author: Markus Frank  28/10/04

/*************************************************************************
 * Copyright (C) 1995-2004, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/
#ifndef ROOT_TEmulatedCollectionProxy
#define ROOT_TEmulatedCollectionProxy

//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TEmulatedCollectionProxy
//
// Streamer around an arbitrary STL like container, which implements basic
// container functionality.
//
// Note:
// Although this class contains all the setup necessary to deal
// with maps, the map-like functionality is NOT supported.
// For optimization reasons this functionality is put into
// the class TEmulatedMapProxy.
//
//////////////////////////////////////////////////////////////////////////

#include "TGenCollectionProxy.h"

class TEmulatedCollectionProxy : public TGenCollectionProxy  {

   // Friend declaration
   friend class TCollectionProxy;

public:
   // Container type definition
   typedef std::vector<char>  Cont_t;
   // Pointer to container type
   typedef Cont_t            *PCont_t;
protected:

   // Some hack to avoid const-ness
   virtual TGenCollectionProxy* InitializeEx();

   // Object input streamer
   void ReadItems(int nElements, TBuffer &b);

   // Object output streamer
   void WriteItems(int nElements, TBuffer &b);

   // Shrink the container
   void Shrink(UInt_t nCurr, UInt_t left, Bool_t force);

   // Expand the container
   void Expand(UInt_t nCurr, UInt_t left);

public:
   // Virtual copy constructor
   virtual TVirtualCollectionProxy* Generate() const;

   // Copy constructor
   TEmulatedCollectionProxy(const TEmulatedCollectionProxy& copy);

   // Initializing constructor
   TEmulatedCollectionProxy(const char* cl_name);

   // Standard destructor
   virtual ~TEmulatedCollectionProxy();

   // Virtual constructor
   virtual void* New()   const             {  return new Cont_t;         }

   // Virtual in-place constructor
   virtual void* New(void* memory)   const {  return new(memory) Cont_t; }

   // Virtual array constructor
   virtual void* NewArray(Int_t nElements)   const             {  return new Cont_t[nElements];         }

   // Virtual in-place constructor
   virtual void* NewArray(Int_t nElements, void* memory)   const {  return new(memory) Cont_t[nElements]; }

   // Virtual destructor
   virtual void  Destructor(void* p, Bool_t dtorOnly = kFALSE);

   // Virtual array destructor
   virtual void  DeleteArray(void* p, Bool_t dtorOnly = kFALSE);

   // TVirtualCollectionProxy overload: Return the sizeof the collection object.
   virtual UInt_t Sizeof() const           {  return sizeof(Cont_t);     }

   // Return the address of the value at index 'idx'
   virtual void *At(UInt_t idx);

   // Clear the container
   virtual void Clear(const char *opt = "");

   // Resize the container
   virtual void Resize(UInt_t n, Bool_t force_delete);

   // Return the current size of the container
   virtual UInt_t Size() const;

   // Block allocation of containees
   virtual void* Allocate(UInt_t n, Bool_t forceDelete);

   // Block commit of containees
   virtual void Commit(void* env);

   // Streamer for I/O handling
   virtual void Streamer(TBuffer &refBuffer);

   // Streamer I/O overload
   virtual void Streamer(TBuffer &buff, void *pObj, int siz) {
      TGenCollectionProxy::Streamer(buff,pObj,siz);
   }
   
   // Check validity of the proxy itself
   Bool_t IsValid() const;
};

#endif
 TEmulatedCollectionProxy.h:1
 TEmulatedCollectionProxy.h:2
 TEmulatedCollectionProxy.h:3
 TEmulatedCollectionProxy.h:4
 TEmulatedCollectionProxy.h:5
 TEmulatedCollectionProxy.h:6
 TEmulatedCollectionProxy.h:7
 TEmulatedCollectionProxy.h:8
 TEmulatedCollectionProxy.h:9
 TEmulatedCollectionProxy.h:10
 TEmulatedCollectionProxy.h:11
 TEmulatedCollectionProxy.h:12
 TEmulatedCollectionProxy.h:13
 TEmulatedCollectionProxy.h:14
 TEmulatedCollectionProxy.h:15
 TEmulatedCollectionProxy.h:16
 TEmulatedCollectionProxy.h:17
 TEmulatedCollectionProxy.h:18
 TEmulatedCollectionProxy.h:19
 TEmulatedCollectionProxy.h:20
 TEmulatedCollectionProxy.h:21
 TEmulatedCollectionProxy.h:22
 TEmulatedCollectionProxy.h:23
 TEmulatedCollectionProxy.h:24
 TEmulatedCollectionProxy.h:25
 TEmulatedCollectionProxy.h:26
 TEmulatedCollectionProxy.h:27
 TEmulatedCollectionProxy.h:28
 TEmulatedCollectionProxy.h:29
 TEmulatedCollectionProxy.h:30
 TEmulatedCollectionProxy.h:31
 TEmulatedCollectionProxy.h:32
 TEmulatedCollectionProxy.h:33
 TEmulatedCollectionProxy.h:34
 TEmulatedCollectionProxy.h:35
 TEmulatedCollectionProxy.h:36
 TEmulatedCollectionProxy.h:37
 TEmulatedCollectionProxy.h:38
 TEmulatedCollectionProxy.h:39
 TEmulatedCollectionProxy.h:40
 TEmulatedCollectionProxy.h:41
 TEmulatedCollectionProxy.h:42
 TEmulatedCollectionProxy.h:43
 TEmulatedCollectionProxy.h:44
 TEmulatedCollectionProxy.h:45
 TEmulatedCollectionProxy.h:46
 TEmulatedCollectionProxy.h:47
 TEmulatedCollectionProxy.h:48
 TEmulatedCollectionProxy.h:49
 TEmulatedCollectionProxy.h:50
 TEmulatedCollectionProxy.h:51
 TEmulatedCollectionProxy.h:52
 TEmulatedCollectionProxy.h:53
 TEmulatedCollectionProxy.h:54
 TEmulatedCollectionProxy.h:55
 TEmulatedCollectionProxy.h:56
 TEmulatedCollectionProxy.h:57
 TEmulatedCollectionProxy.h:58
 TEmulatedCollectionProxy.h:59
 TEmulatedCollectionProxy.h:60
 TEmulatedCollectionProxy.h:61
 TEmulatedCollectionProxy.h:62
 TEmulatedCollectionProxy.h:63
 TEmulatedCollectionProxy.h:64
 TEmulatedCollectionProxy.h:65
 TEmulatedCollectionProxy.h:66
 TEmulatedCollectionProxy.h:67
 TEmulatedCollectionProxy.h:68
 TEmulatedCollectionProxy.h:69
 TEmulatedCollectionProxy.h:70
 TEmulatedCollectionProxy.h:71
 TEmulatedCollectionProxy.h:72
 TEmulatedCollectionProxy.h:73
 TEmulatedCollectionProxy.h:74
 TEmulatedCollectionProxy.h:75
 TEmulatedCollectionProxy.h:76
 TEmulatedCollectionProxy.h:77
 TEmulatedCollectionProxy.h:78
 TEmulatedCollectionProxy.h:79
 TEmulatedCollectionProxy.h:80
 TEmulatedCollectionProxy.h:81
 TEmulatedCollectionProxy.h:82
 TEmulatedCollectionProxy.h:83
 TEmulatedCollectionProxy.h:84
 TEmulatedCollectionProxy.h:85
 TEmulatedCollectionProxy.h:86
 TEmulatedCollectionProxy.h:87
 TEmulatedCollectionProxy.h:88
 TEmulatedCollectionProxy.h:89
 TEmulatedCollectionProxy.h:90
 TEmulatedCollectionProxy.h:91
 TEmulatedCollectionProxy.h:92
 TEmulatedCollectionProxy.h:93
 TEmulatedCollectionProxy.h:94
 TEmulatedCollectionProxy.h:95
 TEmulatedCollectionProxy.h:96
 TEmulatedCollectionProxy.h:97
 TEmulatedCollectionProxy.h:98
 TEmulatedCollectionProxy.h:99
 TEmulatedCollectionProxy.h:100
 TEmulatedCollectionProxy.h:101
 TEmulatedCollectionProxy.h:102
 TEmulatedCollectionProxy.h:103
 TEmulatedCollectionProxy.h:104
 TEmulatedCollectionProxy.h:105
 TEmulatedCollectionProxy.h:106
 TEmulatedCollectionProxy.h:107
 TEmulatedCollectionProxy.h:108
 TEmulatedCollectionProxy.h:109
 TEmulatedCollectionProxy.h:110
 TEmulatedCollectionProxy.h:111
 TEmulatedCollectionProxy.h:112
 TEmulatedCollectionProxy.h:113
 TEmulatedCollectionProxy.h:114
 TEmulatedCollectionProxy.h:115
 TEmulatedCollectionProxy.h:116
 TEmulatedCollectionProxy.h:117
 TEmulatedCollectionProxy.h:118
 TEmulatedCollectionProxy.h:119
 TEmulatedCollectionProxy.h:120
 TEmulatedCollectionProxy.h:121
 TEmulatedCollectionProxy.h:122