#ifndef __JROOTSUPPORTKIT__ #define __JROOTSUPPORTKIT__ #include "TFile.h" #include "JLang/JTest.hh" #include "JLang/JBool.hh" #include "JROOT/JRootToolkit.hh" /** * \file * * Data type dependent action methods for customised ROOT version management. * \author mdejong */ namespace JROOT {} namespace JPP { using namespace JROOT; } namespace JROOT { using JLANG::JTest; using JLANG::JBool; /** * Auxiliary class to handle version management of given class at opening of a ROOT file. */ template class JActionAtFileOpen : public JTest { using JTest::test; template static JTrue test(JTypecheck*); /** * Execute action. * * This implementation transfers the action to the given class. * * \param file pointer to file * \param option true */ static inline void execute(TFile* file, JBool option) { T::actionAtFileOpen(getStreamerVersion(file, T::Class_Name())); } /** * Execute action. * * This implementation does nothing. * * \param file pointer to file * \param option false */ static inline void execute(TFile* file, JBool option) {} public: static const bool has_method = JTEST(test(NULL)); //!< true if class has policy method actionAtFileOpen; else false /** * Execute action. * * \param file pointer to file */ static inline void execute(TFile* file) { execute(file, JBool()); } }; /** * Auxiliary class to handle version management of given class at reading from a ROOT file. */ template class JActionAtFileRead : public JTest { using JTest::test; template static JTrue test(JTypecheck*); /** * Execute action. * * This implementation transfers the action to the given object. * * \param object pointer to object (I/O) * \param option true */ static inline void execute(T* object, JBool option) { object->actionAtFileRead(); } /** * Execute action. * * This implementation does nothing. * * \param object pointer to object (I/O) * \param option false */ static inline void execute(T* object, JBool option) {} public: static const bool has_method = JTEST(test(NULL)); //!< true if class has policy method actionAtFileRead; else false /** * Execute action. * * \param object pointer to object (I/O) */ static inline void execute(T* object) { execute(object, JBool()); } }; /** * General action method at file open. * * The class T should provide the policy method: *
   *    static void %actionAtFileOpen(int version);
   * 
* whenever an action specific to this data type has to be executed after opening a file.\n * This method will then be called following each file open operation. * * \param file pointer to file */ template inline void actionAtFileOpen(TFile* file) { if (file != NULL) { JActionAtFileOpen::execute(file); } } /** * General action method at file read. * * The class T should provide the policy method: *
   *    void %actionAtFileRead();
   * 
* whenever an action specific to this data type has to be executed after reading from a file.\n * This method will then be called following each file read operation. * * \param object pointer to object (I/O) */ template inline void actionAtFileRead(T* object) { if (object != NULL) { JActionAtFileRead::execute(object); } } } #endif