Logo ROOT   6.14/05
Reference Guide
TEmulatedCollectionProxy.h
Go to the documentation of this file.
1 // @(#)root/io:$Id$
2 // Author: Markus Frank 28/10/04
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2004, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 #ifndef ROOT_TEmulatedCollectionProxy
12 #define ROOT_TEmulatedCollectionProxy
13 
14 #include "TGenCollectionProxy.h"
15 
17 
18  // Friend declaration
19  friend class TCollectionProxy;
20 
21 public:
22  // Container type definition
23  typedef std::vector<char> Cont_t;
24  // Pointer to container type
25  typedef Cont_t *PCont_t;
26 protected:
27 
28  // Some hack to avoid const-ness
29  virtual TGenCollectionProxy* InitializeEx(Bool_t silent);
30 
31  // Object input streamer
32  void ReadItems(int nElements, TBuffer &b);
33 
34  // Object output streamer
35  void WriteItems(int nElements, TBuffer &b);
36 
37  // Shrink the container
38  void Shrink(UInt_t nCurr, UInt_t left, Bool_t force);
39 
40  // Expand the container
41  void Expand(UInt_t nCurr, UInt_t left);
42 
43 private:
44  TEmulatedCollectionProxy &operator=(const TEmulatedCollectionProxy &); // Not implemented.
45 
46 public:
47  // Virtual copy constructor
48  virtual TVirtualCollectionProxy* Generate() const;
49 
50  // Copy constructor
52 
53  // Initializing constructor
54  TEmulatedCollectionProxy(const char* cl_name, Bool_t silent);
55 
56  // Standard destructor
57  virtual ~TEmulatedCollectionProxy();
58 
59  // Virtual constructor
60  virtual void* New() const { return new Cont_t; }
61 
62  // Virtual in-place constructor
63  virtual void* New(void* memory) const { return new(memory) Cont_t; }
64 
65  // Virtual array constructor
66  virtual void* NewArray(Int_t nElements) const { return new Cont_t[nElements]; }
67 
68  // Virtual in-place constructor
69  virtual void* NewArray(Int_t nElements, void* memory) const { return new(memory) Cont_t[nElements]; }
70 
71  // Virtual destructor
72  virtual void Destructor(void* p, Bool_t dtorOnly = kFALSE) const;
73 
74  // Virtual array destructor
75  virtual void DeleteArray(void* p, Bool_t dtorOnly = kFALSE) const;
76 
77  // TVirtualCollectionProxy overload: Return the sizeof the collection object.
78  virtual UInt_t Sizeof() const { return sizeof(Cont_t); }
79 
80  // Return the address of the value at index 'idx'
81  virtual void *At(UInt_t idx);
82 
83  // Clear the container
84  virtual void Clear(const char *opt = "");
85 
86  // Resize the container
87  virtual void Resize(UInt_t n, Bool_t force_delete);
88 
89  // Return the current size of the container
90  virtual UInt_t Size() const;
91 
92  // Block allocation of containees
93  virtual void* Allocate(UInt_t n, Bool_t forceDelete);
94 
95  // Block commit of containees
96  virtual void Commit(void* env);
97 
98  // Insert data into the container where data is a C-style array of the actual type contained in the collection
99  // of the given size. For associative container (map, etc.), the data type is the pair<key,value>.
100  virtual void Insert(const void *data, void *container, size_t size);
101 
102  // Read portion of the streamer
103  virtual void ReadBuffer(TBuffer &buff, void *pObj);
104  virtual void ReadBuffer(TBuffer &buff, void *pObj, const TClass *onfile);
105 
106  // Streamer for I/O handling
107  virtual void Streamer(TBuffer &refBuffer);
108 
109  // Streamer I/O overload
110  virtual void Streamer(TBuffer &buff, void *pObj, int siz) {
111  TGenCollectionProxy::Streamer(buff,pObj,siz);
112  }
113 
114  // Check validity of the proxy itself
115  Bool_t IsValid() const;
116 };
117 
118 #endif
virtual UInt_t Size() const
Return the current size of the container.
void Expand(UInt_t nCurr, UInt_t left)
virtual void Destructor(void *p, Bool_t dtorOnly=kFALSE) const
virtual void * New(void *memory) const
Buffer base class used for serializing objects.
Definition: TBuffer.h:40
virtual UInt_t Sizeof() const
Return the sizeof the collection object.
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
Streamer around an arbitrary STL like container, which implements basic container functionality...
TEmulatedCollectionProxy(const TEmulatedCollectionProxy &copy)
virtual void * Allocate(UInt_t n, Bool_t forceDelete)
Allocate the needed space.
virtual void Streamer(TBuffer &refBuffer)
Streamer Function.
virtual void Resize(UInt_t n, Bool_t force_delete)
Resize the container.
virtual TVirtualCollectionProxy * Generate() const
Virtual copy constructor.
virtual void Clear(const char *opt="")
Clear the emulated collection.
unsigned int UInt_t
Definition: RtypesCore.h:42
virtual TGenCollectionProxy * InitializeEx(Bool_t silent)
Proxy initializer.
The ROOT global object gROOT contains a list of all defined classes.
Definition: TClass.h:75
void WriteItems(int nElements, TBuffer &b)
const Bool_t kFALSE
Definition: RtypesCore.h:88
virtual void Commit(void *env)
Commit the change.
virtual void * NewArray(Int_t nElements, void *memory) const
virtual void * NewArray(Int_t nElements) const
virtual void Insert(const void *data, void *container, size_t size)
Insert data into the container where data is a C-style array of the actual type contained in the coll...
void Shrink(UInt_t nCurr, UInt_t left, Bool_t force)
void ReadItems(int nElements, TBuffer &b)
virtual void DeleteArray(void *p, Bool_t dtorOnly=kFALSE) const
TEmulatedCollectionProxy & operator=(const TEmulatedCollectionProxy &)
Proxy around an arbitrary container, which implements basic functionality and iteration.
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
Definition: TRolke.cxx:630
virtual void Streamer(TBuffer &buff, void *pObj, int siz)
Streamer I/O overload.
virtual void * At(UInt_t idx)
Return the address of the value at index &#39;idx&#39;.
virtual void ReadBuffer(TBuffer &buff, void *pObj)
virtual void Streamer(TBuffer &refBuffer)
Streamer Function.
const Int_t n
Definition: legend1.C:16