Skip to content
Snippets Groups Projects
Commit 69e299d2 authored by Christos Anastopoulos's avatar Christos Anastopoulos
Browse files

StoregateSvc:retrieve. Avoid un-needed allocation of std:string due to...

StoregateSvc:retrieve. Avoid un-needed allocation of std:string due to static_cast<std::string> , when the TKEY type is already std::string
parent 56cc36cb
No related branches found
No related tags found
No related merge requests found
......@@ -228,10 +228,22 @@ public:
template <typename T, typename TKEY>
StatusCode retrieve(const T*& ptr, const TKEY& key) const;
/// Retrieve an object with "key", into a const T*.
/// Overload for std::string KEY type
template <typename T>
StatusCode retrieve(const T*& ptr, const std::string& key) const;
/// Retrieve an object with "key", into a T*
template <typename T, typename TKEY>
StatusCode retrieve(T*& ptr, const TKEY& key) const;
/// Retrieve an object with "key", into a T*.
/// Overload for std::string KEY type
template <typename T>
StatusCode retrieve(T*& ptr, const std::string& key) const;
/// Variant of the above which doesn't return a status code.
/// Just returns null if the object isn't found.
template <typename T, class TKEY>
......
......@@ -363,19 +363,17 @@ StatusCode StoreGateSvc::retrieve(T*& ptr) const
//////////////////////////////////////////////////////////////////
// Retrieve the keyed object as a const pointer
// Overload for std::string key type
//////////////////////////////////////////////////////////////////
template <typename T, typename TKEY>
StatusCode StoreGateSvc::retrieve(const T*& ptr, const TKEY& key) const
template <typename T>
StatusCode StoreGateSvc::retrieve(const T*& ptr, const std::string& key) const
{
if (m_storeID == StoreID::EVENT_STORE && s_pSlot != nullptr) {
rememberBadRetrieve (ClassID_traits<T>::ID(), key);
}
#ifndef __clang__
BOOST_CONCEPT_ASSERT( (KeyConcept<TKEY>) );
#endif
SG::DataProxy* dp =proxy (ClassID_traits<T>::ID(),
static_cast<std::string> (key),
key,
false);
if (!dp || !dp->isValid()) {
warning()
......@@ -401,24 +399,34 @@ StatusCode StoreGateSvc::retrieve(const T*& ptr, const TKEY& key) const
}
//////////////////////////////////////////////////////////////////
// Retrieve the keyed object as a non-const pointer
// Retrieve the keyed object as a const pointer
//////////////////////////////////////////////////////////////////
template <typename T, typename TKEY>
StatusCode StoreGateSvc::retrieve(T*& ptr, const TKEY& key) const
StatusCode StoreGateSvc::retrieve(const T*& ptr, const TKEY& key) const
{
#ifndef __clang__
BOOST_CONCEPT_ASSERT( (KeyConcept<TKEY>) );
#endif
return this->retrieve(ptr, static_cast<std::string>(key));
}
//////////////////////////////////////////////////////////////////
// Retrieve the keyed object as a non-const pointer
// Overload for std::string key type
//////////////////////////////////////////////////////////////////
template <typename T>
StatusCode StoreGateSvc::retrieve(T*& ptr, const std::string& key) const
{
if (m_storeID == StoreID::EVENT_STORE && s_pSlot != nullptr) {
rememberBadRetrieve (ClassID_traits<T>::ID(), key);
}
#ifndef __clang__
BOOST_CONCEPT_ASSERT( (KeyConcept<TKEY>) );
#endif
SG::DataProxy* dp =proxy (ClassID_traits<T>::ID(),
static_cast<std::string> (key),
key,
false);
if (!dp || !dp->isValid() || dp->isConst()) {
SG_MSG_WARNING("retrieve(non-const): No valid proxy for object "
<< (std::string)key << ' '
<< key << ' '
<< " of type " << ClassID_traits<T>::typeName() << "(CLID "
<< ClassID_traits<T>::ID()
<< ") \n Try to use a const retrieve" );
......@@ -440,6 +448,18 @@ StatusCode StoreGateSvc::retrieve(T*& ptr, const TKEY& key) const
return StatusCode::SUCCESS;
}
//////////////////////////////////////////////////////////////////
// Retrieve the keyed object as a non-const pointer
//////////////////////////////////////////////////////////////////
template <typename T, typename TKEY>
StatusCode StoreGateSvc::retrieve(T*& ptr, const TKEY& key) const
{
#ifndef __clang__
BOOST_CONCEPT_ASSERT( (KeyConcept<TKEY>) );
#endif
return this->retrieve(ptr, static_cast<std::string>(key));
}
/// Retrieve all objects of type T: returns an SG::ConstIterator range
template <typename T>
StatusCode
......
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