diff --git a/Control/AthenaBaseComps/AthenaBaseComps/AthConstConverter.h b/Control/AthenaBaseComps/AthenaBaseComps/AthConstConverter.h new file mode 100644 index 0000000000000000000000000000000000000000..0dcc82c3942799cac74c17f4ce1eeb912347e7fa --- /dev/null +++ b/Control/AthenaBaseComps/AthenaBaseComps/AthConstConverter.h @@ -0,0 +1,75 @@ +// This file's extension implies that it's C, but it's really -*- C++ -*-. +/* + * Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration. + */ +/** + * @file AthenaBaseComps/AthConstConverter.h + * @author scott snyder <snyder@bnl.gov> + * @date Oct, 2020 + * @brief Gaudi converter base class with const interfaces. + */ + + +#ifndef ATHENABASECOMPS_ATHCONSTCONVERTER_H +#define ATHENABASECOMPS_ATHCONSTCONVERTER_H + + +#include "AthenaBaseComps/AthMessaging.h" +#include "AthenaBaseComps/AthMsgStreamMacros.h" +#include "GaudiKernel/Converter.h" + + +/** + * @brief Gaudi converter base class with const interfaces. + * + * This is a version of Gaudi Converter which uses const + * @c createRepConst and @c createObjConst methods instead + * of @c createObj and @c createRep. This can be used for converters + * that one wants to execute concurrently in MT jobs. + * + * As a bonus, we also include @c AthMessaging functionality. + */ +class AthConstConverter : public Converter, public AthMessaging +{ +public: + AthConstConverter (long storage_type, + const CLID& class_type, + ISvcLocator* svc, + const std::string& name) + : Converter (storage_type, class_type, svc), + AthMessaging (msgSvc().get(), name), + m_name (name) + { + } + + + /// Create the transient representation of an object. + virtual StatusCode createObjConst( IOpaqueAddress* pAddress, + DataObject*& refpObject ) const; + + /// Convert the transient object to the requested representation. + virtual StatusCode createRepConst( DataObject* pObject, + IOpaqueAddress*& refpAddress ) const; + + + /// Create the transient representation of an object. + // Non-const version; just calls the const version. + virtual StatusCode createObj( IOpaqueAddress* pAddress, + DataObject*& refpObject ) override final; + + + /// Convert the transient object to the requested representation. + // Non-const version; just calls the const version. + virtual StatusCode createRep( DataObject* pObject, + IOpaqueAddress*& refpAddress ) override final; + + + std::string name() const { return m_name; } + + +private: + std::string m_name; +}; + + +#endif // not ATHENABASECOMPS_ATHCONSTCONVERTER_H diff --git a/Control/AthenaBaseComps/src/AthConstConverter.cxx b/Control/AthenaBaseComps/src/AthConstConverter.cxx new file mode 100644 index 0000000000000000000000000000000000000000..2b22a70b6ca40adbd94f59b2f2e7624ae35719bd --- /dev/null +++ b/Control/AthenaBaseComps/src/AthConstConverter.cxx @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration. + */ +/** + * @file AthenaBaseComps/AthConstConverter.h + * @author scott snyder <snyder@bnl.gov> + * @date Oct, 2020 + * @brief Gaudi converter base class with const interfaces. + */ + + +#include "AthenaBaseComps/AthConstConverter.h" + + +/** + * @brief Create the transient representation of an object. + * + * The default implementation is a no-op. + */ +StatusCode AthConstConverter::createObjConst( IOpaqueAddress* /*pAddress*/, + DataObject*& /*refpObject*/ ) const +{ + return StatusCode::SUCCESS; +} + + +/** + * @brief Convert the transient object to the requested representation. + * + * The default implementation is a no-op. + */ +StatusCode AthConstConverter::createRepConst( DataObject* /*pObject*/, + IOpaqueAddress*& /*refpAddress*/ ) const +{ + return StatusCode::SUCCESS; +} + + +/** + * @brief Create the transient representation of an object. + * + * Non-const version; just calls the const version. + */ +StatusCode AthConstConverter::createObj( IOpaqueAddress* pAddress, + DataObject*& refpObject ) +{ + return createObjConst (pAddress, refpObject); +} + + +/** + * @brief Convert the transient object to the requested representation. + * + * Non-const version; just calls the const version. + */ +StatusCode AthConstConverter::createRep( DataObject* pObject, + IOpaqueAddress*& refpAddress ) +{ + return createRepConst (pObject, refpAddress); +} +