ROOT  6.06/09
Reference Guide
TRef.h
Go to the documentation of this file.
1 // @(#)root/cont:$Id$
2 // Author: Rene Brun 28/09/2001
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_TRef
13 #define ROOT_TRef
14 
15 
16 //////////////////////////////////////////////////////////////////////////
17 // //
18 // TRef //
19 // //
20 // Persistent Reference link to a TObject //
21 // //
22 //////////////////////////////////////////////////////////////////////////
23 
24 
25 #ifndef ROOT_TObject
26 #include "TObject.h"
27 #endif
28 
29 class TProcessID;
30 class TFile;
31 class TExec;
32 class TObjArray;
33 
34 class TRef : public TObject {
35 
36 protected:
37  TProcessID *fPID; //!Pointer to ProcessID when TRef was written
38 
39  static TObjArray *fgExecs; //List of execs
40  static TObject *fgObject; //In: this, Out: pointer to object (used by Action on Demand)
41 
42 public:
43  //status bits
44  enum { kNotComputed = BIT(12)};
45 
46  TRef(): fPID(0) { }
47  TRef(TObject *obj);
48  TRef(const TRef &ref);
49  void operator=(TObject *obj);
50  TRef& operator=(const TRef &ref);
51  virtual ~TRef() { }
52 
53  TObject *GetObject() const;
54  TProcessID *GetPID() const {return fPID;}
55  Bool_t IsValid() const {return GetUniqueID()!=0 ? kTRUE : kFALSE;}
56  virtual void SetAction(const char *name);
57  virtual void SetAction(TObject *parent);
58 
59  static void SetObject(TObject *obj);
60  static void SetStaticObject(TObject *obj);
61  static Int_t AddExec(const char *name);
62  static TObjArray *GetListOfExecs();
63  static TObject *GetStaticObject();
64 
65  friend Bool_t operator==(const TRef &r1, const TRef &r2);
66  friend Bool_t operator!=(const TRef &r1, const TRef &r2);
67 
68  ClassDef(TRef,1) //Persistent Reference link to a TObject
69 };
70 
71 #endif
An array of TObjects.
Definition: TObjArray.h:39
#define BIT(n)
Definition: Rtypes.h:120
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
Definition: TFile.h:45
static void SetStaticObject(TObject *obj)
Static function to set the object found on the Action on Demand function.
Definition: TRef.cxx:476
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kFALSE
Definition: Rtypes.h:92
virtual ~TRef()
Definition: TRef.h:51
static void SetObject(TObject *obj)
static Obsolete function kept for back compatibility.
Definition: TRef.cxx:464
Persistent Reference link to a TObject A TRef is a lightweight object pointing to any TObject...
Definition: TRef.h:34
Bool_t IsValid() const
Definition: TRef.h:55
static TObject * GetStaticObject()
Returns the static object.
Definition: TRef.cxx:456
#define ClassDef(name, id)
Definition: Rtypes.h:254
TProcessID * GetPID() const
Definition: TRef.h:54
TProcessID * fPID
Definition: TRef.h:37
static TObject * fgObject
Definition: TRef.h:40
A TProcessID identifies a ROOT job in a unique way in time and space.
Definition: TProcessID.h:34
static Int_t AddExec(const char *name)
If Exec with name does not exist in the list of Execs, it is created.
Definition: TRef.cxx:339
static TObjArray * GetListOfExecs()
Return a pointer to the static TObjArray holding the list of Execs.
Definition: TRef.cxx:359
static TObjArray * fgExecs
Pointer to ProcessID when TRef was written.
Definition: TRef.h:39
unsigned int r1[N_CITIES]
Definition: simanTSP.cxx:321
friend Bool_t operator==(const TRef &r1, const TRef &r2)
Return kTRUE if r1 and r2 point to the same object.
Definition: TRef.cxx:320
void operator=(TObject *obj)
Assign object to reference.
Definition: TRef.cxx:277
friend Bool_t operator!=(const TRef &r1, const TRef &r2)
Return kTRUE if r1 and r2 do not point to the same object.
Definition: TRef.cxx:329
virtual UInt_t GetUniqueID() const
Return the unique object id.
Definition: TObject.cxx:433
#define name(a, b)
Definition: linkTestLib0.cpp:5
Mother of all ROOT objects.
Definition: TObject.h:58
TObject * GetObject() const
Return a pointer to the referenced object.
Definition: TRef.cxx:377
virtual void SetAction(const char *name)
Store the exec number (in the ROOT list of Execs) into the fBits of this TRef.
Definition: TRef.cxx:427
TRef()
Definition: TRef.h:46
TExec is a utility class that can be used to execute a C++ command when some event happens in a pad...
Definition: TExec.h:30
const Bool_t kTRUE
Definition: Rtypes.h:91
TObject * obj
unsigned int r2[N_CITIES]
Definition: simanTSP.cxx:322