Skip to content
Snippets Groups Projects
Commit c04bd9d5 authored by Vakhtang Tsulaia's avatar Vakhtang Tsulaia
Browse files

Fixed cppcheck warnings in GeoModelXml

Porting Scott's changes from Athena (MR!47594)
parent c79cae7c
No related branches found
No related tags found
1 merge request!104Ported several code changes from the Athena version of GeoModelXml
Showing
with 41 additions and 28 deletions
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
*/
//
......@@ -19,8 +19,10 @@ class Element2GeoItemRegistry {
public:
Element2GeoItemRegistry();
~Element2GeoItemRegistry();
void enregister(const std::string tagName, Element2GeoItem *processor); // register = keyword
Element2GeoItem *find(const std::string tagName);
Element2GeoItemRegistry(const Element2GeoItemRegistry&) = delete;
Element2GeoItemRegistry& operator=(const Element2GeoItemRegistry&) = delete;
void enregister(const std::string& tagName, Element2GeoItem *processor); // register = keyword
Element2GeoItem *find(const std::string& tagName);
private:
Element2GeoItem *m_defaultProcessor;
......
......@@ -58,7 +58,7 @@ class Evaluator;
class Gmx2Geo {
public:
Gmx2Geo(const std::string gmxFile, GeoPhysVol *addHere, GmxInterface &gmxInterface, unsigned int flags = 0, bool useMatManager = 0,const processorList& procs=processorList());
Gmx2Geo(const std::string& gmxFile, GeoPhysVol *addHere, GmxInterface &gmxInterface, unsigned int flags = 0, bool useMatManager = 0,const processorList& procs=processorList());
private:
// Disallow copying
Gmx2Geo(const Gmx2Geo &right);
......
......@@ -25,9 +25,9 @@ class GmxInterface {
public:
virtual int sensorId(std::map<std::string, int> &index) const;
virtual int splitSensorId(std::map<std::string, int> &index, std::pair<std::string, int> &extraIndex, std::map<std::string, int> &updatedIndex) const; //For "artificially" adding to Identifiers; specify the field (e.g. "eta_module") and the value to add
virtual void addSensorType(std::string type, std::string name, std::map<std::string, std::string> parameters);
virtual void addSensor(std::string name, std::map<std::string, int> &index, int id, GeoVFullPhysVol *fpv);
virtual void addSplitSensor(std::string name, std::map<std::string, int> &index, std::pair<std::string, int> &extraIndex, int id, GeoVFullPhysVol *fpv);
virtual void addSensorType(const std::string& cls, const std::string& type, const std::map<std::string, std::string>& parameters);
virtual void addSensor(const std::string& name, std::map<std::string, int> &index, int id, GeoVFullPhysVol *fpv);
virtual void addSplitSensor(const std::string& name, std::map<std::string, int> &index, std::pair<std::string, int> &extraIndex, int id, GeoVFullPhysVol *fpv);
virtual void addAlignable(int level, std::map<std::string, int> &index,
GeoVFullPhysVol *fpv, GeoAlignableTransform *transform);
......
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
*/
//
......@@ -34,10 +34,10 @@ public:
int copyNo(int level);
int setCopyNo(int copyNo);
void addIndex(std::string name);
void addIndex(const std::string& name);
std::string name(int whichOne);
std::string formula(std::string name);
void setFormula(std::string name, std::string formula);
std::string formula(const std::string& name);
void setFormula(const std::string& name, const std::string& formula);
void indices(std::map<std::string, int> &index, Evaluator &eval);
......
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
*/
//
......@@ -19,8 +19,10 @@ class ElementProcessor;
class ProcessorRegistry {
public:
ProcessorRegistry();
void enregister(const std::string tagName, ElementProcessor *processor);
ElementProcessor *find(const std::string name);
ProcessorRegistry(const ProcessorRegistry&) = delete;
ProcessorRegistry& operator=(const ProcessorRegistry&) = delete;
void enregister(const std::string& tagName, ElementProcessor *processor);
ElementProcessor *find(const std::string& name);
private:
ElementProcessor *m_defaultProcessor;
......
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
*/
#include "GeoModelXml/Element2GeoItemRegistry.h"
......@@ -13,11 +13,11 @@ Element2GeoItemRegistry::~Element2GeoItemRegistry() {
delete m_defaultProcessor;
}
void Element2GeoItemRegistry::enregister(const std::string tagName, Element2GeoItem *processor) {
void Element2GeoItemRegistry::enregister(const std::string& tagName, Element2GeoItem *processor) {
m_processor[tagName] = processor;
}
Element2GeoItem * Element2GeoItemRegistry::find(const std::string name) {
Element2GeoItem * Element2GeoItemRegistry::find(const std::string& name) {
std::map<std::string, Element2GeoItem *>::iterator it = m_processor.find(name);
return it == m_processor.end()? m_defaultProcessor: it->second;
......
......@@ -30,7 +30,7 @@
using namespace std;
using namespace xercesc;
Gmx2Geo::Gmx2Geo(const string xmlFile, GeoPhysVol *addHere, GmxInterface &gmxInterface, unsigned int flags, bool useMatManager, const processorList& procs) {
Gmx2Geo::Gmx2Geo(const string& xmlFile, GeoPhysVol *addHere, GmxInterface &gmxInterface, unsigned int flags, bool useMatManager, const processorList& procs) {
//
// Create the xml tree (DOMDocument)
//
......
......@@ -26,16 +26,16 @@ int GmxInterface::splitSensorId(map<string, int> &/*index*/, std::pair<std::stri
return sequentialId++;
}
void GmxInterface::addSensorType(string clas, string type, map<string, string> params) {
void GmxInterface::addSensorType(const string& clas, const string& type, const map<string, string>& params) {
msglog << MSG::DEBUG << "GmxInterface::addSensorType called for class " << clas << "; type " << type <<
"\n Parameter names and values:\n";
for (map<string, string>::iterator p = params.begin(); p != params.end(); ++p) {
for (map<string, string>::const_iterator p = params.begin(); p != params.end(); ++p) {
msglog << " " << p->first << " = " << p->second << endmsg;
}
}
void GmxInterface::addSensor(string name, map<string, int> &index, int sequentialId, GeoVFullPhysVol *fpv) {
void GmxInterface::addSensor(const string& name, map<string, int> &index, int sequentialId, GeoVFullPhysVol *fpv) {
msglog << MSG::DEBUG << "GmxInterface::addSensor called for " << fpv->getLogVol()->getName() << ", type " << name <<
". Indices: ";
......@@ -45,7 +45,7 @@ void GmxInterface::addSensor(string name, map<string, int> &index, int sequentia
msglog << "\nSequential ID = " << sequentialId << endmsg;
}
void GmxInterface::addSplitSensor(string name, map<string, int> &index, std::pair<std::string, int> &extraIndex, int sequentialId, GeoVFullPhysVol *fpv) {
void GmxInterface::addSplitSensor(const string& name, map<string, int> &index, std::pair<std::string, int> &extraIndex, int sequentialId, GeoVFullPhysVol *fpv) {
msglog << MSG::DEBUG << "GmxInterface::addSensor called for " << fpv->getLogVol()->getName() << ", type " << name <<
". Indices: ";
......
......@@ -56,6 +56,9 @@ RCBase * MakeIntersection::make(const xercesc::DOMElement *element, GmxUtil &gmx
elementIndex++;
}
}
if (!first || !second) std::abort();
// FIXME: intersect() returns a new'd object --- should really be
// returning a `unique_ptr<GeoShapeIntersection>' not a
// `const GeoShapeIntersection'
......
......@@ -57,6 +57,9 @@ RCBase * MakeSubtraction::make(const xercesc::DOMElement *element, GmxUtil &gmxU
elementIndex++;
}
}
if (!first || !second) std::abort();
// FIXME: subtract() returns a new'd object --- should really be
// returning a `unique_ptr<GeoShapeSubtraction>' not a
// `const GeoShapeSubtraction'
......
......@@ -55,6 +55,9 @@ RCBase * MakeUnion::make(const xercesc::DOMElement *element, GmxUtil &gmxUtil) c
elementIndex++;
}
}
if (!first || !second) std::abort();
// FIXME: add() returns a new'd object --- should really be
// returning a `unique_ptr<GeoShapeUnion>' not a
// `const GeoShapeUnion'
......
......@@ -46,7 +46,7 @@ int PositionIndex::setCopyNo(int copyNo) {
return m_copyNo[m_level];
}
void PositionIndex::addIndex(std::string name) {
void PositionIndex::addIndex(const std::string& name) {
m_name.push_back(name);
m_formula[name] = "0";
}
......@@ -60,11 +60,11 @@ string PositionIndex::name(int whichOne) {
}
}
std::string PositionIndex::formula(std::string name) {
std::string PositionIndex::formula(const std::string& name) {
return m_formula[name];
}
void PositionIndex::setFormula(std::string name, std::string formula) {
void PositionIndex::setFormula(const std::string& name, const std::string& formula) {
m_formula[name] = formula;
}
......
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
*/
#include "GeoModelXml/ProcessorRegistry.h"
......@@ -9,11 +9,11 @@ ProcessorRegistry::ProcessorRegistry() {
m_defaultProcessor = new ElementProcessor();
}
void ProcessorRegistry::enregister(const std::string tagName, ElementProcessor *processor) {
void ProcessorRegistry::enregister(const std::string& tagName, ElementProcessor *processor) {
m_processor[tagName] = processor;
}
ElementProcessor * ProcessorRegistry::find(const std::string name) {
ElementProcessor * ProcessorRegistry::find(const std::string& name) {
std::map<std::string, ElementProcessor *>::iterator it = m_processor.find(name);
return it == m_processor.end()? m_defaultProcessor: it->second;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment