Skip to content
Snippets Groups Projects
Commit 31b06a17 authored by Frank Winklmeier's avatar Frank Winklmeier
Browse files

Merge branch 'checkAuxID.AthContainers-20240423' into 'main'

AthContainers: Add AuxTypeRegistry::checkAuxID.

See merge request !70804
parents bf54abc5 3cd5bcc5
No related branches found
No related tags found
33 merge requests!78241Draft: FPGATrackSim: GenScan code refactor,!78236Draft: Switching Streams https://its.cern.ch/jira/browse/ATR-27417,!78056AFP monitoring: new synchronization and cleaning,!78041AFP monitoring: new synchronization and cleaning,!77990Updating TRT chip masks for L1TRT trigger simulation - ATR-28372,!77733Draft: add new HLT NN JVT, augmented with additional tracking information,!77731Draft: Updates to ZDC reconstruction,!77728Draft: updates to ZDC reconstruction,!77522Draft: sTGC Pad Trigger Emulator,!76725ZdcNtuple: Fix cppcheck warning.,!76611L1CaloFEXByteStream: Fix out-of-bounds array accesses.,!76475Punchthrough AF3 implementation in FastG4,!76474Punchthrough AF3 implementation in FastG4,!76343Draft: MooTrackBuilder: Recalibrate NSW hits in refine method,!75729New implementation of ZDC nonlinear FADC correction.,!75703Draft: Update to HI han config for HLT jets,!75184Draft: Update file heavyions_run.config,!74430Draft: Fixing upper bound for Delayed Jet Triggers,!73963Changing the path of the histograms to "Expert" area,!73875updating ID ART reference plots,!73874AtlasCLHEP_RandomGenerators: Fix cppcheck warnings.,!73449Add muon detectors to DarkJetPEBTLA partial event building,!73343Draft: [TrigEgamma] Add photon ringer chains on bootstrap mechanism,!72972Update L1Calo Jet Trigger Efficiency Monitoring algorithm,!72336Fixed TRT calibration crash,!72176Draft: Improving L1TopoOnline chain that now gets no-empty plots. Activating it by default,!72012Draft: Separate JiveXMLConfig.py into Config files,!71876Fix MET trigger name in MissingETMonitoring,!71820Draft: Adding new TLA End-Of-Fill (EOF) chains and removing obsolete DIPZ chains,!71279Draft: ATR-29330: Move L1_4J15 and the HLT chains seeded by it in the MC Menu,!70990Updates to pulse analysis to support new 2016 p+Pb analysis and 2023 Pb+Pb analysis,!70948[TrigEGam] Adding egamma chains to be monitored,!70804AthContainers: Add AuxTypeRegistry::checkAuxID.
// This file's extension implies that it's C, but it's really -*- C++ -*-.
/*
Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
*/
/**
* @file AthContainers/AuxTypeRegistry.h
......@@ -90,7 +89,7 @@ public:
* The type of the item is given by the template parameter @c T,
* and the @c ALLOC gives the type of the vector allocator.
* If an item with the same name was previously requested
* with a different type, then raise @c SG::ExcAuxTypeMismatch.
* with a different type, then throw @c SG::ExcAuxTypeMismatch.
*/
template <class T, class ALLOC = AuxAllocator_t<T> >
SG::auxid_t getAuxID (const std::string& name,
......@@ -109,7 +108,7 @@ public:
* Return @c null_auxid if we don't know how to make vectors of @a ti.
* (Use @c addFactory to register additional types.)
* If an item with the same name was previously requested
* with a different type, then raise @c SG::ExcAuxTypeMismatch.
* with a different type, then throw @c SG::ExcAuxTypeMismatch.
*/
SG::auxid_t getAuxID (const std::type_info& ti,
const std::string& name,
......@@ -129,7 +128,7 @@ public:
* Return @c null_auxid if we don't know how to make vectors of @a ti.
* (Use @c addFactory to register additional types.)
* If an item with the same name was previously requested
* with a different type, then raise @c SG::ExcAuxTypeMismatch.
* with a different type, then throw @c SG::ExcAuxTypeMismatch.
*/
SG::auxid_t getAuxID (const std::type_info& ti_alloc,
const std::type_info& ti,
......@@ -150,7 +149,7 @@ public:
* Return @c null_auxid if we don't know how to make vectors of @a ti.
* (Use @c addFactory to register additional types.)
* If an item with the same name was previously requested
* with a different type, then raise @c SG::ExcAuxTypeMismatch.
* with a different type, then throw @c SG::ExcAuxTypeMismatch.
*/
SG::auxid_t getAuxID (const std::string& alloc_type,
const std::type_info& ti,
......@@ -171,7 +170,38 @@ public:
SG::auxid_t findAuxID( const std::string& name,
const std::string& clsname = "") const;
/**
* @brief Verify type for an aux variable.
* @param auxid The ID of the variable to check.
* @param flags Optional flags qualifying the type. See above.
*
* If the type of @c auxid is not compatible with the supplied
* types @c T / @c ALLOC, then throw a @c SG::ExcAuxTypeMismatch exception.
* Also may throw @c SG::ExcAtomicMismatch.
*/
template <class T, class ALLOC = AuxAllocator_t<T> >
void checkAuxID (const SG::auxid_t auxid,
const Flags flags = Flags::None);
/**
* @brief Verify type for an aux variable.
* @param auxid The ID of the variable to check.
* @param ti Type of the aux data item.
* @param ti_alloc Type of the vector allocator.
* @param flags Optional flags qualifying the type. See above.
*
* If the type of @c auxid is not compatible with the supplied
* types @c ti / @c ti_alloc, then throw a @c SG::ExcAuxTypeMismatch exception.
* Also may throw @c SG::ExcAtomicMismatch.
*/
void checkAuxID (const SG::auxid_t auxid,
const std::type_info& ti,
const std::type_info& ti_alloc,
const Flags flags);
/**
* @brief Construct a new vector to hold an aux item.
* @param auxid The desired aux data item.
......@@ -493,7 +523,7 @@ private:
*
* If the aux data item already exists, check to see if the provided
* type matches the type that was used before. If so, then set
* return the auxid; otherwise, raise @c SG::ExcAuxTypeMismatch.
* return the auxid; otherwise, throw @c SG::ExcAuxTypeMismatch.
*
* If the aux data item does not already exist, then see if we
* have a factory registered for this @c type_info. If not, then
......
......@@ -21,7 +21,7 @@ namespace SG {
* The type of the item is given by the template parameter @c T,
* and the @c ALLOC gives the type of the vector allocator.
* If an item with the same name was previously requested
* with a different type, then raise an @c AuxTypeMismatch exception.
* with a different type, then throw an @c AuxTypeMismatch exception.
*/
template <class T, class ALLOC>
SG::auxid_t
......@@ -34,6 +34,24 @@ AuxTypeRegistry::getAuxID (const std::string& name,
}
/**
* @brief Verify type for an aux variable.
* @param auxid The ID of the variable to check.
* @param flags Optional flags qualifying the type. See above.
*
* If the type of @c auxid is not compatible with the supplied
* types @c T / @c ALLOC, then throw a @c SG::ExcAuxTypeMismatch exception.
* Also may throw @c SG::ExcAtomicMismatch.
*/
template <class T, class ALLOC>
void
AuxTypeRegistry::checkAuxID (const SG::auxid_t auxid,
const Flags flags /*= Flags::None*/)
{
return checkAuxID (auxid, typeid(T), typeid(ALLOC), flags);
}
/**
* @brief Return the vector factory for a given auxid.
* @param auxid The desired aux data item.
......
......@@ -76,7 +76,7 @@ size_t AuxTypeRegistry::numVariables() const
* Return @c null_auxid if we don't know how to make vectors of @a ti.
* (Use @c addFactory to register additional types.)
* If an item with the same name was previously requested
* with a different type, then raise @c SG::ExcAuxTypeMismatch.
* with a different type, then throw @c SG::ExcAuxTypeMismatch.
*/
SG::auxid_t AuxTypeRegistry::getAuxID (const std::type_info& ti,
const std::string& name,
......@@ -100,7 +100,7 @@ SG::auxid_t AuxTypeRegistry::getAuxID (const std::type_info& ti,
* Return @c null_auxid if we don't know how to make vectors of @a ti.
* (Use @c addFactory to register additional types.)
* If an item with the same name was previously requested
* with a different type, then raise @c SG::ExcAuxTypeMismatch.
* with a different type, then throw @c SG::ExcAuxTypeMismatch.
*/
SG::auxid_t AuxTypeRegistry::getAuxID (const std::type_info& ti_alloc,
const std::type_info& ti,
......@@ -125,7 +125,7 @@ SG::auxid_t AuxTypeRegistry::getAuxID (const std::type_info& ti_alloc,
* Return @c null_auxid if we don't know how to make vectors of @a ti.
* (Use @c addFactory to register additional types.)
* If an item with the same name was previously requested
* with a different type, then raise @c SG::ExcAuxTypeMismatch.
* with a different type, then throw @c SG::ExcAuxTypeMismatch.
*/
SG::auxid_t AuxTypeRegistry::getAuxID (const std::string& alloc_type,
const std::type_info& ti,
......@@ -164,6 +164,39 @@ AuxTypeRegistry::findAuxID( const std::string& name,
}
/**
* @brief Verify type for an aux variable.
* @param auxid The ID of the variable to check.
* @param ti Type of the aux data item.
* @param ti_alloc Type of the vector allocator.
* @param flags Optional flags qualifying the type. See above.
*
* If the type of @c auxid is not compatible with the supplied
* types @c ti / @c ti_alloc, then throw a @c SG::ExcAuxTypeMismatch exception.
* Also may throw @c SG::ExcAtomicMismatch.
*/
void AuxTypeRegistry::checkAuxID (const SG::auxid_t auxid,
const std::type_info& ti,
const std::type_info& ti_alloc,
const Flags flags)
{
typeinfo_t& m = m_types.at (auxid);
if ( ! ((&ti == m.m_ti || strcmp(ti.name(), m.m_ti->name()) == 0) &&
m.checkAlloc (&ti_alloc, nullptr)))
{
throw SG::ExcAuxTypeMismatch (auxid, ti, *m.m_ti,
SG::normalizedTypeinfoName (ti_alloc),
m.m_alloc_name);
}
if (CxxUtils::test (m.m_flags, Flags::Atomic) &&
!CxxUtils::test (flags, Flags::Atomic))
{
throw SG::ExcAtomicMismatch (auxid, ti);
}
}
/**
* @brief Construct a new vector to hold an aux item.
* @param auxid The desired aux data item.
......@@ -685,7 +718,7 @@ AuxTypeRegistry::~AuxTypeRegistry()
*
* If the aux data item already exists, check to see if the provided
* type matches the type that was used before. If so, then set
* return the auxid; otherwise, raise @c SG::ExcAuxTypeMismatch.
* return the auxid; otherwise, throw @c SG::ExcAuxTypeMismatch.
*
* If the aux data item does not already exist, then see if we
* have a factory registered for this @c type_info. If not, then
......
......@@ -130,6 +130,9 @@ void test_type(const std::string& typname,
EXPECT_EXCEPTION (SG::ExcAuxTypeMismatch, r.getAuxID<char> (name, clsname));
r.checkAuxID<T> (auxid);
EXPECT_EXCEPTION (SG::ExcAuxTypeMismatch, r.checkAuxID<char> (auxid));
r.getAuxID<char> (name, "otherclass");
assert (r.getName (auxid) == name);
......@@ -489,6 +492,7 @@ void test_atomic()
assert (r.getFlags (auxid2) == SG::AuxVarFlags::Atomic);
EXPECT_EXCEPTION (SG::ExcAtomicMismatch, r.getAuxID<int> ("atest2"));
EXPECT_EXCEPTION (SG::ExcAtomicMismatch, r.checkAuxID<int> (auxid2));
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment