Logo ROOT   6.18/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
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 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
#define b(i)
Definition: RSha256.hxx:100
int Int_t
Definition: RtypesCore.h:41
unsigned int UInt_t
Definition: RtypesCore.h:42
const Bool_t kFALSE
Definition: RtypesCore.h:88
bool Bool_t
Definition: RtypesCore.h:59
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:75
Streamer around an arbitrary STL like container, which implements basic container functionality.
virtual TGenCollectionProxy * InitializeEx(Bool_t silent)
Proxy initializer.
TEmulatedCollectionProxy & operator=(const TEmulatedCollectionProxy &)
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.
void Expand(UInt_t nCurr, UInt_t left)
virtual void Destructor(void *p, Bool_t dtorOnly=kFALSE) const
void WriteItems(int nElements, TBuffer &b)
virtual void ReadBuffer(TBuffer &buff, void *pObj)
virtual void Commit(void *env)
Commit the change.
virtual void * New(void *memory) const
virtual UInt_t Sizeof() const
Return the sizeof the collection object.
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 void * Allocate(UInt_t n, Bool_t forceDelete)
Allocate the needed space.
virtual UInt_t Size() const
Return the current size of the container.
virtual void * NewArray(Int_t nElements, void *memory) const
void ReadItems(int nElements, TBuffer &b)
virtual void * NewArray(Int_t nElements) const
TEmulatedCollectionProxy(const TEmulatedCollectionProxy &copy)
virtual void * At(UInt_t idx)
Return the address of the value at index 'idx'.
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