How to get all TObject with a certain name

Dear experts

I want to get the reference of all instantiated object of the same class, is there a way to do it?
For example I have a class MyObject inherited from TObject, and I created 2 instances of MyObject, obj1 and obj2.

Hi,

Are you looking for all open files as the title suggests or all objects?

Cheers,
D

Ah sorry I messed the title and contents, I edited title now.
I’m looking for some certain objects.

Hi,

I would not know how to do that and that might be bad design in C++: is it possible for you to register somehow these instances, e.g. through a factory pattern?

Cheers,
D

I found I can manage them by adding them into gROOT->GetListOfSpecials()->Add(this) then I can retrieve them :slight_smile:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.