27 ClassImp(TListOfFunctionTemplates);
32 TListOfFunctionTemplates::TListOfFunctionTemplates(TClass *cl) : fClass(cl),fIds(0),
33 fUnloaded(0),fLastLoadMarker(0)
36 fUnloaded =
new THashList;
42 TListOfFunctionTemplates::~TListOfFunctionTemplates()
53 void TListOfFunctionTemplates::MapObject(TObject *obj)
55 TFunctionTemplate *f =
dynamic_cast<TFunctionTemplate*
>(obj);
57 fIds->Add((Long64_t)f->GetDeclId(),(Long64_t)f);
64 void TListOfFunctionTemplates::AddFirst(TObject *obj)
66 THashList::AddFirst(obj);
77 void TListOfFunctionTemplates::AddFirst(TObject *obj, Option_t *opt)
79 THashList::AddFirst(obj,opt);
86 void TListOfFunctionTemplates::AddLast(TObject *obj)
88 THashList::AddLast(obj);
99 void TListOfFunctionTemplates::AddLast(TObject *obj, Option_t *opt)
101 THashList::AddLast(obj, opt);
108 void TListOfFunctionTemplates::AddAt(TObject *obj, Int_t idx)
110 THashList::AddAt(obj, idx);
117 void TListOfFunctionTemplates::AddAfter(
const TObject *after, TObject *obj)
119 THashList::AddAfter(after, obj);
126 void TListOfFunctionTemplates::AddAfter(TObjLink *after, TObject *obj)
128 THashList::AddAfter(after, obj);
135 void TListOfFunctionTemplates::AddBefore(
const TObject *before, TObject *obj)
137 THashList::AddBefore(before, obj);
144 void TListOfFunctionTemplates::AddBefore(TObjLink *before, TObject *obj)
146 THashList::AddBefore(before, obj);
154 void TListOfFunctionTemplates::Clear(Option_t *option)
156 fUnloaded->Clear(option);
158 THashList::Clear(option);
164 void TListOfFunctionTemplates::Delete(Option_t *option )
166 fUnloaded->Delete(option);
168 THashList::Delete(option);
175 TObject *TListOfFunctionTemplates::FindObject(
const char *name)
const
177 TObject *result = THashList::FindObject(name);
180 R__LOCKGUARD(gInterpreterMutex);
182 TInterpreter::DeclId_t decl;
183 if (fClass) decl = gInterpreter->GetFunctionTemplate(fClass->GetClassInfo(),name);
184 else decl = gInterpreter->GetFunctionTemplate(0,name);
185 if (decl) result =
const_cast<TListOfFunctionTemplates*
>(
this)->Get(decl);
194 TList* TListOfFunctionTemplates::GetListForObjectNonConst(
const char* name)
196 R__LOCKGUARD(gInterpreterMutex);
198 TList* overloads = (TList*)fOverloads.FindObject(name);
200 Bool_t wasEmpty =
true;
202 overloads =
new TList();
203 overloads->SetName(name);
204 fOverloads.Add(overloads);
206 TIter iOverload(overloads);
207 while (TFunctionTemplate* over = (TFunctionTemplate*)iOverload()) {
209 overloadsSet.Add((Long64_t)(ULong64_t)over->GetDeclId(),
210 (Long64_t)(ULong64_t)over);
215 std::vector<DeclId_t> overloadDecls;
216 ClassInfo_t* ci = fClass ? fClass->GetClassInfo() : 0;
217 gInterpreter->GetFunctionOverloads(ci, name, overloadDecls);
218 for (std::vector<DeclId_t>::const_iterator iD = overloadDecls.begin(),
219 eD = overloadDecls.end(); iD != eD; ++iD) {
220 TFunctionTemplate* over = Get(*iD);
221 if (wasEmpty || !overloadsSet.GetValue((Long64_t)(ULong64_t)over->GetDeclId())) {
222 overloads->Add(over);
233 TList* TListOfFunctionTemplates::GetListForObject(
const char* name)
const
235 return const_cast<TListOfFunctionTemplates*
>(
this)->GetListForObjectNonConst(name);
242 TList* TListOfFunctionTemplates::GetListForObject(
const TObject* obj)
const
245 return const_cast<TListOfFunctionTemplates*
>(
this)
246 ->GetListForObjectNonConst(obj->GetName());
253 TFunctionTemplate *TListOfFunctionTemplates::Get(DeclId_t
id)
257 TFunctionTemplate *f = (TFunctionTemplate*)fIds->GetValue((Long64_t)
id);
260 if (!gInterpreter->ClassInfo_Contains(fClass->GetClassInfo(),id))
return 0;
262 if (!gInterpreter->ClassInfo_Contains(0,
id))
return 0;
265 R__LOCKGUARD(gInterpreterMutex);
267 FuncTempInfo_t *m = gInterpreter->FuncTempInfo_Factory(
id);
271 gInterpreter->FuncTempInfo_Name(m, name);
272 TFunctionTemplate* update = (TFunctionTemplate*)fUnloaded->FindObject(name);
274 fUnloaded->Remove(update);
279 if (fClass) f =
new TFunctionTemplate(m, fClass);
280 else f =
new TFunctionTemplate(m, 0);
284 THashList::AddLast(f);
285 fIds->Add((Long64_t)
id,(Long64_t)f);
293 void TListOfFunctionTemplates::UnmapObject(TObject *obj)
295 TFunctionTemplate *f =
dynamic_cast<TFunctionTemplate*
>(obj);
297 fIds->Remove((Long64_t)f->GetDeclId());
310 void TListOfFunctionTemplates::RecursiveRemove(TObject *obj)
314 THashList::RecursiveRemove(obj);
315 fUnloaded->RecursiveRemove(obj);
323 TObject* TListOfFunctionTemplates::Remove(TObject *obj)
327 found = THashList::Remove(obj);
329 found = fUnloaded->Remove(obj);
332 if (found)
return obj;
339 TObject* TListOfFunctionTemplates::Remove(TObjLink *lnk)
343 TObject *obj = lnk->GetObject();
345 THashList::Remove(lnk);
346 fUnloaded->Remove(obj);
356 void TListOfFunctionTemplates::Load()
358 if (fClass && fClass->GetClassInfo() == 0)
return;
360 R__LOCKGUARD(gInterpreterMutex);
362 ULong64_t currentTransaction = gInterpreter->GetInterpreterStateMarker();
363 if (currentTransaction == fLastLoadMarker) {
366 fLastLoadMarker = currentTransaction;
368 gInterpreter->LoadFunctionTemplates(fClass);
377 void TListOfFunctionTemplates::Unload()
379 TObjLink *lnk = FirstLink();
381 TFunctionTemplate *func = (TFunctionTemplate*)lnk->GetObject();
383 fIds->Remove((Long64_t)func->GetDeclId());
384 fUnloaded->Add(func);
398 void TListOfFunctionTemplates::Unload(TFunctionTemplate *func)
400 if (THashList::Remove(func)) {
404 fIds->Remove((Long64_t)func->GetDeclId());
405 fUnloaded->Add(func);