From b18019b7c767c2efc01398ef1f5940dcb6174ec9 Mon Sep 17 00:00:00 2001 From: John Chapman <jchapman@cern.ch> Date: Mon, 6 Jul 2020 15:55:16 +0200 Subject: [PATCH] Tidying syntax in AGDDToolBase, so that python2 and python3 behaviour match Also adapting derived classes `DefaultAGDDTool`, `MuonAGDDTool` and `NSWAGDDTool` to use `Gaudi::Property` member variables from the base-class correctly. --- .../AGDD/AGDD2GeoSvc/src/DefaultAGDDTool.cxx | 6 +-- .../AGDDControl/AGDDControl/AGDDToolBase.h | 48 +++++++++---------- .../AGDDControl/AGDDControl/IAGDDToolBase.h | 17 +++---- .../AGDD/AGDDControl/src/AGDDToolBase.cxx | 33 ++++--------- .../MuonAGDD/src/MuonAGDDTool.cxx | 6 +-- .../MuonDetDescr/MuonAGDD/src/NSWAGDDTool.cxx | 6 +-- 6 files changed, 47 insertions(+), 69 deletions(-) diff --git a/DetectorDescription/AGDD/AGDD2GeoSvc/src/DefaultAGDDTool.cxx b/DetectorDescription/AGDD/AGDD2GeoSvc/src/DefaultAGDDTool.cxx index 29b7a50f30d..bbf3e19e6ad 100644 --- a/DetectorDescription/AGDD/AGDD2GeoSvc/src/DefaultAGDDTool.cxx +++ b/DetectorDescription/AGDD/AGDD2GeoSvc/src/DefaultAGDDTool.cxx @@ -15,7 +15,7 @@ DefaultAGDDTool::DefaultAGDDTool(const std::string& type, const std::string& nam StatusCode DefaultAGDDTool::initialize() { ATH_MSG_INFO("this is DefaultAGDDTool::initialize()!!!!"); - ATH_MSG_INFO("Default detector "<<m_defaultDetector); + ATH_MSG_INFO("Default detector "<<m_defaultDetector.value()); return AGDDToolBase::initialize(); } @@ -35,8 +35,8 @@ StatusCode DefaultAGDDTool::construct() if (!m_defaultDetector.empty()) { - ATH_MSG_INFO(" setting default detector to "<<m_defaultDetector); - m_controller->UseGeoModelDetector(m_defaultDetector); + ATH_MSG_INFO(" setting default detector to "<<m_defaultDetector.value()); + m_controller->UseGeoModelDetector(m_defaultDetector.value()); } m_controller->BuildAll(); diff --git a/DetectorDescription/AGDD/AGDDControl/AGDDControl/AGDDToolBase.h b/DetectorDescription/AGDD/AGDDControl/AGDDControl/AGDDToolBase.h index 357b78efffe..148485b13ab 100644 --- a/DetectorDescription/AGDD/AGDDControl/AGDDControl/AGDDToolBase.h +++ b/DetectorDescription/AGDD/AGDDControl/AGDDControl/AGDDToolBase.h @@ -1,41 +1,39 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ -#ifndef AGDDToolBase_H -#define AGDDToolBase_H +#ifndef AGDDCONTROL_AGDDToolBase_H +#define AGDDCONTROL_AGDDToolBase_H #include "AGDDControl/IAGDDToolBase.h" #include "AthenaBaseComps/AthAlgTool.h" #include "GaudiKernel/StatusCode.h" -class IInterface; class AGDDController; -class AGDDToolBase: public AthAlgTool, virtual public IAGDDToolBase +class AGDDToolBase: public extends<AthAlgTool, IAGDDToolBase> { public: - AGDDToolBase(const std::string& type, const std::string& name, - const IInterface* parent); - virtual StatusCode initialize(); - virtual StatusCode construct() {return StatusCode::SUCCESS;} + AGDDToolBase(const std::string& type, const std::string& name, + const IInterface* parent); + virtual StatusCode initialize(); + virtual StatusCode construct() {return StatusCode::SUCCESS;} protected: - std::vector<std::string> m_xmlFiles; - std::vector<std::string> m_sectionsToBuild; - std::vector<std::string> m_volumesToBuild; - int m_parserVerbosity; - int m_builderVerbosity; - bool m_printSections; - bool m_disableSections; - bool m_locked; - bool m_writeDBfile; - std::string m_outFileName; - std::string m_defaultDetector; - std::string m_navigateDetector; - - void InitializeAGDD(); - - AGDDController* m_controller; + void InitializeAGDD(); + + Gaudi::Property<std::vector<std::string> > m_xmlFiles{this, "XMLFiles", {} }; + Gaudi::Property<std::vector<std::string> > m_sectionsToBuild{this, "Sections", {} }; + Gaudi::Property<std::vector<std::string> > m_volumesToBuild{this, "Volumes", {} }; + Gaudi::Property<int> m_parserVerbosity{this, "ParserVerbosity", 0}; + Gaudi::Property<int> m_builderVerbosity{this, "BuilderVerbosity", 0}; + Gaudi::Property<bool> m_printSections{this, "PrintSections", false}; + Gaudi::Property<bool> m_disableSections{this, "DisableSections", true}; + Gaudi::Property<bool> m_locked{this, "Locked", false}; + Gaudi::Property<bool> m_writeDBfile{this, "WriteAGDDFile", false}; + Gaudi::Property<std::string> m_outFileName{this, "OutAGDDXMLName", "mytest.xml"}; + Gaudi::Property<std::string> m_defaultDetector{this, "DefaultDetector", "NoDetector"}; + Gaudi::Property<std::string> m_navigateDetector{this, "NavigateDetector", ""}; + AGDDController* m_controller {}; }; #endif diff --git a/DetectorDescription/AGDD/AGDDControl/AGDDControl/IAGDDToolBase.h b/DetectorDescription/AGDD/AGDDControl/AGDDControl/IAGDDToolBase.h index 45d1a024f44..49ca8aa412b 100644 --- a/DetectorDescription/AGDD/AGDDControl/AGDDControl/IAGDDToolBase.h +++ b/DetectorDescription/AGDD/AGDDControl/AGDDControl/IAGDDToolBase.h @@ -1,24 +1,21 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ -#ifndef IAGDDToolBase_H -#define IAGDDToolBase_H +#ifndef AGDDCONTROL_IAGDDToolBase_H +#define AGDDCONTROL_IAGDDToolBase_H #include "GaudiKernel/IAlgTool.h" -static const InterfaceID IID_IAGDDToolBase("IAGDDToolBase",1,0); - // Interface to define an AGDD-constructing tool to be used from AGDD2GeoSvc class IAGDDToolBase: virtual public IAlgTool { public: - static const InterfaceID& interfaceID() {return IID_IAGDDToolBase;} - - virtual ~IAGDDToolBase() {} - - virtual StatusCode construct() =0; + virtual ~IAGDDToolBase() {} + DeclareInterfaceID(IAGDDToolBase,1,0); + + virtual StatusCode construct() = 0; }; #endif diff --git a/DetectorDescription/AGDD/AGDDControl/src/AGDDToolBase.cxx b/DetectorDescription/AGDD/AGDDControl/src/AGDDToolBase.cxx index 3555489ebda..05c0aec7df6 100644 --- a/DetectorDescription/AGDD/AGDDControl/src/AGDDToolBase.cxx +++ b/DetectorDescription/AGDD/AGDDControl/src/AGDDToolBase.cxx @@ -1,39 +1,22 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #include "AGDDControl/AGDDToolBase.h" #include "AGDDControl/AGDDController.h" -AGDDToolBase::AGDDToolBase(const std::string& type, const std::string& name, - const IInterface* parent):AthAlgTool(type,name,parent), - m_parserVerbosity(0),m_builderVerbosity(0), - m_printSections(false),m_locked(false), - m_defaultDetector("NoDetector"),m_navigateDetector("") +AGDDToolBase::AGDDToolBase(const std::string& type, const std::string& name, + const IInterface* parent) + : base_class(type,name,parent) { - declareInterface<IAGDDToolBase> (this); - - declareProperty( "XMLFiles", m_xmlFiles); - declareProperty( "Sections", m_sectionsToBuild); - declareProperty( "Volumes" , m_volumesToBuild); - declareProperty( "ParserVerbosity", m_parserVerbosity); - declareProperty( "BuilderVerbosity", m_builderVerbosity); - declareProperty( "PrintSections", m_printSections); - declareProperty( "Locked", m_locked); - declareProperty("DefaultDetector", m_defaultDetector); - declareProperty("NavigateDetector", m_navigateDetector); - declareProperty("DisableSections", m_disableSections); - declareProperty("WriteAGDDFile", m_writeDBfile = false); - declareProperty("OutAGDDXMLName", m_outFileName = "mytest.xml"); - - ATH_MSG_DEBUG(" trying to get the controller"); - m_controller =AGDDController::GetController(); + ATH_MSG_DEBUG(" trying to get the controller"); + m_controller = AGDDController::GetController(); } StatusCode AGDDToolBase::initialize() { - InitializeAGDD(); - return AlgTool::initialize(); + InitializeAGDD(); + return StatusCode::SUCCESS; } void AGDDToolBase::InitializeAGDD() diff --git a/MuonSpectrometer/MuonDetDescr/MuonAGDD/src/MuonAGDDTool.cxx b/MuonSpectrometer/MuonDetDescr/MuonAGDD/src/MuonAGDDTool.cxx index 66f9790e635..6e1d23f9a3a 100644 --- a/MuonSpectrometer/MuonDetDescr/MuonAGDD/src/MuonAGDDTool.cxx +++ b/MuonSpectrometer/MuonDetDescr/MuonAGDD/src/MuonAGDDTool.cxx @@ -156,7 +156,7 @@ StatusCode MuonAGDDTool::construct() bool MuonAGDDTool::WritePREsqlFile() const { - std::ifstream outfile(m_outFileName.c_str(), std::ifstream::in | std::ifstream::binary); + std::ifstream outfile(m_outFileName.value().c_str(), std::ifstream::in | std::ifstream::binary); std::vector<std::string> newoutfilelines; std::string outfileline; @@ -171,14 +171,14 @@ bool MuonAGDDTool::WritePREsqlFile() const } outfile.close(); - std::ofstream newoutfile(m_outFileName.c_str(), std::ofstream::out | std::ofstream::trunc); + std::ofstream newoutfile(m_outFileName.value().c_str(), std::ofstream::out | std::ofstream::trunc); for(auto it = newoutfilelines.begin(); it != newoutfilelines.end(); ++it) { if(it != newoutfilelines.begin()) newoutfile << "\n"; newoutfile << *it; } newoutfile.close(); - outfile.open(m_outFileName.c_str(), std::ifstream::in | std::ifstream::binary); + outfile.open(m_outFileName.value().c_str(), std::ifstream::in | std::ifstream::binary); int fileSize = 0; if(outfile.is_open()) diff --git a/MuonSpectrometer/MuonDetDescr/MuonAGDD/src/NSWAGDDTool.cxx b/MuonSpectrometer/MuonDetDescr/MuonAGDD/src/NSWAGDDTool.cxx index 4ae838e4893..bc7c02a61b7 100644 --- a/MuonSpectrometer/MuonDetDescr/MuonAGDD/src/NSWAGDDTool.cxx +++ b/MuonSpectrometer/MuonDetDescr/MuonAGDD/src/NSWAGDDTool.cxx @@ -144,7 +144,7 @@ StatusCode NSWAGDDTool::construct() bool NSWAGDDTool::WritePREsqlFile() const { - std::ifstream outfile(m_outFileName.c_str(), std::ifstream::in | std::ifstream::binary); + std::ifstream outfile(m_outFileName.value().c_str(), std::ifstream::in | std::ifstream::binary); std::vector<std::string> newoutfilelines; std::string outfileline; @@ -159,14 +159,14 @@ bool NSWAGDDTool::WritePREsqlFile() const } outfile.close(); - std::ofstream newoutfile(m_outFileName.c_str(), std::ofstream::out | std::ofstream::trunc); + std::ofstream newoutfile(m_outFileName.value().c_str(), std::ofstream::out | std::ofstream::trunc); for(auto it = newoutfilelines.begin(); it != newoutfilelines.end(); ++it) { if(it != newoutfilelines.begin()) newoutfile << "\n"; newoutfile << *it; } newoutfile.close(); - outfile.open(m_outFileName.c_str(), std::ifstream::in | std::ifstream::binary); + outfile.open(m_outFileName.value().c_str(), std::ifstream::in | std::ifstream::binary); int fileSize = 0; if(outfile.is_open()) -- GitLab