Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
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 "Rtypes.h"
26 
27 #include "TObjArray.h"
28 
29 class TClass;
30 
31 
32 class TClonesArray : public TObjArray {
33 
34 protected:
35  TClass *fClass; //!Pointer to the class of the elements
36  TObjArray *fKeep; //!Saved copies of pointers to objects
37 
38 public:
39  enum EStatusBits {
40  kBypassStreamer = BIT(12), // Class Streamer not called (default)
41  kForgetBits = BIT(15) // Do not create branches for fBits, fUniqueID
42  };
43 
44  TClonesArray();
45  TClonesArray(const char *classname, Int_t size = 1000, Bool_t call_dtor = kFALSE);
46  TClonesArray(const TClass *cl, Int_t size = 1000, Bool_t call_dtor = kFALSE);
47  TClonesArray(const TClonesArray& tc);
48  virtual ~TClonesArray();
49  TClonesArray& operator=(const TClonesArray& tc);
50  virtual void Compress();
51  virtual void Clear(Option_t *option="");
52  virtual void Delete(Option_t *option="");
53  virtual void Expand(Int_t newSize);
54  virtual void ExpandCreate(Int_t n);
55  virtual void ExpandCreateFast(Int_t n);
56  TClass *GetClass() const { return fClass; }
57  virtual void SetOwner(Bool_t enable = kTRUE);
58 
59  void AddFirst(TObject *) { MayNotUse("AddFirst"); }
60  void AddLast(TObject *) { MayNotUse("AddLast"); }
61  void AddAt(TObject *, Int_t) { MayNotUse("AddAt"); }
62  void AddAtAndExpand(TObject *, Int_t) { MayNotUse("AddAtAndExpand"); }
63  Int_t AddAtFree(TObject *) { MayNotUse("AddAtFree"); return 0; }
64  void AddAfter(const TObject *, TObject *) { MayNotUse("AddAfter"); }
65  void AddBefore(const TObject *, TObject *) { MayNotUse("AddBefore"); }
66  void BypassStreamer(Bool_t bypass=kTRUE);
67  Bool_t CanBypassStreamer() const { return TestBit(kBypassStreamer); }
68  TObject *ConstructedAt(Int_t idx);
69  TObject *ConstructedAt(Int_t idx, Option_t *clear_options);
70  void SetClass(const char *classname,Int_t size=1000);
71  void SetClass(const TClass *cl,Int_t size=1000);
72 
73  void AbsorbObjects(TClonesArray *tc);
74  void AbsorbObjects(TClonesArray *tc, Int_t idx1, Int_t idx2);
75  void MultiSort(Int_t nTCs, TClonesArray** tcs, Int_t upto = kMaxInt);
76  virtual TObject *RemoveAt(Int_t idx);
77  virtual TObject *Remove(TObject *obj);
78  virtual void RemoveRange(Int_t idx1, Int_t idx2);
79  virtual void Sort(Int_t upto = kMaxInt);
80 
81  TObject *New(Int_t idx);
82  TObject *AddrAt(Int_t idx);
83  TObject *&operator[](Int_t idx);
84  TObject *operator[](Int_t idx) const;
85 
86  ClassDef(TClonesArray,4) //An array of clone objects
87 };
88 
89 inline TObject *TClonesArray::AddrAt(Int_t idx)
90 {
91  return operator[](idx);
92 }
93 
94 #endif