Commit 081ace6f authored by Nils Krumnack's avatar Nils Krumnack

add AsgServiceWrapper for AsgService

Just so that services can be added to EventLoop jobs.
parent b8938060
......@@ -21,7 +21,7 @@ find_package( GTest )
atlas_add_root_dictionary( EventLoop
EventLoopDictSource
ROOT_HEADERS EventLoop/Algorithm.h EventLoop/AlgorithmWrapper.h
EventLoop/BatchDriver.h
EventLoop/AsgServiceWrapper.h EventLoop/BatchDriver.h
EventLoop/BatchJob.h EventLoop/BatchSegment.h EventLoop/BatchSample.h
EventLoop/CondorDriver.h EventLoop/DirectDriver.h
EventLoop/GEDriver.h EventLoop/Job.h EventLoop/KubernetesDriver.h
......@@ -35,10 +35,10 @@ atlas_add_root_dictionary( EventLoop
atlas_add_library( EventLoop
EventLoop/*.h EventLoop/*.ihh Root/*.cxx ${EventLoopDictSource}
PUBLIC_HEADERS EventLoop
INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} ${GTEST_INCLUDE_DIRS}
LINK_LIBRARIES ${ROOT_LIBRARIES} ${GTEST_LIBRARIES} RootCoreUtils
SampleHandler AnaAlgorithmLib
PRIVATE_LINK_LIBRARIES AsgTools xAODRootAccess PathResolver )
INCLUDE_DIRS ${ROOT_INCLUDE_DIRS}
PRIVATE_INCLUDE_DIRS ${Boost_INCLUDE_DIRS}
LINK_LIBRARIES ${ROOT_LIBRARIES} AnaAlgorithmLib AsgServicesLib AsgMessagingLib AsgTools SampleHandler
PRIVATE_LINK_LIBRARIES ${Boost_LIBRARIES} PathResolver RootCoreUtils xAODCore xAODRootAccess )
target_compile_definitions (EventLoop PUBLIC USE_CMAKE)
......
/*
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
*/
/// @author Nils Krumnack
#ifndef EVENT_LOOP_ASG_SERVICE_WRAPPER_H
#define EVENT_LOOP_ASG_SERVICE_WRAPPER_H
#include <EventLoop/Global.h>
#include <AsgServices/AsgService.h>
#include <AsgServices/AsgServiceConfig.h>
#include <AnaAlgorithm/IAlgorithmWrapper.h>
namespace EL
{
/// \brief an \ref IAlgorithmWrapper for \ref AsgService
class AsgServiceWrapper final : public IAlgorithmWrapper
{
public:
/// Public Members
/// ==============
/// \brief test the invariant of this object
void testInvariant () const;
/// \brief standard default constructor for serialization
AsgServiceWrapper () {};
/// \brief standard constructor
AsgServiceWrapper (asg::AsgServiceConfig val_config);
/// Inherited Members
/// =================
virtual std::string_view getName () const override;
virtual bool hasName (const std::string& name) const override;
virtual std::unique_ptr<IAlgorithmWrapper> makeClone() const override;
virtual StatusCode initialize (const AlgorithmWorkerData& workerData) override;
virtual StatusCode execute () override;
virtual StatusCode finalize () override;
virtual ::StatusCode fileExecute () override;
virtual ::StatusCode beginInputFile () override;
virtual ::StatusCode endInputFile () override;
/// Private Members
/// ===============
private:
/// \brief the algorithm configuration
asg::AsgServiceConfig m_config;
/// \brief the actual service (once instantiated)
///
/// Please note (and do not remove) the comment at the end of the
/// line. This specifically excludes this member from
/// serialization.
std::shared_ptr<asg::AsgService> m_service; //!
};
}
#endif
......@@ -29,6 +29,11 @@
#include <SampleHandler/SampleHandler.h>
#include <SampleHandler/MetaObject.h>
namespace asg
{
class AsgServiceConfig;
}
namespace EL
{
/// effects: standard swap
......@@ -94,6 +99,7 @@ namespace EL
void algsAdd (Algorithm *alg_swallow);
void algsAdd (const AnaAlgorithmConfig& config);
void algsAdd (const AnaReentrantAlgorithmConfig& config);
void algsAdd (const asg::AsgServiceConfig& config);
/// \brief add a clone of the given algorithm
......
/*
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
*/
/// @author Nils Krumnack
//
// includes
//
#include <EventLoop/AsgServiceWrapper.h>
#include <EventLoop/MessageCheck.h>
#include <RootCoreUtils/Assert.h>
//
// method implementations
//
namespace EL
{
void AsgServiceWrapper ::
testInvariant () const
{
RCU_INVARIANT (!m_config.name().empty());
}
AsgServiceWrapper ::
AsgServiceWrapper (asg::AsgServiceConfig val_config)
: m_config (std::move (val_config))
{
RCU_NEW_INVARIANT (this);
}
std::string_view AsgServiceWrapper ::
getName () const
{
RCU_READ_INVARIANT (this);
return m_config.name();
}
bool AsgServiceWrapper ::
hasName (const std::string& name) const
{
RCU_READ_INVARIANT (this);
return m_config.name() == name;
}
std::unique_ptr<IAlgorithmWrapper> AsgServiceWrapper ::
makeClone() const
{
RCU_READ_INVARIANT (this);
return std::make_unique<AsgServiceWrapper> (m_config);
}
StatusCode AsgServiceWrapper ::
initialize (const AlgorithmWorkerData& /*workerData*/)
{
using namespace msgEventLoop;
RCU_CHANGE_INVARIANT (this);
if (m_config.makeService (m_service).isFailure())
{
ANA_MSG_ERROR ("failed to create AsgService: " << m_config.name());
return StatusCode::FAILURE;
}
return StatusCode::SUCCESS;
}
StatusCode AsgServiceWrapper ::
execute ()
{
RCU_READ_INVARIANT (this);
return StatusCode::SUCCESS;
}
StatusCode AsgServiceWrapper ::
finalize ()
{
using namespace msgEventLoop;
RCU_READ_INVARIANT (this);
if (m_service->finalize().isFailure())
{
ANA_MSG_ERROR ("failed to call finalize() on service: " << m_config.name());
return StatusCode::FAILURE;
}
return StatusCode::SUCCESS;
}
StatusCode AsgServiceWrapper ::
fileExecute ()
{
RCU_READ_INVARIANT (this);
return StatusCode::SUCCESS;
}
StatusCode AsgServiceWrapper ::
beginInputFile ()
{
RCU_READ_INVARIANT (this);
return StatusCode::SUCCESS;
}
::StatusCode AsgServiceWrapper ::
endInputFile ()
{
// no-op
return StatusCode::SUCCESS;
}
}
......@@ -14,6 +14,7 @@
#include <EventLoop/MessageCheck.h>
#include <EventLoop/Algorithm.h>
#include <EventLoop/AlgorithmWrapper.h>
#include <EventLoop/AsgServiceWrapper.h>
#include <EventLoop/OutputStream.h>
#include <RootCoreUtils/Assert.h>
#include <RootCoreUtils/CheckRootVersion.h>
......@@ -273,6 +274,15 @@ namespace EL
void Job ::
algsAdd (const asg::AsgServiceConfig& config)
{
// no invariant used
algsAdd (std::make_unique<AsgServiceWrapper> (config));
}
void Job ::
algsAddClone (const Algorithm& alg)
{
......
......@@ -11,6 +11,7 @@
#pragma link C++ class EL::Algorithm+;
#pragma link C++ class EL::AlgorithmWrapper+;
#pragma link C++ class EL::AsgServiceWrapper+;
#pragma link C++ class EL::BatchDriver+;
#pragma link C++ class EL::BatchJob+;
#pragma link C++ class EL::BatchSample+;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment