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
16#include <vector>
17
19
20 // Friend declaration
21 friend class TCollectionProxy;
22
23public:
24 // Container type definition
25 typedef std::vector<char> Cont_t;
26 // Pointer to container type
27 typedef Cont_t *PCont_t;
28protected:
29
30 // Some hack to avoid const-ness
32
33 // Object input streamer
34 void ReadItems(int nElements, TBuffer &b);
35
36 // Object output streamer
37 void WriteItems(int nElements, TBuffer &b);
38
39 // Shrink the container
40 void Shrink(UInt_t nCurr, UInt_t left, Bool_t force);
41
42 // Expand the container
43 void Expand(UInt_t nCurr, UInt_t left);
44
45private:
47
48public:
49 // Virtual copy constructor
50 virtual TVirtualCollectionProxy* Generate() const;
51
52 // Copy constructor
54
55 // Initializing constructor
56 TEmulatedCollectionProxy(const char* cl_name, Bool_t silent);
57
58 // Standard destructor
60
61 // Virtual constructor
62 virtual void* New() const { return new Cont_t; }
63
64 // Virtual in-place constructor
65 virtual void* New(void* memory) const { return new(memory) Cont_t; }
66
67 // Virtual constructor
68 virtual TClass::ObjectPtr NewObject() const { return {new Cont_t, nullptr}; }
69
70 // Virtual in-place constructor
71 virtual TClass::ObjectPtr NewObject(void* memory) const { return {new(memory) Cont_t, nullptr}; }
72
73 // Virtual array constructor
74 virtual void* NewArray(Int_t nElements) const { return new Cont_t[nElements]; }
75
76 // Virtual in-place constructor
77 virtual void* NewArray(Int_t nElements, void* memory) const { return new(memory) Cont_t[nElements]; }
78
79 // Virtual array constructor
80 virtual TClass::ObjectPtr NewObjectArray(Int_t nElements) const { return {new Cont_t[nElements], nullptr}; }
81
82 // Virtual in-place constructor
83 virtual TClass::ObjectPtr NewObjectArray(Int_t nElements, void* memory) const { return {new(memory) Cont_t[nElements], nullptr}; }
84
85 // Virtual destructor
86 virtual void Destructor(void* p, Bool_t dtorOnly = kFALSE) const;
87
88 // Virtual array destructor
89 virtual void DeleteArray(void* p, Bool_t dtorOnly = kFALSE) const;
90
91 // TVirtualCollectionProxy overload: Return the sizeof the collection object.
92 virtual UInt_t Sizeof() const { return sizeof(Cont_t); }
93
94 // Return the address of the value at index 'idx'
95 virtual void *At(UInt_t idx);
96
97 // Clear the container
98 virtual void Clear(const char *opt = "");
99
100 // Resize the container
101 virtual void Resize(UInt_t n, Bool_t force_delete);
102
103 // Return the current size of the container
104 virtual UInt_t Size() const;
105
106 // Block allocation of containees
107 virtual void* Allocate(UInt_t n, Bool_t forceDelete);
108
109 // Block commit of containees
110 virtual void Commit(void* env);
111
112 // Insert data into the container where data is a C-style array of the actual type contained in the collection
113 // of the given size. For associative container (map, etc.), the data type is the pair<key,value>.
114 virtual void Insert(const void *data, void *container, size_t size);
115
116 // Read portion of the streamer
117 virtual void ReadBuffer(TBuffer &buff, void *pObj);
118 virtual void ReadBuffer(TBuffer &buff, void *pObj, const TClass *onfile);
119
120 // Streamer for I/O handling
121 virtual void Streamer(TBuffer &refBuffer);
122
123 // Streamer I/O overload
124 virtual void Streamer(TBuffer &buff, void *pObj, int siz) {
125 TGenCollectionProxy::Streamer(buff,pObj,siz);
126 }
127
128 // Check validity of the proxy itself
129 Bool_t IsValid() const;
130};
131
132#endif
int Int_t
Definition: CPyCppyy.h:43
unsigned int UInt_t
Definition: CPyCppyy.h:44
#define b(i)
Definition: RSha256.hxx:100
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
const Bool_t kFALSE
Definition: RtypesCore.h:101
bool Bool_t
Definition: RtypesCore.h:63
Buffer base class used for serializing objects.
Definition: TBuffer.h:43
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