Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TClonesArray.h
Go to the documentation of this file.
1// @(#)root/cont:$Id$
2// Author: Rene Brun 11/02/96
3
4/*************************************************************************
5 * Copyright (C) 1995-2000, 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
12#ifndef ROOT_TClonesArray
13#define ROOT_TClonesArray
14
15
16//////////////////////////////////////////////////////////////////////////
17// //
18// TClonesArray //
19// //
20// An array of clone TObjects. The array expands automatically when //
21// adding elements (shrinking can be done explicitly). //
22// //
23//////////////////////////////////////////////////////////////////////////
24
25#include "TObjArray.h"
26
27class TClass;
28
29class TClonesArray : public TObjArray {
30
31protected:
32 TClass *fClass; //!Pointer to the class of the elements
33 TObjArray *fKeep; //!Saved copies of pointers to objects
34
35public:
37 kBypassStreamer = BIT(12), // Class Streamer not called (default)
38 kForgetBits = BIT(15) // Do not create branches for fBits, fUniqueID
39 };
40
42 TClonesArray(const char *classname, Int_t size = 1000, Bool_t call_dtor = kFALSE);
43 TClonesArray(const TClass *cl, Int_t size = 1000, Bool_t call_dtor = kFALSE);
44 TClonesArray(const TClonesArray& tc);
45 virtual ~TClonesArray();
47 void Compress() override;
48 void Clear(Option_t *option="") override;
49 void Delete(Option_t *option="") override;
50 void Expand(Int_t newSize) override;
51 virtual void ExpandCreate(Int_t n);
52 virtual void ExpandCreateFast(Int_t n);
53 TClass *GetClass() const { return fClass; }
54 void SetOwner(Bool_t enable = kTRUE) override;
55
56 void AddFirst(TObject *) override { MayNotUse("AddFirst"); }
57 void AddLast(TObject *) override { MayNotUse("AddLast"); }
58 void AddAt(TObject *, Int_t) override { MayNotUse("AddAt"); }
59 void AddAtAndExpand(TObject *, Int_t) override { MayNotUse("AddAtAndExpand"); }
60 Int_t AddAtFree(TObject *) override { MayNotUse("AddAtFree"); return 0; }
61 void AddAfter(const TObject *, TObject *) override { MayNotUse("AddAfter"); }
62 void AddBefore(const TObject *, TObject *) override { MayNotUse("AddBefore"); }
63 void BypassStreamer(Bool_t bypass=kTRUE);
66 TObject *ConstructedAt(Int_t idx, Option_t *clear_options);
67 void SetClass(const char *classname,Int_t size=1000);
68 void SetClass(const TClass *cl,Int_t size=1000);
69
71 void AbsorbObjects(TClonesArray *tc, Int_t idx1, Int_t idx2);
72 void MultiSort(Int_t nTCs, TClonesArray** tcs, Int_t upto = kMaxInt);
73 TObject *RemoveAt(Int_t idx) override;
74 TObject *Remove(TObject *obj) override;
75 void RemoveRange(Int_t idx1, Int_t idx2) override;
76 void Sort(Int_t upto = kMaxInt) override;
77
78 TObject *New(Int_t idx);
79 TObject *AddrAt(Int_t idx);
80 TObject *&operator[](Int_t idx) override;
81 TObject *operator[](Int_t idx) const override;
82
83 ClassDefOverride(TClonesArray,4) //An array of clone objects
84};
85
87{
88 return operator[](idx);
89}
90
91#endif
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
bool Bool_t
Definition RtypesCore.h:63
int Int_t
Definition RtypesCore.h:45
constexpr Int_t kMaxInt
Definition RtypesCore.h:112
constexpr Bool_t kFALSE
Definition RtypesCore.h:101
constexpr Bool_t kTRUE
Definition RtypesCore.h:100
const char Option_t
Definition RtypesCore.h:66
#define BIT(n)
Definition Rtypes.h:85
#define ClassDefOverride(name, id)
Definition Rtypes.h:341
Option_t Option_t option
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition TClass.h:81
An array of clone (identical) objects.
TObjArray * fKeep
Pointer to the class of the elements.
TObject *& operator[](Int_t idx) override
Return pointer to reserved area in which a new object of clones class can be constructed.
void BypassStreamer(Bool_t bypass=kTRUE)
When the kBypassStreamer bit is set, the automatically generated Streamer can call directly TClass::W...
void AddAfter(const TObject *, TObject *) override
void AddLast(TObject *) override
virtual ~TClonesArray()
Delete a clones array.
void AbsorbObjects(TClonesArray *tc)
Directly move the object pointers from tc without cloning (copying).
virtual void ExpandCreateFast(Int_t n)
Expand or shrink the array to n elements and create the clone objects by calling their default ctor.
void AddFirst(TObject *) override
void AddAtAndExpand(TObject *, Int_t) override
Add object at position idx.
void Expand(Int_t newSize) override
Expand or shrink the array to newSize elements.
TObject * RemoveAt(Int_t idx) override
Remove object at index idx.
void AddBefore(const TObject *, TObject *) override
TClass * GetClass() const
TObject * AddrAt(Int_t idx)
void SetClass(const char *classname, Int_t size=1000)
see TClonesArray::SetClass(const TClass*)
EStatusBits
Saved copies of pointers to objects.
Bool_t CanBypassStreamer() const
void Clear(Option_t *option="") override
Clear the clones array.
void Delete(Option_t *option="") override
Clear the clones array.
TClass * fClass
TClonesArray & operator=(const TClonesArray &tc)
Assignment operator.
void Sort(Int_t upto=kMaxInt) override
If objects in array are sortable (i.e.
void RemoveRange(Int_t idx1, Int_t idx2) override
Remove objects from index idx1 to idx2 included.
TObject * ConstructedAt(Int_t idx)
Get an object at index 'idx' that is guaranteed to have been constructed.
void AddAt(TObject *, Int_t) override
virtual void ExpandCreate(Int_t n)
Expand or shrink the array to n elements and create the clone objects by calling their default ctor.
TClonesArray()
Default Constructor.
void Compress() override
Remove empty slots from array.
void SetOwner(Bool_t enable=kTRUE) override
A TClonesArray is always the owner of the object it contains.
TObject * New(Int_t idx)
Create an object of type fClass with the default ctor at the specified index.
TObject * Remove(TObject *obj) override
Remove object from array.
Int_t AddAtFree(TObject *) override
Return the position of the new object.
void MultiSort(Int_t nTCs, TClonesArray **tcs, Int_t upto=kMaxInt)
Sort multiple TClonesArrays simultaneously with this array.
An array of TObjects.
Definition TObjArray.h:31
Mother of all ROOT objects.
Definition TObject.h:41
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition TObject.h:201
void MayNotUse(const char *method) const
Use this method to signal that a method (defined in a base class) may not be called in a derived clas...
Definition TObject.cxx:1029
const Int_t n
Definition legend1.C:16