Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TClassRef.cxx
Go to the documentation of this file.
1// @(#)root/meta:$Id$
2// Author: Philippe Canal 15/03/2005
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/** \class TClassRef
13TClassRef is used to implement a permanent reference to a TClass
14object. In particular this reference will change if and when the
15TClass object is regenerated. This regeneration usually happens
16when a library containing the described class is loaded after a
17file containing an instance of this class has been opened.
18
19The references kept track of using an intrusive double linked list.
20The intrusive list is maintained by TClass::AddRef and
21TClass::RemoveRef. The 'start' of the list is held in
22TClass::fRefStart.
23*/
24
25#include "TClassRef.h"
26
27////////////////////////////////////////////////////////////////////////////////
28/// Copy ctor, increases reference count to original TClass object.
29
31 fClassName(org.fClassName), fClassPtr(org.fClassPtr)
32{
33}
34
35////////////////////////////////////////////////////////////////////////////////
36/// Create reference to specified class name, but don't set referenced
37/// class object.
38
39TClassRef::TClassRef(const char *classname) :
40 fClassName(classname), fClassPtr(nullptr)
41{
42}
43
44////////////////////////////////////////////////////////////////////////////////
45/// Add reference to specified class object.
46
47TClassRef::TClassRef(TClass *cl) : fClassPtr(nullptr)
48{
49 if (cl) {
50 fClassName = cl->GetName();
52 }
53}
54
55////////////////////////////////////////////////////////////////////////////////
56/// Assignment operator implementation, increases reference count to original class object.
57/// This routines assumes that the copy actually need to be done.
58
60{
62 fClassPtr = rhs.fClassPtr;
63}
64
65////////////////////////////////////////////////////////////////////////////////
66/// Assignment operator, increases reference count to original class object.
67/// This routines assumes that the copy actually need to be done.
68
70{
71 if (rhs) {
73 fClassName = rhs->GetName();
74 } else {
75 fClassPtr = nullptr;
76 fClassName.clear();
77 }
78}
79
80////////////////////////////////////////////////////////////////////////////////
81/// Return the current TClass object corresponding to fClassName.
82
84{
85 if (fClassPtr && *fClassPtr) return *fClassPtr;
86 if (fClassName.size()==0) return nullptr;
87
88 TClass *cl = TClass::GetClass(fClassName.c_str());
89 if (cl) {
90 (const_cast<TClassRef*>(this))->fClassPtr = cl->GetPersistentRef();
91 return cl;
92 } else {
93 return nullptr;
94 }
95}
96
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t org
TClassRef is used to implement a permanent reference to a TClass object.
Definition TClassRef.h:28
TClass * InternalGetClass() const
Return the current TClass object corresponding to fClassName.
Definition TClassRef.cxx:83
TClass *const * fClassPtr
Definition TClassRef.h:32
std::string fClassName
Definition TClassRef.h:31
void Assign(const TClassRef &)
Assignment operator implementation, increases reference count to original class object.
Definition TClassRef.cxx:59
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition TClass.h:81
TClass *const * GetPersistentRef() const
Definition TClass.h:481
static TClass * GetClass(const char *name, Bool_t load=kTRUE, Bool_t silent=kFALSE)
Static method returning pointer to TClass of the specified class name.
Definition TClass.cxx:2968
const char * GetName() const override
Returns name of object.
Definition TNamed.h:47