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