Hi Victor, if you have any "name-dependent" actions in the constructor/streamer, setting name after Clone() doesn't help. --- TPortfolio *Portfolio = (TPortfolio*) gROOT->GetListOfSpecials()->FindObject(GetName()); if (Portfolio) { Warning("Init","Replacing existing portfolio: %s",GetName()); gROOT->GetListOfSpecials()->Remove(Portfolio); delete Portfolio; } gROOT->GetListOfSpecials()->Add(this); --- The code above will delete parent object. I thought TObject::Clone(const char* Name = "") is quite natural solution which is also back compatible. Regards, Anton http://www.smartquant.com ----- Original Message ----- From: Victor Perevoztchikov <perev@bnl.gov> To: Anton Fokin <anton.fokin@smartquant.com> Cc: roottalk <roottalk@pcroot.cern.ch> Sent: Tuesday, February 13, 2001 12:07 AM Subject: Re: [ROOT] Clone() > Hi Anton, > > > I think it might be wise to add/improve > > > > TObject::Clone(const char* Name="") > It is easy to do after: > > p = xxx->Clone(); p->SetName("***"); > > I think that any complication of root basis > should be done only if user can not do it himself. > Or it is too complicated. > > So it is better to keep TObject as simple as possible. > > Victor > > > Anton Fokin wrote: > > > > Hi rooters, > > > > I think it might be wise to add/improve > > > > TObject::Clone(const char* Name="") > > > > function, which sets Name in case of TNamed derived classes. This is useful > > if you clone named objects like TH1, especially if you algorithm deletes > > overwritten object with the same name. > > > > TPortfolio *ClonePortfolio = Portfolio->Clone("ClonePortfolio"); > > > > can help a lot. > > > > /Anton > > > > http://www.smartquant.com > > -- > Victor M. Perevoztchikov perev@bnl.gov perev@vxcern.cern.ch > Brookhaven National Laboratory MS 510A PO Box 5000 Upton NY 11973-5000 > tel office : 631-344-7894; fax 631-344-4206; home 631-345-2690 > >
This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:36 MET