| The Gaudi Framework v30r0 (c919700c)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

PartitionSwitchTool.cpp
Go to the documentation of this file.
1 // Framework include files
2 #include "GaudiKernel/AlgTool.h"
3 #include "GaudiKernel/IPartitionControl.h"
4 #include "GaudiKernel/MsgStream.h"
5 #include "GaudiKernel/SmartIF.h"
6
12 class PartitionSwitchTool : public extends<AlgTool, IPartitionControl>
13 {
14
15 using CSTR = const std::string&;
16 using STATUS = StatusCode;
17
18 private:
19 Gaudi::Property<std::string> m_actorName{this, "Actor", "EventDataService", "option to set the multi-service name"};
21 SmartIF<IPartitionControl> m_actor;
22
23 public:
24 using extends::extends;
26 ~PartitionSwitchTool() override = default;
27
29 STATUS initialize() override
30 {
32 STATUS sc = AlgTool::initialize();
33 if ( !sc.isSuccess() ) {
34 error() << "Cannot initialize base class!" << endmsg;
35 return sc;
36 }
37 m_actor = nullptr;
38 IPartitionControl* tmpPtr = nullptr;
39 sc = service( m_actorName, tmpPtr );
40 m_actor = tmpPtr;
41 if ( !sc.isSuccess() ) {
42 error() << "Cannot retrieve partition controller \"" << m_actorName.value() << "\"!" << endmsg;
43 return sc;
44 }
45 return sc;
46 }
48 STATUS finalize() override
49 {
50 m_actor = nullptr;
51 return AlgTool::finalize();
52 }
53
54 void _check( STATUS sc, CSTR msg ) const { error() << msg << " Status=" << sc.getCode() << endmsg; }
55 #define CHECK( x, y ) \
56 if ( !x.isSuccess() ) _check( x, y ); \
57 return x;
58
60 STATUS create( CSTR nam, CSTR typ ) override
61 {
62 STATUS sc = m_actor ? m_actor->create( nam, typ ) : NO_INTERFACE;
63 CHECK( sc, "Cannot create partition: " + nam + " of type " + typ );
64 }
66 STATUS create( CSTR nam, CSTR typ, IInterface*& pPartition ) override
67 {
68 STATUS sc = m_actor ? m_actor->create( nam, typ, pPartition ) : NO_INTERFACE;
69 CHECK( sc, "Cannot create partition: " + nam + " of type " + typ );
70 }
72 STATUS drop( CSTR nam ) override
73 {
74 STATUS sc = m_actor ? m_actor->drop( nam ) : NO_INTERFACE;
75 CHECK( sc, "Cannot drop partition: " + nam );
76 }
78 STATUS drop( IInterface* pPartition ) override
79 {
80 STATUS sc = m_actor ? m_actor->drop( pPartition ) : NO_INTERFACE;
81 CHECK( sc, "Cannot drop partition by Interface." );
82 }
84 STATUS activate( CSTR nam ) override
85 {
86 STATUS sc = m_actor ? m_actor->activate( nam ) : NO_INTERFACE;
87 CHECK( sc, "Cannot activate partition: " + nam );
88 }
90 STATUS activate( IInterface* pPartition ) override
91 {
92 STATUS sc = m_actor ? m_actor->activate( pPartition ) : NO_INTERFACE;
93 CHECK( sc, "Cannot activate partition by Interface." );
94 }
96 STATUS get( CSTR nam, IInterface*& pPartition ) const override
97 {
98 STATUS sc = m_actor ? m_actor->get( nam, pPartition ) : NO_INTERFACE;
99 CHECK( sc, "Cannot get partition " + nam );
100 }
102 STATUS activePartition( std::string& nam, IInterface*& pPartition ) const override
103 {
104 STATUS sc = m_actor ? m_actor->activePartition( nam, pPartition ) : NO_INTERFACE;
105 CHECK( sc, "Cannot determine active partition." );
106 }
107 };
108
109 // Declaration of the Tool Factory
110 DECLARE_COMPONENT( PartitionSwitchTool )
SmartIF< IPartitionControl >
CommonMessagingBase::msg
MsgStream & msg() const
shortcut for the method msgStream(MSG::INFO)
Definition: CommonMessaging.h:121
PartitionSwitchTool::create
STATUS create(CSTR nam, CSTR typ) override
Create a partition object. The name identifies the partition uniquely.
Definition: PartitionSwitchTool.cpp:60
Gaudi::Property
Implementation of property with value of concrete type.
Definition: Property.h:319
StatusCode::getCode
unsigned long getCode() const
Get the status code by value.
Definition: StatusCode.h:69
MsgStream.h
AlgTool::initialize
StatusCode initialize() override
Definition: AlgTool.cpp:243
PartitionSwitchTool::finalize
STATUS finalize() override
Finalize.
Definition: PartitionSwitchTool.cpp:48
PartitionSwitchTool::_check
void _check(STATUS sc, CSTR msg) const
Definition: PartitionSwitchTool.cpp:54
PartitionSwitchTool::activePartition
STATUS activePartition(std::string &nam, IInterface *&pPartition) const override
Access the active partition object.
Definition: PartitionSwitchTool.cpp:102
StatusCode::isSuccess
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:50
AlgTool.h
PartitionSwitchTool::activate
STATUS activate(CSTR nam) override
Activate a partition object. The name identifies the partition uniquely.
Definition: PartitionSwitchTool.cpp:84
IPartitionControl::create
virtual StatusCode create(const std::string &name, const std::string &type)=0
Create a partition object. The name identifies the partition uniquely.
DECLARE_COMPONENT
#define DECLARE_COMPONENT(type)
Definition: PluginService.h:33
PartitionSwitchTool::m_actorName
Gaudi::Property< std::string > m_actorName
Definition: PartitionSwitchTool.cpp:19
std::string
STL class.
AlgTool::finalize
StatusCode finalize() override
Definition: AlgTool.cpp:313
PartitionSwitchTool::drop
STATUS drop(CSTR nam) override
Drop a partition object. The name identifies the partition uniquely.
Definition: PartitionSwitchTool.cpp:72
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:106
PartitionSwitchTool
Definition: PartitionSwitchTool.cpp:12
IPartitionControl.h
PartitionSwitchTool::drop
STATUS drop(IInterface *pPartition) override
Drop a partition object. The name identifies the partition uniquely.
Definition: PartitionSwitchTool.cpp:78
PartitionSwitchTool::m_actor
SmartIF< IPartitionControl > m_actor
reference to Partition Controller
Definition: PartitionSwitchTool.cpp:21
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
IPartitionControl::get
virtual StatusCode get(const std::string &name, IInterface *&pPartition) const =0
Access a partition object. The name identifies the partition uniquely.
IInterface
Definition of the basic interface.
Definition: IInterface.h:277
SmartIF.h
AlgTool::service
StatusCode service(const std::string &name, T *&svc, bool createIf=true) const
Access a service by name, creating it if it doesn&#39;t already exist.
Definition: AlgTool.h:132
IPartitionControl::activePartition
virtual StatusCode activePartition(std::string &name, IInterface *&pPartition) const =0
Access the active partition object.
PartitionSwitchTool::~PartitionSwitchTool
~PartitionSwitchTool() override=default
Standard destructor.
IPartitionControl
Create / access partitions.
Definition: IPartitionControl.h:66
extends
Base class used to extend a class implementing other interfaces.
Definition: extends.h:10
PartitionSwitchTool::initialize
STATUS initialize() override
Initialize.
Definition: PartitionSwitchTool.cpp:29
IPartitionControl::drop
virtual StatusCode drop(const std::string &name)=0
Drop a partition object. The name identifies the partition uniquely.
IPartitionControl::activate
virtual StatusCode activate(const std::string &name)=0
Activate a partition object. The name identifies the partition uniquely.
PartitionSwitchTool::activate
STATUS activate(IInterface *pPartition) override
Activate a partition object.
Definition: PartitionSwitchTool.cpp:90
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
PartitionSwitchTool::create
STATUS create(CSTR nam, CSTR typ, IInterface *&pPartition) override
Create a partition object. The name identifies the partition uniquely.
Definition: PartitionSwitchTool.cpp:66
CHECK
#define CHECK(x, y)
Definition: PartitionSwitchTool.cpp:55