Recent

Author Topic: autoupdating my classlist  (Read 477 times)

Paolo

  • Hero Member
  • *****
  • Posts: 714
autoupdating my classlist
« on: February 17, 2024, 01:07:12 pm »
Hello, I am trying to implement an automatic updating of myclass

I have this

Code: Pascal  [Select][+][-]
  1. Type
  2.   TMyObj = class(TObject)
  3.   end;
  4.  
  5.   TMyChildL1_1 = class(TMyObj)
  6.   end;
  7.  
  8.   TMyChildL1_2 = class(TMyObj)
  9.   end;
  10.  
  11.   TMyChildL2_1 = class(TMyChildL1_1)
  12.   end;
  13.  
  14.   TmyChildL2_2 = class(TmyChildL1_2)
  15.   end;
  16. ...
  17.  

and so on..
then I have

Code: Pascal  [Select][+][-]
  1.   TMyClassList = class(TClassList)
  2.  
  3.   end;
  4.  
  5. var
  6.   Myclass : TMyClassList;
  7. ...
  8. Initialization
  9.   MYClass:=TmyClassList.Create;
  10.   MyClass.Add(TMyObj);
  11.   MyClass.Add(TMyChildL1_1);
  12.   MYclass.Add(TMyChildL1_2);
  13. ..
  14. finalization
  15.   MYClass.Free
  16. end.
  17.  

All the above works fine, but any new added Tchild requires to be added manually to the list in the code in the inizializations section,

Is there a function that given the “father” (ie  here TmyObj) goes trough all the children so that MyClass instance is automatically updated ?

something like (pseudo code)

Code: Pascal  [Select][+][-]
  1. Loop form TmyObj to childrenlist.count do
  2. MyClass.Add(TchildN)
  3.  

 

TinyPortal © 2005-2018