@@ -2010,63 +2010,7 @@ Int_t TDirectoryFile::WriteTObject(const TObject *obj, const char *name, Option_
20102010 return nbytes;
20112011}
20122012
2013- // //////////////////////////////////////////////////////////////////////////////
2014- // / Write object from pointer of class classname in this directory.
2015- // /
2016- // / obj may not derive from TObject. See TDirectoryFile::WriteTObject for comments
2017- // /
2018- // / ## Very important note
2019- // / The value passed as 'obj' needs to be from a pointer to the type described by classname.
2020- // / For example:
2021- // / ~~~{.cpp}
2022- // / TopClass *top;
2023- // / BottomClass *bottom;
2024- // / top = bottom;
2025- // / ~~~
2026- // / you can do:
2027- // / ~~~{.cpp}
2028- // / directory->WriteObjectAny(top,"top","name of object");
2029- // / directory->WriteObjectAny(bottom,"bottom","name of object");
2030- // / ~~~
2031- // / <b>BUT YOU CAN NOT DO</b> the following since it will fail with multiple inheritance:
2032- // / ~~~{.cpp}
2033- // / directory->WriteObjectAny(top,"bottom","name of object");
2034- // / ~~~
2035- // / We <b>STRONGLY</b> recommend to use
2036- // / ~~~{.cpp}
2037- // / TopClass *top = ....;
2038- // / directory->WriteObject(top,"name of object")
2039- // / ~~~
2040- // / See also remarks in TDirectoryFile::WriteTObject
2041-
2042- Int_t TDirectoryFile::WriteObjectAny (const void *obj, const char *classname, const char *name, Option_t *option, Int_t bufsize)
2043- {
2044- TClass *cl = TClass::GetClass (classname);
2045- if (!cl) {
2046- TObject *info_obj = *(TObject**)obj;
2047- TVirtualStreamerInfo *info = dynamic_cast <TVirtualStreamerInfo*>(info_obj);
2048- if (!info) {
2049- Error (" WriteObjectAny" ," Unknown class: %s" ,classname);
2050- return 0 ;
2051- } else {
2052- cl = info->GetClass ();
2053- }
2054- }
2055- return WriteObjectAny (obj,cl,name,option,bufsize);
2056- }
2057-
2058- // //////////////////////////////////////////////////////////////////////////////
2059- // / Write object of class with dictionary cl in this directory.
2060- // /
2061- // / obj may not derive from TObject
2062- // / To get the TClass* cl pointer, one can use
2063- // /
2064- // / TClass *cl = TClass::GetClass("classname");
2065- // /
2066- // / An alternative is to call the function WriteObjectAny above.
2067- // / see TDirectoryFile::WriteTObject for comments
2068-
2069- Int_t TDirectoryFile::WriteObjectAny (const void *obj, const TClass *cl, const char *name, Option_t *option, Int_t bufsize)
2013+ Int_t TDirectoryFile::WriteObjectAny (const void *obj, const TClass *cl, const char *name, const char *title, Option_t *option, Int_t bufsize)
20702014{
20712015 TDirectory::TContext ctxt (this );
20722016
@@ -2136,6 +2080,7 @@ Int_t TDirectoryFile::WriteObjectAny(const void *obj, const TClass *cl, const ch
21362080 oldkey = GetKey (oname);
21372081 }
21382082 key = fFile ->CreateKey (this , obj, cl, oname, bsize);
2083+ key->SetTitle (title);
21392084 if (newName) delete [] newName;
21402085
21412086 if (!key->GetSeekKey ()) {
@@ -2155,6 +2100,67 @@ Int_t TDirectoryFile::WriteObjectAny(const void *obj, const TClass *cl, const ch
21552100 return nbytes;
21562101}
21572102
2103+ // //////////////////////////////////////////////////////////////////////////////
2104+ // / Write object from pointer of class classname in this directory.
2105+ // /
2106+ // / obj may not derive from TObject. See TDirectoryFile::WriteTObject for comments
2107+ // /
2108+ // / ## Very important note
2109+ // / The value passed as 'obj' needs to be from a pointer to the type described by classname.
2110+ // / For example:
2111+ // / ~~~{.cpp}
2112+ // / TopClass *top;
2113+ // / BottomClass *bottom;
2114+ // / top = bottom;
2115+ // / ~~~
2116+ // / you can do:
2117+ // / ~~~{.cpp}
2118+ // / directory->WriteObjectAny(top,"top","name of object");
2119+ // / directory->WriteObjectAny(bottom,"bottom","name of object");
2120+ // / ~~~
2121+ // / <b>BUT YOU CAN NOT DO</b> the following since it will fail with multiple inheritance:
2122+ // / ~~~{.cpp}
2123+ // / directory->WriteObjectAny(top,"bottom","name of object");
2124+ // / ~~~
2125+ // / We <b>STRONGLY</b> recommend to use
2126+ // / ~~~{.cpp}
2127+ // / TopClass *top = ....;
2128+ // / directory->WriteObject(top,"name of object")
2129+ // / ~~~
2130+ // / See also remarks in TDirectoryFile::WriteTObject
2131+
2132+ Int_t TDirectoryFile::WriteObjectAny (const void *obj, const char *classname, const char *name, Option_t *option, Int_t bufsize)
2133+ {
2134+ TClass *cl = TClass::GetClass (classname);
2135+ if (!cl) {
2136+ TObject *info_obj = *(TObject**)obj;
2137+ TVirtualStreamerInfo *info = dynamic_cast <TVirtualStreamerInfo*>(info_obj);
2138+ if (!info) {
2139+ Error (" WriteObjectAny" ," Unknown class: %s" ,classname);
2140+ return 0 ;
2141+ } else {
2142+ cl = info->GetClass ();
2143+ }
2144+ }
2145+ return WriteObjectAny (obj,cl,name,option,bufsize);
2146+ }
2147+
2148+ // //////////////////////////////////////////////////////////////////////////////
2149+ // / Write object of class with dictionary cl in this directory.
2150+ // /
2151+ // / obj may not derive from TObject
2152+ // / To get the TClass* cl pointer, one can use
2153+ // /
2154+ // / TClass *cl = TClass::GetClass("classname");
2155+ // /
2156+ // / An alternative is to call the function WriteObjectAny above.
2157+ // / see TDirectoryFile::WriteTObject for comments
2158+
2159+ Int_t TDirectoryFile::WriteObjectAny (const void *obj, const TClass *cl, const char *name, Option_t *option, Int_t bufsize)
2160+ {
2161+ return WriteObjectAny (obj, cl, name, /* title=*/ " " , option, bufsize);
2162+ }
2163+
21582164// //////////////////////////////////////////////////////////////////////////////
21592165// / Overwrite the Directory header record.
21602166
0 commit comments