00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include "TError.h"
00013 #include "TLeafObject.h"
00014 #include "TInterpreter.h"
00015 #include "TVirtualRefProxy.h"
00016 #include "TFormLeafInfoReference.h"
00017
00018
00019
00020
00021
00022
00023
00024 TFormLeafInfoReference::TFormLeafInfoReference(TClass* cl, TStreamerElement* e, int off)
00025 : TFormLeafInfo(cl,off,e), fProxy(0), fBranch(0)
00026 {
00027
00028
00029 TVirtualRefProxy* p = cl->GetReferenceProxy();
00030 if ( !p ) {
00031 ::Error("TFormLeafInfoReference","No reference proxy for class %s availible",cl->GetName());
00032 return;
00033 }
00034 fProxy = p->Clone();
00035 }
00036
00037
00038 TFormLeafInfoReference::TFormLeafInfoReference(const TFormLeafInfoReference& org)
00039 : TFormLeafInfo(org), fProxy(0), fBranch(org.fBranch)
00040 {
00041
00042
00043 TVirtualRefProxy* p = org.fProxy;
00044 if ( !p ) {
00045 ::Error("TFormLeafInfoReference","No reference proxy for class %s availible",fClass->GetName());
00046 return;
00047 }
00048 fProxy = p->Clone();
00049 }
00050
00051
00052 TFormLeafInfoReference::~TFormLeafInfoReference()
00053 {
00054
00055
00056 if ( fProxy ) fProxy->Release();
00057 }
00058
00059
00060 TFormLeafInfo* TFormLeafInfoReference::DeepCopy() const
00061 {
00062
00063
00064 return new TFormLeafInfoReference(*this);
00065 }
00066
00067
00068 TClass* TFormLeafInfoReference::GetClass() const
00069 {
00070
00071
00072 return fNext ? fNext->GetClass() : 0;
00073 }
00074
00075
00076 Bool_t TFormLeafInfoReference::HasCounter() const
00077 {
00078
00079
00080 Bool_t result = fProxy ? fProxy->HasCounter() : false;
00081 if (fNext) result |= fNext->HasCounter();
00082 return fCounter!=0 || result;
00083 }
00084
00085 Int_t TFormLeafInfoReference::ReadCounterValue(char *where)
00086 {
00087
00088
00089 Int_t result = 0;
00090 if ( where && HasCounter() ) {
00091 where = (char*)fProxy->GetPreparedReference(where);
00092 if ( where ) {
00093 return fProxy->GetCounterValue(this, where);
00094 }
00095 }
00096 gInterpreter->ClearStack();
00097
00098 return result;
00099 }
00100
00101
00102 Int_t TFormLeafInfoReference::GetCounterValue(TLeaf* leaf) {
00103
00104
00105 if ( HasCounter() ) {
00106 char *thisobj = 0;
00107 Int_t instance = 0;
00108 if (leaf->InheritsFrom(TLeafObject::Class()) ) {
00109 thisobj = (char*)((TLeafObject*)leaf)->GetObject();
00110 } else {
00111 thisobj = GetObjectAddress((TLeafElement*)leaf, instance);
00112 }
00113 return ReadCounterValue(thisobj);
00114 }
00115 return 0;
00116 }
00117
00118
00119 TClass* TFormLeafInfoReference::GetValueClass(TLeaf* leaf)
00120 {
00121
00122
00123 return this->GetValueClass(this->GetLocalValuePointer(leaf,0));
00124 }
00125
00126
00127 TClass* TFormLeafInfoReference::GetValueClass(void* obj)
00128 {
00129
00130
00131 return fProxy ? fProxy->GetValueClass(obj) : 0;
00132 }
00133
00134
00135 Bool_t TFormLeafInfoReference::Update()
00136 {
00137
00138
00139 Bool_t res = this->TFormLeafInfo::Update();
00140 if ( fProxy ) fProxy->Update();
00141 return res;
00142 }
00143
00144
00145 Double_t TFormLeafInfoReference::GetValue(TLeaf *leaf, Int_t instance)
00146 {
00147
00148
00149 fBranch = leaf->GetBranch();
00150 return TFormLeafInfo::GetValue(leaf, instance);
00151 }
00152
00153
00154 void *TFormLeafInfoReference::GetLocalValuePointer( TLeaf *from, Int_t instance)
00155 {
00156
00157
00158
00159 fBranch = from->GetBranch();
00160 return TFormLeafInfo::GetLocalValuePointer(from, instance);
00161 }
00162
00163
00164 void *TFormLeafInfoReference::GetLocalValuePointer(char *where, Int_t instance)
00165 {
00166
00167
00168 if (where) {
00169 where = (char*)fProxy->GetPreparedReference(where);
00170 if (where) {
00171 void* result = fProxy->GetObject(this, where, instance);
00172 gInterpreter->ClearStack();
00173 return result;
00174 }
00175 }
00176 gInterpreter->ClearStack();
00177 return 0;
00178 }
00179
00180
00181 Double_t TFormLeafInfoReference::ReadValue(char *where, Int_t instance)
00182 {
00183
00184
00185 Double_t result = 0;
00186 if ( where ) {
00187 where = (char*)fProxy->GetPreparedReference(where);
00188 if ( where ) {
00189 void* res = fProxy->GetObject(this, where, instance);
00190 if ( res ) {
00191 result = (fNext) ? fNext->ReadValue((char*)res,instance) : *(Double_t*)res;
00192 }
00193 }
00194 }
00195 gInterpreter->ClearStack();
00196
00197 return result;
00198 }