From 20f6f8ffa9aec3958d60551f7f4351a3adaad57f Mon Sep 17 00:00:00 2001
From: Markus Frank <Markus.Frank@cern.ch>
Date: Thu, 8 Feb 2024 10:13:59 +0100
Subject: [PATCH] Suppress default use of std namespace
---
DDG4/src/EventParameters.cpp | 2 ++
DDG4/src/Geant4Action.cpp | 53 +++++++++++++++---------------
DDG4/src/Geant4ActionContainer.cpp | 37 ++++++++++-----------
DDG4/src/Geant4ActionPhase.cpp | 23 +++++++------
DDG4/src/Geant4AssemblyVolume.cpp | 14 ++++----
DDG4/src/Geant4Call.cpp | 2 +-
DDG4/src/Geant4Context.cpp | 13 ++++----
7 files changed, 71 insertions(+), 73 deletions(-)
diff --git a/DDG4/src/EventParameters.cpp b/DDG4/src/EventParameters.cpp
index 0596e5a56..5a52e0da2 100644
--- a/DDG4/src/EventParameters.cpp
+++ b/DDG4/src/EventParameters.cpp
@@ -10,8 +10,10 @@
//
//====================================================================
+/// Framework include files
#include "DDG4/EventParameters.h"
+/// C/C++ include files
#include <map>
#include <string>
diff --git a/DDG4/src/Geant4Action.cpp b/DDG4/src/Geant4Action.cpp
index 2b7660298..9902863e3 100644
--- a/DDG4/src/Geant4Action.cpp
+++ b/DDG4/src/Geant4Action.cpp
@@ -12,34 +12,33 @@
//==========================================================================
// Framework include files
-#include "DD4hep/Printout.h"
-#include "DD4hep/InstanceCount.h"
-#include "DDG4/Geant4Context.h"
-#include "DDG4/Geant4Action.h"
-#include "DDG4/Geant4Kernel.h"
-#include "DDG4/Geant4UIMessenger.h"
+#include <DD4hep/Printout.h>
+#include <DD4hep/InstanceCount.h>
+#include <DDG4/Geant4Context.h>
+#include <DDG4/Geant4Action.h>
+#include <DDG4/Geant4Kernel.h>
+#include <DDG4/Geant4UIMessenger.h>
// Geant4 include files
-#include "G4UIdirectory.hh"
+#include <G4UIdirectory.hh>
// C/C++ include files
#include <algorithm>
-using namespace std;
using namespace dd4hep;
using namespace dd4hep::sim;
-TypeName TypeName::split(const string& type_name, const string& delim) {
+TypeName TypeName::split(const std::string& type_name, const std::string& delim) {
size_t idx = type_name.find(delim);
- string typ = type_name, nam = type_name;
- if (idx != string::npos) {
+ std::string typ = type_name, nam = type_name;
+ if (idx != std::string::npos) {
typ = type_name.substr(0, idx);
nam = type_name.substr(idx + 1);
}
return TypeName(typ, nam);
}
-TypeName TypeName::split(const string& type_name) {
+TypeName TypeName::split(const std::string& type_name) {
return split(type_name,"/");
}
#if 0
@@ -53,7 +52,7 @@ void Geant4Action::ContextUpdate::operator()(Geant4Action* action) const {
}
#endif
/// Standard constructor
-Geant4Action::Geant4Action(Geant4Context* ctxt, const string& nam)
+Geant4Action::Geant4Action(Geant4Context* ctxt, const std::string& nam)
: m_context(ctxt), m_control(0), m_outputLevel(INFO), m_needsControl(false), m_name(nam),
m_refCount(1)
{
@@ -94,12 +93,12 @@ PrintLevel Geant4Action::setOutputLevel(PrintLevel new_level) {
}
/// Check property for existence
-bool Geant4Action::hasProperty(const string& nam) const {
+bool Geant4Action::hasProperty(const std::string& nam) const {
return m_properties.exists(nam);
}
/// Access single property
-Property& Geant4Action::property(const string& nam) {
+Property& Geant4Action::property(const std::string& nam) {
return properties()[nam];
}
@@ -107,7 +106,7 @@ Property& Geant4Action::property(const string& nam) {
void Geant4Action::installMessengers() {
//m_needsControl = true;
if (m_needsControl && !m_control) {
- string path = context()->kernel().directoryName();
+ std::string path = context()->kernel().directoryName();
path += name() + "/";
m_control = new Geant4UIMessenger(name(), path);
installPropertyMessenger();
@@ -145,7 +144,7 @@ void Geant4Action::configureFiber(Geant4Context* /* thread_context */) {
/// Support for messages with variable output level using output level
void Geant4Action::print(const char* fmt, ...) const {
- int level = max(int(outputLevel()),(int)VERBOSE);
+ int level = std::max(int(outputLevel()),(int)VERBOSE);
if ( level >= printLevel() ) {
va_list args;
va_start(args, fmt);
@@ -156,7 +155,7 @@ void Geant4Action::print(const char* fmt, ...) const {
/// Support for messages with variable output level using output level-1
void Geant4Action::printM1(const char* fmt, ...) const {
- int level = max(outputLevel()-1,(int)VERBOSE);
+ int level = std::max(outputLevel()-1,(int)VERBOSE);
if ( level >= printLevel() ) {
va_list args;
va_start(args, fmt);
@@ -167,7 +166,7 @@ void Geant4Action::printM1(const char* fmt, ...) const {
/// Support for messages with variable output level using output level-2
void Geant4Action::printM2(const char* fmt, ...) const {
- int level = max(outputLevel()-2,(int)VERBOSE);
+ int level = std::max(outputLevel()-2,(int)VERBOSE);
if ( level >= printLevel() ) {
va_list args;
va_start(args, fmt);
@@ -178,7 +177,7 @@ void Geant4Action::printM2(const char* fmt, ...) const {
/// Support for messages with variable output level using output level-1
void Geant4Action::printP1(const char* fmt, ...) const {
- int level = min(outputLevel()+1,(int)FATAL);
+ int level = std::min(outputLevel()+1,(int)FATAL);
if ( level >= printLevel() ) {
va_list args;
va_start(args, fmt);
@@ -189,7 +188,7 @@ void Geant4Action::printP1(const char* fmt, ...) const {
/// Support for messages with variable output level using output level-2
void Geant4Action::printP2(const char* fmt, ...) const {
- int level = min(outputLevel()+2,(int)FATAL);
+ int level = std::min(outputLevel()+2,(int)FATAL);
if ( level >= printLevel() ) {
va_list args;
va_start(args, fmt);
@@ -259,22 +258,22 @@ void Geant4Action::fatal(const char* fmt, ...) const {
void Geant4Action::except(const char* fmt, ...) const {
va_list args;
va_start(args, fmt);
- string err = dd4hep::format(m_name, fmt, args);
+ std::string err = dd4hep::format(m_name, fmt, args);
dd4hep::printout(dd4hep::FATAL, m_name, err.c_str());
va_end(args);
- throw runtime_error(err);
+ throw std::runtime_error(err);
}
/// Abort Geant4 Run by throwing a G4Exception with type RunMustBeAborted
-void Geant4Action::abortRun(const string& exception, const char* fmt, ...) const {
- string desc, typ = typeName(typeid(*this));
- string issuer = name()+" ["+typ+"]";
+void Geant4Action::abortRun(const std::string& exception, const char* fmt, ...) const {
+ std::string desc, typ = typeName(typeid(*this));
+ std::string issuer = name()+" ["+typ+"]";
va_list args;
va_start(args, fmt);
desc = dd4hep::format("*** Geant4Action:", fmt, args);
va_end(args);
G4Exception(issuer.c_str(),exception.c_str(),RunMustBeAborted,desc.c_str());
- //throw runtime_error(issuer+"> "+desc);
+ //throw std::runtime_error(issuer+"> "+desc);
}
/// Access to the main run action sequence from the kernel object
diff --git a/DDG4/src/Geant4ActionContainer.cpp b/DDG4/src/Geant4ActionContainer.cpp
index d6b23c73c..7fae8020d 100644
--- a/DDG4/src/Geant4ActionContainer.cpp
+++ b/DDG4/src/Geant4ActionContainer.cpp
@@ -12,27 +12,26 @@
//==========================================================================
// Framework include files
-#include "DD4hep/Printout.h"
-#include "DD4hep/Primitives.h"
-#include "DD4hep/InstanceCount.h"
-
-#include "DDG4/Geant4ActionContainer.h"
-#include "DDG4/Geant4RunAction.h"
-#include "DDG4/Geant4PhysicsList.h"
-#include "DDG4/Geant4EventAction.h"
-#include "DDG4/Geant4SteppingAction.h"
-#include "DDG4/Geant4TrackingAction.h"
-#include "DDG4/Geant4StackingAction.h"
-#include "DDG4/Geant4GeneratorAction.h"
-#include "DDG4/Geant4DetectorConstruction.h"
-#include "DDG4/Geant4UserInitialization.h"
-#include "DDG4/Geant4SensDetAction.h"
+#include <DD4hep/Printout.h>
+#include <DD4hep/Primitives.h>
+#include <DD4hep/InstanceCount.h>
+
+#include <DDG4/Geant4ActionContainer.h>
+#include <DDG4/Geant4RunAction.h>
+#include <DDG4/Geant4PhysicsList.h>
+#include <DDG4/Geant4EventAction.h>
+#include <DDG4/Geant4SteppingAction.h>
+#include <DDG4/Geant4TrackingAction.h>
+#include <DDG4/Geant4StackingAction.h>
+#include <DDG4/Geant4GeneratorAction.h>
+#include <DDG4/Geant4DetectorConstruction.h>
+#include <DDG4/Geant4UserInitialization.h>
+#include <DDG4/Geant4SensDetAction.h>
// C/C++ include files
#include <stdexcept>
#include <algorithm>
-using namespace std;
using namespace dd4hep::sim;
/// Standard constructor
@@ -69,7 +68,7 @@ int Geant4ActionContainer::terminate() {
Geant4Context* Geant4ActionContainer::workerContext() {
if ( m_context ) return m_context;
- throw runtime_error(format("Geant4Kernel", "DDG4: Master kernel object has no thread context! [Invalid Handle]"));
+ throw std::runtime_error(format("Geant4Kernel", "DDG4: Master kernel object has no thread context! [Invalid Handle]"));
}
/// Set the thread's context
@@ -83,7 +82,7 @@ template <class C> bool Geant4ActionContainer::registerSequence(C*& seq, const s
seq->installMessengers();
return true;
}
- throw runtime_error(format("Geant4ActionContainer", "DDG4: The action '%s' not found. [Action-NotFound]", name.c_str()));
+ throw std::runtime_error(format("Geant4ActionContainer", "DDG4: The action '%s' not found. [Action-NotFound]", name.c_str()));
}
/// Access generator action sequence
@@ -141,7 +140,7 @@ Geant4SensDetSequences& Geant4ActionContainer::sensitiveActions() const {
}
/// Access to the sensitive detector action from the kernel object
-Geant4SensDetActionSequence* Geant4ActionContainer::sensitiveAction(const string& nam) {
+Geant4SensDetActionSequence* Geant4ActionContainer::sensitiveAction(const std::string& nam) {
Geant4SensDetActionSequence* ptr = m_sensDetActions->find(nam);
if (ptr) {
return ptr;
diff --git a/DDG4/src/Geant4ActionPhase.cpp b/DDG4/src/Geant4ActionPhase.cpp
index 78f42f986..5d84e8c46 100644
--- a/DDG4/src/Geant4ActionPhase.cpp
+++ b/DDG4/src/Geant4ActionPhase.cpp
@@ -12,10 +12,9 @@
//==========================================================================
// Framework include files
-#include "DD4hep/InstanceCount.h"
-#include "DDG4/Geant4ActionPhase.h"
+#include <DD4hep/InstanceCount.h>
+#include <DDG4/Geant4ActionPhase.h>
-using namespace std;
using namespace dd4hep::sim;
/// Standard constructor
@@ -37,8 +36,8 @@ dd4hep::Callback Geant4PhaseAction::callback() {
}
/// Standard constructor
-Geant4ActionPhase::Geant4ActionPhase(Geant4Context* ctxt, const string& nam, const type_info& arg_type0,
- const type_info& arg_type1, const type_info& arg_type2)
+Geant4ActionPhase::Geant4ActionPhase(Geant4Context* ctxt, const std::string& nam, const std::type_info& arg_type0,
+ const std::type_info& arg_type1, const std::type_info& arg_type2)
: Geant4Action(ctxt, nam) {
m_argTypes[0] = &arg_type0;
m_argTypes[1] = &arg_type1;
@@ -64,7 +63,7 @@ bool Geant4ActionPhase::add(Geant4Action* action, Callback callback) {
/// Remove an existing member from the phase. If not existing returns false
bool Geant4ActionPhase::remove(Geant4Action* action, Callback callback) {
if (action && callback.func.first) {
- Members::iterator i = find(m_members.begin(), m_members.end(), make_pair(action,callback));
+ Members::iterator i = find(m_members.begin(), m_members.end(), std::make_pair(action,callback));
if (i != m_members.end()) {
(*i).first->release();
m_members.erase(i);
@@ -92,12 +91,12 @@ void Geant4ActionPhase::execute(void* argument) {
class G4HCofThisEvent;
class G4TouchableHistory;
-#include "DDG4/Geant4RunAction.h"
-#include "DDG4/Geant4EventAction.h"
-#include "DDG4/Geant4TrackingAction.h"
-#include "DDG4/Geant4SteppingAction.h"
-#include "DDG4/Geant4StackingAction.h"
-#include "DDG4/Geant4GeneratorAction.h"
+#include <DDG4/Geant4RunAction.h>
+#include <DDG4/Geant4EventAction.h>
+#include <DDG4/Geant4TrackingAction.h>
+#include <DDG4/Geant4SteppingAction.h>
+#include <DDG4/Geant4StackingAction.h>
+#include <DDG4/Geant4GeneratorAction.h>
namespace dd4hep {
namespace sim {
/// Callback in Begin stacking action
diff --git a/DDG4/src/Geant4AssemblyVolume.cpp b/DDG4/src/Geant4AssemblyVolume.cpp
index 5f0c2496e..6517b7e03 100644
--- a/DDG4/src/Geant4AssemblyVolume.cpp
+++ b/DDG4/src/Geant4AssemblyVolume.cpp
@@ -12,19 +12,19 @@
//==========================================================================
/// Geant4 include files
-#include "G4LogicalVolume.hh"
-#include "G4VPhysicalVolume.hh"
-#include "G4ReflectionFactory.hh"
+#include <G4LogicalVolume.hh>
+#include <G4VPhysicalVolume.hh>
+#include <G4ReflectionFactory.hh>
/// C/C++ include files
#include <sstream>
#include <string>
/// Framework include files
-#include "DD4hep/DetectorTools.h"
-#include "DDG4/Geant4Converter.h"
-#include "DDG4/Geant4GeometryInfo.h"
-#include "DDG4/Geant4AssemblyVolume.h"
+#include <DD4hep/DetectorTools.h>
+#include <DDG4/Geant4Converter.h>
+#include <DDG4/Geant4GeometryInfo.h>
+#include <DDG4/Geant4AssemblyVolume.h>
using namespace dd4hep::sim;
diff --git a/DDG4/src/Geant4Call.cpp b/DDG4/src/Geant4Call.cpp
index b204635dd..e5d6cf295 100644
--- a/DDG4/src/Geant4Call.cpp
+++ b/DDG4/src/Geant4Call.cpp
@@ -12,7 +12,7 @@
//==========================================================================
// Framework include files
-#include "DDG4/Geant4Call.h"
+#include <DDG4/Geant4Call.h>
/// Default destructor (keep here to avoid weak linkage to vtable)
dd4hep::sim::Geant4Call::~Geant4Call() {
diff --git a/DDG4/src/Geant4Context.cpp b/DDG4/src/Geant4Context.cpp
index fb3908341..95f0f84d4 100644
--- a/DDG4/src/Geant4Context.cpp
+++ b/DDG4/src/Geant4Context.cpp
@@ -12,15 +12,14 @@
//==========================================================================
// Framework include files
-#include "DD4hep/Printout.h"
-#include "DD4hep/InstanceCount.h"
-#include "DDG4/Geant4Context.h"
-#include "DDG4/Geant4Kernel.h"
+#include <DD4hep/Printout.h>
+#include <DD4hep/InstanceCount.h>
+#include <DDG4/Geant4Context.h>
+#include <DDG4/Geant4Kernel.h>
// C/C++ include files
#include <algorithm>
-using namespace std;
using namespace dd4hep;
using namespace dd4hep::sim;
@@ -101,9 +100,9 @@ Geant4Context::UserFramework& Geant4Context::userFramework() const {
/// Create a user trajectory
G4VTrajectory* Geant4Context::createTrajectory(const G4Track* /* track */) const {
- string err = dd4hep::format("Geant4Kernel", "createTrajectory: Purely virtual method. requires overloading!");
+ std::string err = dd4hep::format("Geant4Kernel", "createTrajectory: Purely virtual method. requires overloading!");
dd4hep::printout(dd4hep::FATAL, "Geant4Kernel", "createTrajectory: Purely virtual method. requires overloading!");
- throw runtime_error(err);
+ throw std::runtime_error(err);
}
/// Access the tracking manager
--
GitLab