Skip to content
Snippets Groups Projects
Commit a89e2061 authored by Shaun Roe's avatar Shaun Roe
Browse files

solve remaining warnings

parent eabc9885
No related branches found
No related tags found
1 merge request!425Solve clang warnings
Pipeline #11770846 passed
...@@ -12,6 +12,12 @@ GeoDeDuplicator::GeoIdMap GeoDeDuplicator::s_geoIds{}; ...@@ -12,6 +12,12 @@ GeoDeDuplicator::GeoIdMap GeoDeDuplicator::s_geoIds{};
namespace { namespace {
std::mutex s_mutex{}; std::mutex s_mutex{};
///typeis function uses simple arguments to typeid (not an expression) to avoid warnings
template<class A, class B>
bool
typeis(B && b){
return typeid(A) == typeid(b);
}
} }
void GeoDeDuplicator::setShapeDeDuplication(bool enable){ void GeoDeDuplicator::setShapeDeDuplication(bool enable){
...@@ -124,10 +130,10 @@ PVLink GeoDeDuplicator::clone(PVConstLink cloneMe) const { ...@@ -124,10 +130,10 @@ PVLink GeoDeDuplicator::clone(PVConstLink cloneMe) const {
for(unsigned int chNode =0; chNode < cloneMe->getNChildNodes(); ++chNode) { for(unsigned int chNode =0; chNode < cloneMe->getNChildNodes(); ++chNode) {
GeoIntrusivePtr<const GeoGraphNode>node{*cloneMe->getChildNode(chNode)}; GeoIntrusivePtr<const GeoGraphNode>node{*cloneMe->getChildNode(chNode)};
/** transform nodes */ /** transform nodes */
if (typeid(*node) == typeid(GeoAlignableTransform)) { if (typeis<GeoAlignableTransform>(*node)) {
const auto geoTrf = dynamic_pointer_cast<const GeoAlignableTransform>(node); const auto geoTrf = dynamic_pointer_cast<const GeoAlignableTransform>(node);
newVol->add(make_intrusive<GeoAlignableTransform>(geoTrf->getDefTransform())); newVol->add(make_intrusive<GeoAlignableTransform>(geoTrf->getDefTransform()));
} else if (typeid(*node) == typeid(GeoTransform)) { } else if (typeis<GeoTransform>(*node)) {
const auto geoTrf = dynamic_pointer_cast<const GeoTransform>(node); const auto geoTrf = dynamic_pointer_cast<const GeoTransform>(node);
auto geoTrfNonConst = const_pointer_cast(geoTrf); auto geoTrfNonConst = const_pointer_cast(geoTrf);
newVol->add(cacheTransform(geoTrfNonConst)); newVol->add(cacheTransform(geoTrfNonConst));
......
/* /*
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
*/ */
#include "GeoModelHelpers/cloneVolume.h" #include "GeoModelHelpers/cloneVolume.h"
#include "GeoModelHelpers/getChildNodesWithTrf.h" #include "GeoModelHelpers/getChildNodesWithTrf.h"
...@@ -7,18 +7,27 @@ ...@@ -7,18 +7,27 @@
#include "GeoModelKernel/GeoFullPhysVol.h" #include "GeoModelKernel/GeoFullPhysVol.h"
#include "GeoModelKernel/GeoPhysVol.h" #include "GeoModelKernel/GeoPhysVol.h"
namespace{
///typeis function uses simple arguments to typeid (not an expression) to avoid warnings
template<class A, class B>
bool
typeis(B && b){
return typeid(A) == typeid(b);
}
}
PVLink cloneVolume(const PVLink& volume, bool allowShared) { PVLink cloneVolume(const PVLink& volume, bool allowShared) {
PVLink newVolume{volume}; PVLink newVolume{volume};
if (!allowShared || hasFullPhysVolInTree(volume)) { if (!allowShared || hasFullPhysVolInTree(volume)) {
if (typeid(*volume) == typeid(GeoPhysVol)) { if (typeis<GeoPhysVol>(*volume)) {
newVolume = make_intrusive<GeoPhysVol>(volume->getLogVol()); newVolume = make_intrusive<GeoPhysVol>(volume->getLogVol());
} else if (typeid(*volume) == typeid(GeoFullPhysVol)) { } else if (typeis<GeoFullPhysVol>(*volume)) {
newVolume = make_intrusive<GeoFullPhysVol>(volume->getLogVol()); newVolume = make_intrusive<GeoFullPhysVol>(volume->getLogVol());
} }
for (unsigned int ch = 0; ch < volume->getNChildNodes(); ++ch){ for (unsigned int ch = 0; ch < volume->getNChildNodes(); ++ch){
const GeoGraphNode* node = (*volume->getChildNode(ch)); const GeoGraphNode* node = (*volume->getChildNode(ch));
if (typeid(*node) == typeid(GeoPhysVol) || typeid(*node) == typeid(GeoFullPhysVol)) { if (typeis<GeoPhysVol>(*node) || typeis<GeoFullPhysVol>(*node)) {
const GeoVPhysVol* childConstVol{static_cast<const GeoVPhysVol*>(node)}; const GeoVPhysVol* childConstVol{static_cast<const GeoVPhysVol*>(node)};
GeoVPhysVol* childVol{const_cast<GeoVPhysVol*>(childConstVol)}; GeoVPhysVol* childVol{const_cast<GeoVPhysVol*>(childConstVol)};
newVolume->add(cloneVolume(childVol, allowShared)); newVolume->add(cloneVolume(childVol, allowShared));
......
...@@ -12,6 +12,12 @@ ...@@ -12,6 +12,12 @@
namespace { namespace {
constexpr std::string_view dummyNodeName{"ANON"}; constexpr std::string_view dummyNodeName{"ANON"};
///typeis function uses simple arguments to typeid (not an expression) to avoid warnings
template<class A, class B>
bool
typeis(B && b){
return typeid(A) == typeid(b);
}
} }
...@@ -20,7 +26,7 @@ namespace { ...@@ -20,7 +26,7 @@ namespace {
volume{curs.getVolume()}, volume{curs.getVolume()},
nodeName{curs.getName()}, nodeName{curs.getName()},
isAlignable{curs.hasAlignableTransform()}, isAlignable{curs.hasAlignableTransform()},
isSensitive{typeid(*volume) == typeid(GeoFullPhysVol)}, isSensitive{typeis<GeoFullPhysVol>(*volume)},
volumeId{static_cast<const std::optional<int>&>(curs.getId())} { volumeId{static_cast<const std::optional<int>&>(curs.getId())} {
//// Do not specify a node name if it's a dummy one //// Do not specify a node name if it's a dummy one
if (nodeName == dummyNodeName) { if (nodeName == dummyNodeName) {
...@@ -95,8 +101,8 @@ std::vector<GeoChildNodeWithTrf> getAllSubVolumes(PVConstLink physVol) { ...@@ -95,8 +101,8 @@ std::vector<GeoChildNodeWithTrf> getAllSubVolumes(PVConstLink physVol) {
} }
bool hasFullPhysVolInTree(const PVConstLink& physVol) { bool hasFullPhysVolInTree(const PVConstLink& physVol) {
if (typeid(*physVol) == typeid(GeoFullPhysVol) || if (typeis<GeoFullPhysVol>(*physVol) ||
typeid(*physVol) == typeid(GeoVFullPhysVol)){ typeis<GeoVFullPhysVol>(*physVol)){
return true; return true;
} }
for (unsigned int ch = 0; ch < physVol->getNChildVols(); ++ch) { for (unsigned int ch = 0; ch < physVol->getNChildVols(); ++ch) {
......
...@@ -13,6 +13,15 @@ ...@@ -13,6 +13,15 @@
#include <GeoModelHelpers/getChildNodesWithTrf.h> #include <GeoModelHelpers/getChildNodesWithTrf.h>
#include <iostream> #include <iostream>
namespace{
///typeis function uses simple arguments to typeid (not an expression) to avoid warnings
template<class A>
const char*
safeTypeIdName(A && a){
return typeid(A).name();
}
}
int main(int argc, char *argv[]){ int main(int argc, char *argv[]){
GeoIntrusivePtr<GeoMaterial> material = make_intrusive<GeoMaterial>("Snow", 1.45); GeoIntrusivePtr<GeoMaterial> material = make_intrusive<GeoMaterial>("Snow", 1.45);
...@@ -90,7 +99,7 @@ int main(int argc, char *argv[]){ ...@@ -90,7 +99,7 @@ int main(int argc, char *argv[]){
std::optional<int> query = cParent->getIdOfChildVol(0); std::optional<int> query = cParent->getIdOfChildVol(0);
if (!query) { if (!query) {
std::cerr<<__FILE__<<":"<<__LINE__<<" Failed to obtain a valid child volume ID. Expected "<<currentK std::cerr<<__FILE__<<":"<<__LINE__<<" Failed to obtain a valid child volume ID. Expected "<<currentK
<<" "<<typeid(*cParent->getChildVol(0)).name()<<std::endl; <<" "<<safeTypeIdName(*cParent->getChildVol(0))<<std::endl;
return EXIT_FAILURE; return EXIT_FAILURE;
} }
unsigned int parentID = *query; unsigned int parentID = *query;
......
/* /*
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
*/ */
/* /*
...@@ -66,11 +66,11 @@ class GeoAnnulusSurface : public GeoVSurfaceShape ...@@ -66,11 +66,11 @@ class GeoAnnulusSurface : public GeoVSurfaceShape
// coming soon! // coming soon!
//bool isInside(double x, double y) const; //bool isInside(double x, double y) const;
virtual const std::string & type() const{ virtual const std::string & type() const override final{
return s_classType; return s_classType;
} }
virtual ShapeType typeID() const{ virtual ShapeType typeID() const override final{
return s_classTypeID; return s_classTypeID;
} }
......
/* /*
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
*/ */
#ifndef GEOMODELKERNEL_GEOCOUNTVOLACTION_H #ifndef GEOMODELKERNEL_GEOCOUNTVOLACTION_H
...@@ -14,13 +14,13 @@ class GeoCountVolAction : public GeoNodeAction ...@@ -14,13 +14,13 @@ class GeoCountVolAction : public GeoNodeAction
virtual ~GeoCountVolAction() = default; virtual ~GeoCountVolAction() = default;
// Handles a physical volume. // Handles a physical volume.
virtual void handlePhysVol (const GeoPhysVol *); virtual void handlePhysVol (const GeoPhysVol *) override;
// Handles a physical volume. // Handles a physical volume.
virtual void handleFullPhysVol (const GeoFullPhysVol *); virtual void handleFullPhysVol (const GeoFullPhysVol *) override;
// Handles a Serial Transformer // Handles a Serial Transformer
virtual void handleSerialTransformer (const GeoSerialTransformer *st); virtual void handleSerialTransformer (const GeoSerialTransformer *st) override;
// Handles a virtual surface. // Handles a virtual surface.
virtual void handleVSurface (const GeoVSurface *) override; virtual void handleVSurface (const GeoVSurface *) override;
......
/* /*
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
*/ */
/* /*
...@@ -54,11 +54,11 @@ class GeoDiamondSurface : public GeoVSurfaceShape ...@@ -54,11 +54,11 @@ class GeoDiamondSurface : public GeoVSurfaceShape
return m_YtopHalf; return m_YtopHalf;
} }
virtual const std::string & type () const{ virtual const std::string & type () const override final{
return s_classType; return s_classType;
} }
virtual ShapeType typeID () const{ virtual ShapeType typeID () const override final{
return s_classTypeID; return s_classTypeID;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment