diff --git a/Control/AthContainers/AthContainers/Accessor.h b/Control/AthContainers/AthContainers/Accessor.h index 6db58ed034d1cb5580a1e09d63c0f23d52d88086..4fc111a2434df01677c4ed2d2433fa758ca7d891 100644 --- a/Control/AthContainers/AthContainers/Accessor.h +++ b/Control/AthContainers/AthContainers/Accessor.h @@ -102,6 +102,15 @@ public: Accessor (const std::string& name, const std::string& clsname); + /** + * @brief Constructor taking an auxid directly. + * @param auxid ID for this auxiliary variable. + * + * Will throw @c SG::ExcAuxTypeMismatch if the types don't match. + */ + Accessor (const SG::auxid_t auxid); + + /** * @brief Fetch the variable for one element, as a non-const reference. * @param e The element for which to fetch the variable. diff --git a/Control/AthContainers/AthContainers/Accessor.icc b/Control/AthContainers/AthContainers/Accessor.icc index 581e6cea53235614563670c488e917a5ba0b30ba..f8f60313a019979ed5957505661ef883b1b1c65b 100644 --- a/Control/AthContainers/AthContainers/Accessor.icc +++ b/Control/AthContainers/AthContainers/Accessor.icc @@ -46,6 +46,20 @@ Accessor<T, ALLOC>::Accessor (const std::string& name, } +/** + * @brief Constructor taking an auxid directly. + * @param auxid ID for this auxiliary variable. + * + * Will throw @c SG::ExcAuxTypeMismatch if the types don't match. + */ +template <class T, class ALLOC> +inline +Accessor<T, ALLOC>::Accessor (const SG::auxid_t auxid) + : ConstAccessor<T, ALLOC> (auxid) +{ +} + + /** * @brief Fetch the variable for one element, as a non-const reference. * @param e The element for which to fetch the variable. diff --git a/Control/AthContainers/AthContainers/ConstAccessor.h b/Control/AthContainers/AthContainers/ConstAccessor.h index 30e17dcf9714295b380b615aec1860aa665d7bd6..ba875ddf742e2809e70f973df9fcbf8804666792 100644 --- a/Control/AthContainers/AthContainers/ConstAccessor.h +++ b/Control/AthContainers/AthContainers/ConstAccessor.h @@ -87,6 +87,15 @@ public: ConstAccessor (const std::string& name, const std::string& clsname); + /** + * @brief Constructor taking an auxid directly. + * @param auxid ID for this auxiliary variable. + * + * Will throw @c SG::ExcAuxTypeMismatch if the types don't match. + */ + ConstAccessor (const SG::auxid_t auxid); + + /** * @brief Fetch the variable for one element, as a const reference. * @param e The element for which to fetch the variable. @@ -154,6 +163,17 @@ protected: const SG::AuxVarFlags flags); + /** + * @brief Constructor taking an auxid directly. + * @param auxid ID for this auxiliary variable. + * @param flags Optional flags qualifying the type. See AuxTypeRegistry. + * + * Will throw @c SG::ExcAuxTypeMismatch if the types don't match. + */ + ConstAccessor (const SG::auxid_t auxid, + const SG::AuxVarFlags flags); + + /// The cached @c auxid. SG::auxid_t m_auxid; }; diff --git a/Control/AthContainers/AthContainers/ConstAccessor.icc b/Control/AthContainers/AthContainers/ConstAccessor.icc index f6329f804b6729f7bd4b3ed79460e1ac8e84dcca..34285288362832ebe1c63dcf9749e63f43144128 100644 --- a/Control/AthContainers/AthContainers/ConstAccessor.icc +++ b/Control/AthContainers/AthContainers/ConstAccessor.icc @@ -47,6 +47,20 @@ ConstAccessor<T, ALLOC>::ConstAccessor } +/** + * @brief Constructor taking an auxid directly. + * @param auxid ID for this auxiliary variable. + * + * Will throw @c SG::ExcAuxTypeMismatch if the types don't match. + */ +template <class T, class ALLOC> +inline +ConstAccessor<T, ALLOC>::ConstAccessor (const SG::auxid_t auxid) + : ConstAccessor (auxid, SG::AuxVarFlags::None) +{ +} + + /** * @brief Constructor. * @param name Name of this aux variable. @@ -66,6 +80,22 @@ ConstAccessor<T, ALLOC>::ConstAccessor } +/** + * @brief Constructor taking an auxid directly. + * @param auxid ID for this auxiliary variable. + * + * Will throw @c SG::ExcAuxTypeMismatch if the types don't match. + */ +template <class T, class ALLOC> +inline +ConstAccessor<T, ALLOC>::ConstAccessor (const SG::auxid_t auxid, + const SG::AuxVarFlags flags) + : m_auxid (auxid) +{ + SG::AuxTypeRegistry::instance().checkAuxID<T, ALLOC> (auxid, flags); +} + + /** * @brief Fetch the variable for one element, as a const reference. * @param e The element for which to fetch the variable. diff --git a/Control/AthContainers/AthContainers/Decorator.h b/Control/AthContainers/AthContainers/Decorator.h index 27c66badb331f599d9949e5a3673ea028ec81699..68ddf299f5d70c4b1df20a7ffa0e09c77028c357 100644 --- a/Control/AthContainers/AthContainers/Decorator.h +++ b/Control/AthContainers/AthContainers/Decorator.h @@ -93,6 +93,15 @@ public: Decorator (const std::string& name, const std::string& clsname); + /** + * @brief Constructor taking an auxid directly. + * @param auxid ID for this auxiliary variable. + * + * Will throw @c SG::ExcAuxTypeMismatch if the types don't match. + */ + Decorator (const SG::auxid_t auxid); + + /** * @brief Fetch the variable for one element, as a non-const reference. * @param e The element for which to fetch the variable. @@ -209,6 +218,17 @@ protected: const SG::AuxVarFlags flags); + /** + * @brief Constructor taking an auxid directly. + * @param auxid ID for this auxiliary variable. + * @param flags Optional flags qualifying the type. See AuxTypeRegistry. + * + * Will throw @c SG::ExcAuxTypeMismatch if the types don't match. + */ + Decorator (const SG::auxid_t auxid, + const SG::AuxVarFlags flags); + + private: /// The cached @c auxid. SG::auxid_t m_auxid; diff --git a/Control/AthContainers/AthContainers/Decorator.icc b/Control/AthContainers/AthContainers/Decorator.icc index bdb99f63fb54be86d4111a446884d9dcb198812b..85f78f9ad1149ec77b5d1b2eddd705d67513420b 100644 --- a/Control/AthContainers/AthContainers/Decorator.icc +++ b/Control/AthContainers/AthContainers/Decorator.icc @@ -46,6 +46,20 @@ Decorator<T, ALLOC>::Decorator (const std::string& name, } +/** + * @brief Constructor taking an auxid directly. + * @param auxid ID for this auxiliary variable. + * + * Will throw @c SG::ExcAuxTypeMismatch if the types don't match. + */ +template <class T, class ALLOC> +inline +Decorator<T, ALLOC>::Decorator (const SG::auxid_t auxid) + : Decorator (auxid, SG::AuxVarFlags::None) +{ +} + + /** * @brief Constructor. * @param name Name of this aux variable. @@ -65,6 +79,23 @@ Decorator<T, ALLOC>::Decorator } +/** + * @brief Constructor taking an auxid directly. + * @param auxid ID for this auxiliary variable. + * @param flags Optional flags qualifying the type. See AuxTypeRegistry. + * + * Will throw @c SG::ExcAuxTypeMismatch if the types don't match. + */ +template <class T, class ALLOC> +inline +Decorator<T, ALLOC>::Decorator (const SG::auxid_t auxid, + const SG::AuxVarFlags flags) + : m_auxid (auxid) +{ + SG::AuxTypeRegistry::instance().checkAuxID<T, ALLOC> (auxid, flags); +} + + /** * @brief Fetch the variable for one element, as a non-const reference. * @param e The element for which to fetch the variable. diff --git a/Control/AthContainers/AthContainers/tools/AtomicConstAccessor.h b/Control/AthContainers/AthContainers/tools/AtomicConstAccessor.h index 9b86b4f6d9949cbe88845c07a501a35971b3fbc7..0127cce4e64fba77b0d3db157204d5d0298a5156 100644 --- a/Control/AthContainers/AthContainers/tools/AtomicConstAccessor.h +++ b/Control/AthContainers/AthContainers/tools/AtomicConstAccessor.h @@ -88,6 +88,15 @@ public: AtomicConstAccessor (const std::string& name, const std::string& clsname); + /** + * @brief Constructor taking an auxid directly. + * @param auxid ID for this auxiliary variable. + * + * Will throw @c SG::ExcAuxTypeMismatch if the types don't match. + */ + AtomicConstAccessor (const SG::auxid_t auxid); + + /** * @brief Fetch the variable for one element, as a const reference. * @param e The element for which to fetch the variable. diff --git a/Control/AthContainers/AthContainers/tools/AtomicConstAccessor.icc b/Control/AthContainers/AthContainers/tools/AtomicConstAccessor.icc index 395137ed18ff2590393be4f1a97f2a09d335a58e..6cd98c0e8e2f2b85fb70c21dd4563d47fa8c3511 100644 --- a/Control/AthContainers/AthContainers/tools/AtomicConstAccessor.icc +++ b/Control/AthContainers/AthContainers/tools/AtomicConstAccessor.icc @@ -43,6 +43,20 @@ AtomicConstAccessor<T>::AtomicConstAccessor (const std::string& name, } +/** + * @brief Constructor taking an auxid directly. + * @param auxid ID for this auxiliary variable. + * + * Will throw @c SG::ExcAuxTypeMismatch if the types don't match. + */ +template <class T> +inline +AtomicConstAccessor<T>::AtomicConstAccessor (const SG::auxid_t auxid) + : Base (auxid, SG::AuxVarFlags::Atomic) +{ +} + + /** * @brief Fetch the variable for one element, as a const reference. * @param e The element for which to fetch the variable. diff --git a/Control/AthContainers/AthContainers/tools/AtomicDecorator.h b/Control/AthContainers/AthContainers/tools/AtomicDecorator.h index 8da37ff63b24ef5743ce19877b910590503554a6..bf6523b4c9412f4930d77a4b37d4116e81a89abd 100644 --- a/Control/AthContainers/AthContainers/tools/AtomicDecorator.h +++ b/Control/AthContainers/AthContainers/tools/AtomicDecorator.h @@ -91,6 +91,15 @@ public: AtomicDecorator (const std::string& name, const std::string& clsname); + /** + * @brief Constructor taking an auxid directly. + * @param auxid ID for this auxiliary variable. + * + * Will throw @c SG::ExcAuxTypeMismatch if the types don't match. + */ + AtomicDecorator (const SG::auxid_t auxid); + + /** * @brief Fetch the variable for one element, as a non-const reference. * @param e The element for which to fetch the variable. diff --git a/Control/AthContainers/AthContainers/tools/AtomicDecorator.icc b/Control/AthContainers/AthContainers/tools/AtomicDecorator.icc index 8587d95df6240be110edc613c609f3f8625dfb85..f0a9bf68cbeae67d62b82361e4c6d1f0ce161ce7 100644 --- a/Control/AthContainers/AthContainers/tools/AtomicDecorator.icc +++ b/Control/AthContainers/AthContainers/tools/AtomicDecorator.icc @@ -43,6 +43,20 @@ AtomicDecorator<T>::AtomicDecorator (const std::string& name, } +/** + * @brief Constructor taking an auxid directly. + * @param auxid ID for this auxiliary variable. + * + * Will throw @c SG::ExcAuxTypeMismatch if the types don't match. + */ +template <class T> +inline +AtomicDecorator<T>::AtomicDecorator (const SG::auxid_t auxid) + : Base (auxid, SG::AuxVarFlags::Atomic) +{ +} + + /** * @brief Fetch the variable for one element, as a non-const reference. * @param e The element for which to fetch the variable. diff --git a/Control/AthContainers/test/Accessor_test.cxx b/Control/AthContainers/test/Accessor_test.cxx index 7688684cba03779996fc129d0bde7c8df25515ab..82ebfc387911929b22f12070a742ace6580ab45d 100644 --- a/Control/AthContainers/test/Accessor_test.cxx +++ b/Control/AthContainers/test/Accessor_test.cxx @@ -80,6 +80,12 @@ void test1() assert (ityp1.auxid() == ityp1_id); assert (ftyp1.auxid() == ftyp1_id); + { + SG::Accessor<int> i2 (ityp1_id); + assert (i2.auxid() == ityp1_id); + EXPECT_EXCEPTION (SG::ExcAuxTypeMismatch, (SG::Accessor<float> (ityp1_id))); + } + assert (!ityp1.isAvailable(b)); assert (!ftyp1.isAvailable(b)); assert (!ityp1.isAvailableWritable(b)); diff --git a/Control/AthContainers/test/AtomicConstAccessor_test.cxx b/Control/AthContainers/test/AtomicConstAccessor_test.cxx index a0e8df054ade4a0351a17859aa62b6b5df63238e..77adfa92520b46189e10e325da263c732f95c401 100644 --- a/Control/AthContainers/test/AtomicConstAccessor_test.cxx +++ b/Control/AthContainers/test/AtomicConstAccessor_test.cxx @@ -85,6 +85,13 @@ void test1() static_assert (std::is_same<decltype(ityp2(b)), int>::value, "test"); + { + SG::AtomicConstAccessor<int> i2 (ityp2_id); + assert (i2.auxid() == ityp2_id); + EXPECT_EXCEPTION (SG::ExcAuxTypeMismatch, (SG::AtomicConstAccessor<float> (ityp2_id))); + EXPECT_EXCEPTION (SG::ExcAtomicMismatch, (SG::Accessor<int> (ityp2_id))); + } + SG::AtomicDecorator<int> ityp2_d ("anInt2"); ityp2_d(b) = 11; assert (11 == ityp2(b)); diff --git a/Control/AthContainers/test/AtomicDecorator_test.cxx b/Control/AthContainers/test/AtomicDecorator_test.cxx index 42e1d88c483c6cd580085c6585afcfd9fa2eee39..2d6f3345847f57609b236a9a800513bac019b819 100644 --- a/Control/AthContainers/test/AtomicDecorator_test.cxx +++ b/Control/AthContainers/test/AtomicDecorator_test.cxx @@ -91,6 +91,13 @@ void test1() const SG::AuxElement& cb = b; EXPECT_EXCEPTION (SG::ExcStoreLocked, ityp2(cb) = 14); + { + SG::AtomicDecorator<int> i2 (ityp2_id); + assert (i2.auxid() == ityp2_id); + EXPECT_EXCEPTION (SG::ExcAuxTypeMismatch, (SG::AtomicDecorator<float> (ityp2_id))); + EXPECT_EXCEPTION (SG::ExcAtomicMismatch, (SG::Decorator<int> (ityp2_id))); + } + SG::AtomicDecorator<int> ityp3 ("anInt3"); ityp3(cb) = 12; diff --git a/Control/AthContainers/test/ConstAccessor_test.cxx b/Control/AthContainers/test/ConstAccessor_test.cxx index 265effb16a14531ef8776920f32a4705f3acdd47..81bc6b024db62dcde3583e375518649d27de13b8 100644 --- a/Control/AthContainers/test/ConstAccessor_test.cxx +++ b/Control/AthContainers/test/ConstAccessor_test.cxx @@ -84,6 +84,12 @@ void test1() assert (ityp1.auxid() == ityp1_id); assert (ftyp1.auxid() == ftyp1_id); + { + SG::ConstAccessor<int> i2 (ityp1_id); + assert (i2.auxid() == ityp1_id); + EXPECT_EXCEPTION (SG::ExcAuxTypeMismatch, (SG::ConstAccessor<float> (ityp1_id))); + } + assert (!ityp1.isAvailable(b)); assert (!ftyp1.isAvailable(b)); diff --git a/Control/AthContainers/test/Decorator_test.cxx b/Control/AthContainers/test/Decorator_test.cxx index b506df8591d93c8a2c3a1107f6f6a793fd75c4b4..9fc38c2fddd5554425e3457ae8a14f92abdf0e06 100644 --- a/Control/AthContainers/test/Decorator_test.cxx +++ b/Control/AthContainers/test/Decorator_test.cxx @@ -86,6 +86,12 @@ void test1() assert (ityp1.auxid() == ityp1_id); assert (ftyp1.auxid() == ftyp1_id); + { + SG::Decorator<int> i2 (ityp1_id); + assert (i2.auxid() == ityp1_id); + EXPECT_EXCEPTION (SG::ExcAuxTypeMismatch, (SG::Decorator<float> (ityp1_id))); + } + assert (!ityp1.isAvailable(b)); assert (!ftyp1.isAvailable(b)); assert (!ityp1.isAvailable(bc));