From 3cffef969ef568d7ef43bb9d3a89267f74466910 Mon Sep 17 00:00:00 2001
From: Philippe Canal <pcanal@fnal.gov>
Date: Wed, 8 Dec 2010 17:42:11 +0000
Subject: [PATCH] Since the Collection objects do have a name and the Clone
 method does allow (in other cases) for the name to change, add a
 TCollection::Clone to implement the name change properly

git-svn-id: http://root.cern.ch/svn/root/trunk@37411 27541ba8-7e3a-0410-8455-c3a389f83636
---
 core/cont/inc/TCollection.h   |  1 +
 core/cont/src/TCollection.cxx | 12 ++++++++++++
 2 files changed, 13 insertions(+)

diff --git a/core/cont/inc/TCollection.h b/core/cont/inc/TCollection.h
index 9c8d2611a87..34f2b334bbf 100644
--- a/core/cont/inc/TCollection.h
+++ b/core/cont/inc/TCollection.h
@@ -78,6 +78,7 @@ public:
    void               Browse(TBrowser *b);
    Int_t              Capacity() const { return fSize; }
    virtual void       Clear(Option_t *option="") = 0;
+   virtual TObject   *Clone(const char *newname="") const;
    Int_t              Compare(const TObject *obj) const;
    Bool_t             Contains(const char *name) const { return FindObject(name) != 0; }
    Bool_t             Contains(const TObject *obj) const { return FindObject(obj) != 0; }
diff --git a/core/cont/src/TCollection.cxx b/core/cont/src/TCollection.cxx
index 9677c24debc..c632446f331 100644
--- a/core/cont/src/TCollection.cxx
+++ b/core/cont/src/TCollection.cxx
@@ -125,6 +125,18 @@ void TCollection::Browse(TBrowser *b)
       TObject::Browse(b);
 }
 
+//______________________________________________________________________________
+TObject *TCollection::Clone(const char *newname) const
+{
+   // Make a clone of an collection using the Streamer facility.
+   // If newname is specified, this will be the name of the new collection.
+   
+   TCollection *new_collection = (TCollection*)TObject::Clone(newname);
+   if (newname && strlen(newname)) new_collection->SetName(newname);
+   return new_collection;
+}
+
+
 //______________________________________________________________________________
 Int_t TCollection::Compare(const TObject *obj) const
 {
-- 
GitLab