Skip to content
Snippets Groups Projects
Commit 8f207c80 authored by Adam Edward Barton's avatar Adam Edward Barton
Browse files

Merge branch 'viewKey.AthViews-20200826' into 'master'

AthViews: Factor out view key formation.

See merge request atlas/athena!35930
parents 3688c801 741145d6
No related branches found
No related tags found
No related merge requests found
...@@ -40,6 +40,12 @@ class SimpleView : public IProxyDict ...@@ -40,6 +40,12 @@ class SimpleView : public IProxyDict
SimpleView( std::string Name, bool AllowFallThrough = true, std::string const& storeName = "StoreGateSvc" ); SimpleView( std::string Name, bool AllowFallThrough = true, std::string const& storeName = "StoreGateSvc" );
virtual ~SimpleView(); 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 * @brief links to the previously used views
* through these parent views additional data objects become available * through these parent views additional data objects become available
......
///////////////////////// -*- C++ -*- ///////////////////////////// ///////////////////////// -*- 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 #ifndef ATHVIEWS_VIEW_H
...@@ -30,6 +30,16 @@ public: ...@@ -30,6 +30,16 @@ public:
View (const View&) = delete; View (const View&) = delete;
View& operator= (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 #ifdef ATHVIEWS_DEBUG
void impl ( DebugView* impl ) { m_implementation = impl; } void impl ( DebugView* impl ) { m_implementation = impl; }
DebugView* impl (void ) { return m_implementation; } DebugView* impl (void ) { return m_implementation; }
......
...@@ -225,7 +225,10 @@ namespace ViewHelper ...@@ -225,7 +225,10 @@ namespace ViewHelper
} }
//Declare remapping //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(); offset += queryHandle->size();
} }
...@@ -274,7 +277,7 @@ namespace ViewHelper ...@@ -274,7 +277,7 @@ namespace ViewHelper
template<typename T> template<typename T>
ElementLink<T> makeLink( const SG::View* view, const SG::ReadHandle<T>& handle, size_t index ) 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 } // EOF namspace ViewHelper
......
...@@ -51,8 +51,7 @@ SG::DataProxy * DebugView::proxy( const CLID& id, const std::string& key ) const ...@@ -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 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(); }; 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(key) );
auto localProxy = m_store->proxy( id, viewKey );
if ( isValid( localProxy ) ) { if ( isValid( localProxy ) ) {
return localProxy; return localProxy;
} }
...@@ -134,12 +133,10 @@ SG::DataProxy * DebugView::proxy( const void* const pTransient ) const ...@@ -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 ) 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 // Warn if fallthrough already happened for the object
if ( m_fallList.find( key ) != m_fallList.end() ) { 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" ); 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 );
} }
/* /*
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> #include <stdexcept>
...@@ -18,6 +18,17 @@ SimpleView::~SimpleView() ...@@ -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 ) { void SimpleView::linkParent( const IProxyDict* parent ) {
auto castParent = dynamic_cast< const SG::View* >( parent ); auto castParent = dynamic_cast< const SG::View* >( parent );
if ( castParent ) { if ( castParent ) {
...@@ -63,8 +74,7 @@ SG::DataProxy * SimpleView::proxy( const CLID& id, const std::string& key ) cons ...@@ -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 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(); }; 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(key) );
auto localProxy = m_store->proxy( id, viewKey );
if ( isValid( localProxy ) ) { if ( isValid( localProxy ) ) {
return localProxy; return localProxy;
} }
...@@ -168,8 +178,7 @@ bool SimpleView::tryELRemap( sgkey_t sgkey_in, size_t index_in, sgkey_t & sgkey_ ...@@ -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 ) 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(key), allowMods, returnExisting );
return m_store->recordObject( obj, viewKey, allowMods, returnExisting );
} }
/** /**
...@@ -215,8 +224,7 @@ const std::string& SimpleView::name() const ...@@ -215,8 +224,7 @@ const std::string& SimpleView::name() const
//IStringPool //IStringPool
IStringPool::sgkey_t SimpleView::stringToKey( const std::string& str, CLID clid ) IStringPool::sgkey_t SimpleView::stringToKey( const std::string& str, CLID clid )
{ {
const std::string viewKey = m_name + "_" + str; return m_store->stringToKey( viewKey(str), clid );
return m_store->stringToKey( viewKey, clid );
} }
const std::string* SimpleView::keyToString( IStringPool::sgkey_t key ) const 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 ...@@ -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 ) 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(str), clid );
m_store->registerKey( key, viewKey, clid );
} }
void SimpleView::setROI(const ElementLink<TrigRoiDescriptorCollection>& roi) { void SimpleView::setROI(const ElementLink<TrigRoiDescriptorCollection>& roi) {
......
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