Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

up #38

Merged
merged 2 commits into from
Nov 27, 2024
Merged

up #38

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion include/GenericToolbox.Root.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,9 @@ namespace GenericToolbox{
inline TDirectory* getCurrentTDirectory();
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<std::string> lsTDirectory(TDirectory* directory_, const std::string& className_ = "");
Expand Down Expand Up @@ -774,11 +776,17 @@ 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 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();
Expand All @@ -803,6 +811,10 @@ namespace GenericToolbox {
delete templateClass;
return output;
}
template<typename T, typename = std::enable_if_t<std::is_arithmetic<T>::value>> inline void writeInTFileWithObjTypeExt(TDirectory* dir_, const T& objToSave_, std::string saveName_){
TParameter<T> out(saveName_.c_str(), objToSave_);
writeInTFileWithObjTypeExt(dir_, (TObject*) &out);
}
template<typename T, typename = std::enable_if_t<std::is_arithmetic<T>::value>> inline void writeInTFile(TDirectory* dir_, const T& objToSave_, std::string saveName_){
TParameter<T> out(saveName_.c_str(), objToSave_);
writeInTFile(dir_, (TObject*) &out);
Expand Down
Loading