diff --git a/Control/AthViews/AthViews/SimpleView.h b/Control/AthViews/AthViews/SimpleView.h index f1190641149e5af089f11f428c31533a8e3d5d1b..465d12ff94223f501709b3a529383352cf2e4a48 100644 --- a/Control/AthViews/AthViews/SimpleView.h +++ b/Control/AthViews/AthViews/SimpleView.h @@ -40,6 +40,12 @@ class SimpleView : public IProxyDict SimpleView( std::string Name, bool AllowFallThrough = true, std::string const& storeName = "StoreGateSvc" ); virtual ~SimpleView(); + /** + * @brief Construct a key as used in the parent store. + * @brief key The key as used in the view. + */ + std::string viewKey (const std::string& key) const; + /** * @brief links to the previously used views * through these parent views additional data objects become available diff --git a/Control/AthViews/AthViews/View.h b/Control/AthViews/AthViews/View.h index 9f9d32135d1b227b11581ae9499e7c4874446e1e..9b6a655234976f71c8f10da97c068cad2313adc3 100644 --- a/Control/AthViews/AthViews/View.h +++ b/Control/AthViews/AthViews/View.h @@ -1,7 +1,7 @@ ///////////////////////// -*- C++ -*- ///////////////////////////// /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #ifndef ATHVIEWS_VIEW_H @@ -30,6 +30,16 @@ public: View (const View&) = delete; View& operator= (const View&) = delete; + /** + * @brief Construct a key as used in the parent store. + * @brief key The key as used in the view. + */ + std::string viewKey (const std::string& key) const + { + return m_implementation->viewKey (key); + } + + #ifdef ATHVIEWS_DEBUG void impl ( DebugView* impl ) { m_implementation = impl; } DebugView* impl (void ) { return m_implementation; } diff --git a/Control/AthViews/AthViews/ViewHelper.h b/Control/AthViews/AthViews/ViewHelper.h index 7a65e32a2ec2983f6dd9a8044ac810ce4144a36a..5594c244396124deac04a66bd34b6dd283f9e74c 100644 --- a/Control/AthViews/AthViews/ViewHelper.h +++ b/Control/AthViews/AthViews/ViewHelper.h @@ -225,7 +225,10 @@ namespace ViewHelper } //Declare remapping - m_sg->remap( ClassID_traits< DataVector< T > >::ID(), inputView->name() + "_" + queryHandle.name(), queryHandle.name(), offset ); + m_sg->remap( ClassID_traits< DataVector< T > >::ID(), + inputView->viewKey (queryHandle.name()), + queryHandle.name(), + offset ); offset += queryHandle->size(); } @@ -274,7 +277,7 @@ namespace ViewHelper template<typename T> ElementLink<T> makeLink( const SG::View* view, const SG::ReadHandle<T>& handle, size_t index ) { - return ElementLink<T>( view->name() + "_" + handle.key(), index ); + return ElementLink<T>( view->viewKey (handle.key()), index ); } } // EOF namspace ViewHelper diff --git a/Control/AthViews/src/DebugView.cxx b/Control/AthViews/src/DebugView.cxx index adcd3f122a7fdb0660c2f2f5179e063eb986e4e6..fe386cf24c6b4e1c656932616bf885ab24f238a3 100644 --- a/Control/AthViews/src/DebugView.cxx +++ b/Control/AthViews/src/DebugView.cxx @@ -51,8 +51,7 @@ SG::DataProxy * DebugView::proxy( const CLID& id, const std::string& key ) const SG::DataProxy * DebugView::findProxy( const CLID& id, const std::string& key, const bool allowFallThrough ) const { auto isValid = [](const SG::DataProxy* p) { return p != nullptr and p->isValid(); }; - const std::string viewKey = m_name + "_" + key; - auto localProxy = m_store->proxy( id, viewKey ); + auto localProxy = m_store->proxy( id, viewKey(key) ); if ( isValid( localProxy ) ) { return localProxy; } @@ -134,12 +133,10 @@ SG::DataProxy * DebugView::proxy( const void* const pTransient ) const SG::DataProxy * DebugView::recordObject( SG::DataObjectSharedPtr<DataObject> obj, const std::string& key, bool allowMods, bool returnExisting ) { - const std::string viewKey = m_name + "_" + key; - // Warn if fallthrough already happened for the object if ( m_fallList.find( key ) != m_fallList.end() ) { ATH_MSG_WARNING( "Key " << key << " was recorded to view " << m_name << " but was previously retrieved via fallthrough" ); } - return m_store->recordObject( obj, viewKey, allowMods, returnExisting ); + return m_store->recordObject( obj, viewKey(key), allowMods, returnExisting ); } diff --git a/Control/AthViews/src/SimpleView.cxx b/Control/AthViews/src/SimpleView.cxx index be037112984c46eed274c686dc6b1176a05237aa..5b2821f7055510d444da388c3eacc3433deeb4ef 100644 --- a/Control/AthViews/src/SimpleView.cxx +++ b/Control/AthViews/src/SimpleView.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #include <stdexcept> @@ -18,6 +18,17 @@ SimpleView::~SimpleView() { } + +/** + * @brief Construct a key as used in the parent store. + * @brief key The key as used in the view. + */ +std::string SimpleView::viewKey (const std::string& key) const +{ + return m_name + "_" + key; +} + + void SimpleView::linkParent( const IProxyDict* parent ) { auto castParent = dynamic_cast< const SG::View* >( parent ); if ( castParent ) { @@ -63,8 +74,7 @@ SG::DataProxy * SimpleView::proxy( const CLID& id, const std::string& key ) cons SG::DataProxy * SimpleView::findProxy( const CLID& id, const std::string& key, const bool allowFallThrough ) const { auto isValid = [](const SG::DataProxy* p) { return p != nullptr and p->isValid(); }; - const std::string viewKey = m_name + "_" + key; - auto localProxy = m_store->proxy( id, viewKey ); + auto localProxy = m_store->proxy( id, viewKey(key) ); if ( isValid( localProxy ) ) { return localProxy; } @@ -168,8 +178,7 @@ bool SimpleView::tryELRemap( sgkey_t sgkey_in, size_t index_in, sgkey_t & sgkey_ */ SG::DataProxy * SimpleView::recordObject( SG::DataObjectSharedPtr<DataObject> obj, const std::string& key, bool allowMods, bool returnExisting ) { - const std::string viewKey = m_name + "_" + key; - return m_store->recordObject( obj, viewKey, allowMods, returnExisting ); + return m_store->recordObject( obj, viewKey(key), allowMods, returnExisting ); } /** @@ -215,8 +224,7 @@ const std::string& SimpleView::name() const //IStringPool IStringPool::sgkey_t SimpleView::stringToKey( const std::string& str, CLID clid ) { - const std::string viewKey = m_name + "_" + str; - return m_store->stringToKey( viewKey, clid ); + return m_store->stringToKey( viewKey(str), clid ); } const std::string* SimpleView::keyToString( IStringPool::sgkey_t key ) const { @@ -230,8 +238,7 @@ const std::string* SimpleView::keyToString( IStringPool::sgkey_t key, CLID& clid } void SimpleView::registerKey( IStringPool::sgkey_t key, const std::string& str, CLID clid ) { - const std::string viewKey = m_name + "_" + str; - m_store->registerKey( key, viewKey, clid ); + m_store->registerKey( key, viewKey(str), clid ); } void SimpleView::setROI(const ElementLink<TrigRoiDescriptorCollection>& roi) {