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{};
namespace {
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){
......@@ -124,10 +130,10 @@ PVLink GeoDeDuplicator::clone(PVConstLink cloneMe) const {
for(unsigned int chNode =0; chNode < cloneMe->getNChildNodes(); ++chNode) {
GeoIntrusivePtr<const GeoGraphNode>node{*cloneMe->getChildNode(chNode)};
/** transform nodes */
if (typeid(*node) == typeid(GeoAlignableTransform)) {
if (typeis<GeoAlignableTransform>(*node)) {
const auto geoTrf = dynamic_pointer_cast<const GeoAlignableTransform>(node);
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);
auto geoTrfNonConst = const_pointer_cast(geoTrf);
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/getChildNodesWithTrf.h"
......@@ -7,18 +7,27 @@
#include "GeoModelKernel/GeoFullPhysVol.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 newVolume{volume};
if (!allowShared || hasFullPhysVolInTree(volume)) {
if (typeid(*volume) == typeid(GeoPhysVol)) {
if (typeis<GeoPhysVol>(*volume)) {
newVolume = make_intrusive<GeoPhysVol>(volume->getLogVol());
} else if (typeid(*volume) == typeid(GeoFullPhysVol)) {
} else if (typeis<GeoFullPhysVol>(*volume)) {
newVolume = make_intrusive<GeoFullPhysVol>(volume->getLogVol());
}
for (unsigned int ch = 0; ch < volume->getNChildNodes(); ++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)};
GeoVPhysVol* childVol{const_cast<GeoVPhysVol*>(childConstVol)};
newVolume->add(cloneVolume(childVol, allowShared));
......
......@@ -12,6 +12,12 @@
namespace {
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 {
volume{curs.getVolume()},
nodeName{curs.getName()},
isAlignable{curs.hasAlignableTransform()},
isSensitive{typeid(*volume) == typeid(GeoFullPhysVol)},
isSensitive{typeis<GeoFullPhysVol>(*volume)},
volumeId{static_cast<const std::optional<int>&>(curs.getId())} {
//// Do not specify a node name if it's a dummy one
if (nodeName == dummyNodeName) {
......@@ -95,8 +101,8 @@ std::vector<GeoChildNodeWithTrf> getAllSubVolumes(PVConstLink physVol) {
}
bool hasFullPhysVolInTree(const PVConstLink& physVol) {
if (typeid(*physVol) == typeid(GeoFullPhysVol) ||
typeid(*physVol) == typeid(GeoVFullPhysVol)){
if (typeis<GeoFullPhysVol>(*physVol) ||
typeis<GeoVFullPhysVol>(*physVol)){
return true;
}
for (unsigned int ch = 0; ch < physVol->getNChildVols(); ++ch) {
......
......@@ -13,6 +13,15 @@
#include <GeoModelHelpers/getChildNodesWithTrf.h>
#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[]){
GeoIntrusivePtr<GeoMaterial> material = make_intrusive<GeoMaterial>("Snow", 1.45);
......@@ -90,7 +99,7 @@ int main(int argc, char *argv[]){
std::optional<int> query = cParent->getIdOfChildVol(0);
if (!query) {
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;
}
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
// coming soon!
//bool isInside(double x, double y) const;
virtual const std::string & type() const{
virtual const std::string & type() const override final{
return s_classType;
}
virtual ShapeType typeID() const{
virtual ShapeType typeID() const override final{
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
......@@ -14,13 +14,13 @@ class GeoCountVolAction : public GeoNodeAction
virtual ~GeoCountVolAction() = default;
// Handles a physical volume.
virtual void handlePhysVol (const GeoPhysVol *);
virtual void handlePhysVol (const GeoPhysVol *) override;
// Handles a physical volume.
virtual void handleFullPhysVol (const GeoFullPhysVol *);
virtual void handleFullPhysVol (const GeoFullPhysVol *) override;
// Handles a Serial Transformer
virtual void handleSerialTransformer (const GeoSerialTransformer *st);
virtual void handleSerialTransformer (const GeoSerialTransformer *st) override;
// Handles a virtual surface.
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
return m_YtopHalf;
}
virtual const std::string & type () const{
virtual const std::string & type () const override final{
return s_classType;
}
virtual ShapeType typeID () const{
virtual ShapeType typeID () const override final{
return s_classTypeID;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment