Logo ROOT  
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
21public:
22 // Container type definition
23 typedef std::vector<char> Cont_t;
24 // Pointer to container type
25 typedef Cont_t *PCont_t;
26protected:
27
28 // Some hack to avoid const-ness
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
43private:
45
46public:
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
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 constructor
66 virtual TClass::ObjectPtr NewObject() const { return {new Cont_t, nullptr}; }
67
68 // Virtual in-place constructor
69 virtual TClass::ObjectPtr NewObject(void* memory) const { return {new(memory) Cont_t, nullptr}; }
70
71 // Virtual array constructor
72 virtual void* NewArray(Int_t nElements) const { return new Cont_t[nElements]; }
73
74 // Virtual in-place constructor
75 virtual void* NewArray(Int_t nElements, void* memory) const { return new(memory) Cont_t[nElements]; }
76
77 // Virtual array constructor
78 virtual TClass::ObjectPtr NewObjectArray(Int_t nElements) const { return {new Cont_t[nElements], nullptr}; }
79
80 // Virtual in-place constructor
81 virtual TClass::ObjectPtr NewObjectArray(Int_t nElements, void* memory) const { return {new(memory) Cont_t[nElements], nullptr}; }
82
83 // Virtual destructor
84 virtual void Destructor(void* p, Bool_t dtorOnly = kFALSE) const;
85
86 // Virtual array destructor
87 virtual void DeleteArray(void* p, Bool_t dtorOnly = kFALSE) const;
88
89 // TVirtualCollectionProxy overload: Return the sizeof the collection object.
90 virtual UInt_t Sizeof() const { return sizeof(Cont_t); }
91
92 // Return the address of the value at index 'idx'
93 virtual void *At(UInt_t idx);
94
95 // Clear the container
96 virtual void Clear(const char *opt = "");
97
98 // Resize the container
99 virtual void Resize(UInt_t n, Bool_t force_delete);
100
101 // Return the current size of the container
102 virtual UInt_t Size() const;
103
104 // Block allocation of containees
105 virtual void* Allocate(UInt_t n, Bool_t forceDelete);
106
107 // Block commit of containees
108 virtual void Commit(void* env);
109
110 // Insert data into the container where data is a C-style array of the actual type contained in the collection
111 // of the given size. For associative container (map, etc.), the data type is the pair<key,value>.
112 virtual void Insert(const void *data, void *container, size_t size);
113
114 // Read portion of the streamer
115 virtual void ReadBuffer(TBuffer &buff, void *pObj);
116 virtual void ReadBuffer(TBuffer &buff, void *pObj, const TClass *onfile);
117
118 // Streamer for I/O handling
119 virtual void Streamer(TBuffer &refBuffer);
120
121 // Streamer I/O overload
122 virtual void Streamer(TBuffer &buff, void *pObj, int siz) {
123 TGenCollectionProxy::Streamer(buff,pObj,siz);
124 }
125
126 // Check validity of the proxy itself
127 Bool_t IsValid() const;
128};
129
130#endif
int Int_t
Definition: CPyCppyy.h:43
unsigned int UInt_t
Definition: CPyCppyy.h:44
#define b(i)
Definition: RSha256.hxx:100
const Bool_t kFALSE
Definition: RtypesCore.h:90
bool Bool_t
Definition: RtypesCore.h:61
Buffer base class used for serializing objects.
Definition: TBuffer.h:42
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition: TClass.h:80
Streamer around an arbitrary STL like container, which implements basic container functionality.
virtual TGenCollectionProxy * InitializeEx(Bool_t silent)
Proxy initializer.
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...
virtual void Streamer(TBuffer &buff, void *pObj, int siz)
Streamer I/O overload.
virtual void DeleteArray(void *p, Bool_t dtorOnly=kFALSE) const
virtual void Streamer(TBuffer &refBuffer)
Streamer Function.
virtual TClass::ObjectPtr NewObjectArray(Int_t nElements, void *memory) const
void Expand(UInt_t nCurr, UInt_t left)
virtual void Destructor(void *p, Bool_t dtorOnly=kFALSE) const
virtual TClass::ObjectPtr NewObject(void *memory) const
virtual TClass::ObjectPtr NewObject() const
void WriteItems(int nElements, TBuffer &b)
virtual void ReadBuffer(TBuffer &buff, void *pObj)
virtual void * New(void *memory) const
virtual void Commit(void *env)
Commit the change.
virtual UInt_t Sizeof() const
Return the sizeof the collection object.
TEmulatedCollectionProxy & operator=(const TEmulatedCollectionProxy &)
virtual void * NewArray(Int_t nElements, void *memory) const
virtual void Resize(UInt_t n, Bool_t force_delete)
Resize the container.
void Shrink(UInt_t nCurr, UInt_t left, Bool_t force)
virtual void Clear(const char *opt="")
Clear the emulated collection.
virtual TVirtualCollectionProxy * Generate() const
Virtual copy constructor.
virtual TClass::ObjectPtr NewObjectArray(Int_t nElements) const
virtual void * Allocate(UInt_t n, Bool_t forceDelete)
Allocate the needed space.
virtual UInt_t Size() const
Return the current size of the container.
void ReadItems(int nElements, TBuffer &b)
TEmulatedCollectionProxy(const TEmulatedCollectionProxy &copy)
virtual void * At(UInt_t idx)
Return the address of the value at index 'idx'.
virtual void * NewArray(Int_t nElements) const
Proxy around an arbitrary container, which implements basic functionality and iteration.
virtual void Streamer(TBuffer &refBuffer)
Streamer Function.
const Int_t n
Definition: legend1.C:16