The Gaudi Framework  master (82fdf313)
Loading...
Searching...
No Matches
PartitionSwitchTool.cpp
Go to the documentation of this file.
1/***********************************************************************************\
2* (c) Copyright 1998-2024 CERN for the benefit of the LHCb and ATLAS collaborations *
3* *
4* This software is distributed under the terms of the Apache version 2 licence, *
5* copied verbatim in the file "LICENSE". *
6* *
7* In applying this licence, CERN does not waive the privileges and immunities *
8* granted to it by virtue of its status as an Intergovernmental Organization *
9* or submit itself to any jurisdiction. *
10\***********************************************************************************/
11// Framework include files
12#include <GaudiKernel/AlgTool.h>
15#include <GaudiKernel/SmartIF.h>
16
22class PartitionSwitchTool : public extends<AlgTool, IPartitionControl> {
23
24 using CSTR = const std::string&;
26
27private:
28 Gaudi::Property<std::string> m_actorName{ this, "Actor", "EventDataService", "option to set the multi-service name" };
31
32public:
33 using extends::extends;
34
36 STATUS initialize() override {
39 if ( !sc.isSuccess() ) {
40 error() << "Cannot initialize base class!" << endmsg;
41 return sc;
42 }
44 if ( !m_actor ) {
45 error() << "Cannot retrieve partition controller \"" << m_actorName.value() << "\"!" << endmsg;
47 }
48 return sc;
49 }
50
51 STATUS finalize() override {
52 m_actor = nullptr;
53 return AlgTool::finalize();
54 }
55
56 void _check( STATUS sc, CSTR msg ) const { error() << msg << " Status=" << sc.getCode() << endmsg; }
57#define CHECK( x, y ) \
58 if ( !x.isSuccess() ) _check( x, y ); \
59 return x;
60
62 STATUS create( CSTR nam, CSTR typ ) override {
63 STATUS sc = m_actor ? m_actor->create( nam, typ ) : IInterface::Status::NO_INTERFACE;
64 CHECK( sc, "Cannot create partition: " + nam + " of type " + typ );
65 }
66
67 STATUS create( CSTR nam, CSTR typ, IInterface*& pPartition ) override {
68 STATUS sc = m_actor ? m_actor->create( nam, typ, pPartition ) : IInterface::Status::NO_INTERFACE;
69 CHECK( sc, "Cannot create partition: " + nam + " of type " + typ );
70 }
71
72 STATUS drop( CSTR nam ) override {
74 CHECK( sc, "Cannot drop partition: " + nam );
75 }
76
77 STATUS drop( IInterface* pPartition ) override {
78 STATUS sc = m_actor ? m_actor->drop( pPartition ) : IInterface::Status::NO_INTERFACE;
79 CHECK( sc, "Cannot drop partition by Interface." );
80 }
81
82 STATUS activate( CSTR nam ) override {
84 CHECK( sc, "Cannot activate partition: " + nam );
85 }
86
87 STATUS activate( IInterface* pPartition ) override {
88 STATUS sc = m_actor ? m_actor->activate( pPartition ) : IInterface::Status::NO_INTERFACE;
89 CHECK( sc, "Cannot activate partition by Interface." );
90 }
91
92 STATUS get( CSTR nam, IInterface*& pPartition ) const override {
93 STATUS sc = m_actor ? m_actor->get( nam, pPartition ) : IInterface::Status::NO_INTERFACE;
94 CHECK( sc, "Cannot get partition " + nam );
95 }
96
97 STATUS activePartition( std::string& nam, IInterface*& pPartition ) const override {
98 STATUS sc = m_actor ? m_actor->activePartition( nam, pPartition ) : IInterface::Status::NO_INTERFACE;
99 CHECK( sc, "Cannot determine active partition." );
100 }
101};
102
103// Declaration of the Tool Factory
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition MsgStream.h:198
#define CHECK(x, y)
#define DECLARE_COMPONENT(type)
StatusCode initialize() override
Definition AlgTool.cpp:173
SmartIF< IService > service(std::string_view name, const bool createIf=true, const bool quiet=false) const
Return a pointer to the service identified by name (or "type/name")
Definition AlgTool.cpp:355
StatusCode finalize() override
Definition AlgTool.cpp:225
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
MsgStream & msg() const
shortcut for the method msgStream(MSG::INFO)
Implementation of property with value of concrete type.
Definition PropertyFwd.h:27
Definition of the basic interface.
Definition IInterface.h:225
@ NO_INTERFACE
Requested interface is not available.
Definition IInterface.h:306
SmartIF< IPartitionControl > m_actor
reference to Partition Controller
const std::string & CSTR
STATUS initialize() override
Initialize.
STATUS create(CSTR nam, CSTR typ, IInterface *&pPartition) override
Create a partition object. The name identifies the partition uniquely.
STATUS activePartition(std::string &nam, IInterface *&pPartition) const override
Access the active partition object.
STATUS create(CSTR nam, CSTR typ) override
Create a partition object. The name identifies the partition uniquely.
STATUS drop(IInterface *pPartition) override
Drop a partition object. The name identifies the partition uniquely.
STATUS get(CSTR nam, IInterface *&pPartition) const override
Access a partition object. The name identifies the partition uniquely.
STATUS activate(CSTR nam) override
Activate a partition object. The name identifies the partition uniquely.
STATUS activate(IInterface *pPartition) override
Activate a partition object.
STATUS finalize() override
Finalize.
STATUS drop(CSTR nam) override
Drop a partition object. The name identifies the partition uniquely.
Gaudi::Property< std::string > m_actorName
void _check(STATUS sc, CSTR msg) const
Small smart pointer class with automatic reference counting for IInterface.
Definition SmartIF.h:28
This class is used for returning status codes from appropriate routines.
Definition StatusCode.h:64
bool isSuccess() const
Definition StatusCode.h:314
constexpr static const auto FAILURE
Definition StatusCode.h:100
code_t getCode() const
Retrieve value.
Definition StatusCode.h:136
Base class used to extend a class implementing other interfaces.
Definition extends.h:19