From da1e3af6e8f35a9654d9e5d560ec5051be799772 Mon Sep 17 00:00:00 2001 From: Adrien Blanchet Date: Wed, 27 Nov 2024 12:19:08 +0100 Subject: [PATCH 1/2] forgot overload --- include/GenericToolbox.Root.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/GenericToolbox.Root.h b/include/GenericToolbox.Root.h index 3112536..1d85ea3 100644 --- a/include/GenericToolbox.Root.h +++ b/include/GenericToolbox.Root.h @@ -151,6 +151,7 @@ namespace GenericToolbox{ inline TDirectory* mkdirTFile(TFile* outputFile_, const std::string &dirName_); inline TDirectory* getCurrentTDirectory(); inline void writeInTFileWithObjTypeExt(TDirectory* dir_, const TObject* objToSave_, std::string saveName_ = "", bool forceWriteFile_=false); + inline void writeInTFileWithObjTypeExt(TDirectory* dir_, const TObject& objToSave_, std::string saveName_ = "", bool forceWriteFile_=false); inline void writeInTFile(TDirectory* dir_, const TObject* objToSave_, std::string saveName_ = "", bool forceWriteFile_=false); inline void writeInTFile(TDirectory* dir_, const TObject& objToSave_, std::string saveName_ = "", bool forceWriteFile_=false); inline void writeInTFile(TDirectory* dir_, const std::string& objToSave_, std::string saveName_, bool forceWriteFile_=false); @@ -774,6 +775,9 @@ namespace GenericToolbox { // Force TFile Write? if( forceWriteFile_ ){ triggerTFileWrite(dir_); } } + inline void writeInTFileWithObjTypeExt(TDirectory* dir_, const TObject& objToSave_, std::string saveName_, bool forceWriteFile_){ + writeInTFileWithObjTypeExt(dir_, &objToSave_, std::move(saveName_), forceWriteFile_); + } inline void writeInTFile(TDirectory* dir_, const TObject& objToSave_, std::string saveName_, bool forceWriteFile_){ writeInTFile(dir_, &objToSave_, std::move(saveName_), forceWriteFile_); } From 426d216957528311991a0247579fbded71e8374f Mon Sep 17 00:00:00 2001 From: Adrien Blanchet Date: Wed, 27 Nov 2024 12:49:26 +0100 Subject: [PATCH 2/2] missing overloads --- include/GenericToolbox.Root.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/include/GenericToolbox.Root.h b/include/GenericToolbox.Root.h index 1d85ea3..93bf075 100644 --- a/include/GenericToolbox.Root.h +++ b/include/GenericToolbox.Root.h @@ -151,9 +151,10 @@ namespace GenericToolbox{ inline TDirectory* mkdirTFile(TFile* outputFile_, const std::string &dirName_); inline TDirectory* getCurrentTDirectory(); inline void writeInTFileWithObjTypeExt(TDirectory* dir_, const TObject* objToSave_, std::string saveName_ = "", bool forceWriteFile_=false); - inline void writeInTFileWithObjTypeExt(TDirectory* dir_, const TObject& objToSave_, std::string saveName_ = "", bool forceWriteFile_=false); inline void writeInTFile(TDirectory* dir_, const TObject* objToSave_, std::string saveName_ = "", bool forceWriteFile_=false); + inline void writeInTFileWithObjTypeExt(TDirectory* dir_, const TObject& objToSave_, std::string saveName_ = "", bool forceWriteFile_=false); inline void writeInTFile(TDirectory* dir_, const TObject& objToSave_, std::string saveName_ = "", bool forceWriteFile_=false); + inline void writeInTFileWithObjTypeExt(TDirectory* dir_, const std::string& objToSave_, std::string saveName_, bool forceWriteFile_=false); inline void writeInTFile(TDirectory* dir_, const std::string& objToSave_, std::string saveName_, bool forceWriteFile_=false); inline void triggerTFileWrite(TDirectory* dir_); inline std::vector lsTDirectory(TDirectory* directory_, const std::string& className_ = ""); @@ -778,11 +779,14 @@ namespace GenericToolbox { inline void writeInTFileWithObjTypeExt(TDirectory* dir_, const TObject& objToSave_, std::string saveName_, bool forceWriteFile_){ writeInTFileWithObjTypeExt(dir_, &objToSave_, std::move(saveName_), forceWriteFile_); } + inline void writeInTFileWithObjTypeExt(TDirectory* dir_, const std::string& objToSave_, std::string saveName_, bool forceWriteFile_){ + writeInTFileWithObjTypeExt(dir_, TNamed(saveName_, objToSave_.c_str()), std::move(saveName_), forceWriteFile_); + } inline void writeInTFile(TDirectory* dir_, const TObject& objToSave_, std::string saveName_, bool forceWriteFile_){ writeInTFile(dir_, &objToSave_, std::move(saveName_), forceWriteFile_); } inline void writeInTFile(TDirectory* dir_, const std::string& objToSave_, std::string saveName_, bool forceWriteFile_){ - writeInTFile(dir_, TNamed(saveName_, objToSave_.c_str()), saveName_, forceWriteFile_); + writeInTFile(dir_, TNamed(saveName_, objToSave_.c_str()), std::move(saveName_), forceWriteFile_); } inline void triggerTFileWrite(TDirectory* dir_){ if( dir_->GetFile() != nullptr ) dir_->GetFile()->Write(); @@ -807,6 +811,10 @@ namespace GenericToolbox { delete templateClass; return output; } + template::value>> inline void writeInTFileWithObjTypeExt(TDirectory* dir_, const T& objToSave_, std::string saveName_){ + TParameter out(saveName_.c_str(), objToSave_); + writeInTFileWithObjTypeExt(dir_, (TObject*) &out); + } template::value>> inline void writeInTFile(TDirectory* dir_, const T& objToSave_, std::string saveName_){ TParameter out(saveName_.c_str(), objToSave_); writeInTFile(dir_, (TObject*) &out);