2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
5 #ifndef RINGERSELECTORTOOLS_TOOLS_RINGERIOVARDEPOBJ_ICC
6 #define RINGERSELECTORTOOLS_TOOLS_RINGERIOVARDEPOBJ_ICC
16 #include "RingerSelectorTools/tools/RingerIOVarDepObj.h"
17 #include "RingerSelectorTools/tools/IOHelperFcns.icc"
21 // =============================================================================
22 template < class CRTP >
23 std::string RingerIOVarDepObj<CRTP>::name() const
25 const std::string name = std::string(CRTP::base_t::procType()) +
26 this->VariableDependency::type();
30 // =============================================================================
31 template < class CRTP >
32 CRTP* RingerIOVarDepObj<CRTP>::read(TDirectory *configDir)
34 CRTP* crtp = new CRTP;
36 unsigned v = IOHelperFcns::getWrittenVersion(configDir);
37 CRTP::base_t::read(crtp, configDir, v );
38 VariableDependency::read(crtp, configDir, v );
40 } catch ( const std::runtime_error &e){
41 std::cerr << "Couldn't read object of type "
42 << CRTP::base_t::procType()
43 << ". Reason: " << e.what() << std::endl;
49 // =============================================================================
50 template < class CRTP >
51 void RingerIOVarDepObj<CRTP>::write(TDirectory *baseDir, const char *idxStr)
54 typedef typename CRTP::base_t base_t;
55 typedef typename RingerProcedureType<base_t>::procEnum_t
57 // Create directory where we will add all configurable information:
58 TDirectory* configDir = IOHelperFcns::makeDir( baseDir,
59 (std::string(this->name()) + std::string(idxStr) ).c_str() );
60 // Write object version:
61 unsigned v = IOHelperFcns::version();
62 IOHelperFcns::writeVar( configDir, "writtenOnPkgVersion", v );
64 procEnum_t procType = base_t::template procType<procEnum_t>();
65 IOHelperFcns::writeVar< const procEnum_t, const unsigned int>( configDir,
68 // Now write BaseProcedure and VariableDependency information on it:
69 static_cast<const CRTP*>(this)->base_t::write(configDir, idxStr);
70 static_cast<const VariableDependency*>(this)->writeDepInfo(configDir);
75 #endif // RINGERSELECTORTOOLS_TOOLS_RINGERIOVARDEPOBJ_ICC