Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  v31r0 (aeb156f0)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
PartitionSwitchTool.cpp
Go to the documentation of this file.
1 // Framework include files
2 #include "GaudiKernel/AlgTool.h"
5 #include "GaudiKernel/SmartIF.h"
6 
12 class PartitionSwitchTool : public extends<AlgTool, IPartitionControl> {
13 
14  using CSTR = const std::string&;
15  using STATUS = StatusCode;
16 
17 private:
18  Gaudi::Property<std::string> m_actorName{this, "Actor", "EventDataService", "option to set the multi-service name"};
21 
22 public:
23  using extends::extends;
24 
26  STATUS initialize() override {
29  if ( !sc.isSuccess() ) {
30  error() << "Cannot initialize base class!" << endmsg;
31  return sc;
32  }
33  m_actor = nullptr;
34  IPartitionControl* tmpPtr = nullptr;
35  sc = service( m_actorName, tmpPtr );
36  m_actor = tmpPtr;
37  if ( !sc.isSuccess() ) {
38  error() << "Cannot retrieve partition controller \"" << m_actorName.value() << "\"!" << endmsg;
39  return sc;
40  }
41  return sc;
42  }
44  STATUS finalize() override {
45  m_actor = nullptr;
46  return AlgTool::finalize();
47  }
48 
49  void _check( STATUS sc, CSTR msg ) const { error() << msg << " Status=" << sc.getCode() << endmsg; }
50 #define CHECK( x, y ) \
51  if ( !x.isSuccess() ) _check( x, y ); \
52  return x;
53 
55  STATUS create( CSTR nam, CSTR typ ) override {
56  STATUS sc = m_actor ? m_actor->create( nam, typ ) : IInterface::Status::NO_INTERFACE;
57  CHECK( sc, "Cannot create partition: " + nam + " of type " + typ );
58  }
60  STATUS create( CSTR nam, CSTR typ, IInterface*& pPartition ) override {
61  STATUS sc = m_actor ? m_actor->create( nam, typ, pPartition ) : IInterface::Status::NO_INTERFACE;
62  CHECK( sc, "Cannot create partition: " + nam + " of type " + typ );
63  }
65  STATUS drop( CSTR nam ) override {
66  STATUS sc = m_actor ? m_actor->drop( nam ) : IInterface::Status::NO_INTERFACE;
67  CHECK( sc, "Cannot drop partition: " + nam );
68  }
70  STATUS drop( IInterface* pPartition ) override {
71  STATUS sc = m_actor ? m_actor->drop( pPartition ) : IInterface::Status::NO_INTERFACE;
72  CHECK( sc, "Cannot drop partition by Interface." );
73  }
75  STATUS activate( CSTR nam ) override {
76  STATUS sc = m_actor ? m_actor->activate( nam ) : IInterface::Status::NO_INTERFACE;
77  CHECK( sc, "Cannot activate partition: " + nam );
78  }
80  STATUS activate( IInterface* pPartition ) override {
81  STATUS sc = m_actor ? m_actor->activate( pPartition ) : IInterface::Status::NO_INTERFACE;
82  CHECK( sc, "Cannot activate partition by Interface." );
83  }
85  STATUS get( CSTR nam, IInterface*& pPartition ) const override {
86  STATUS sc = m_actor ? m_actor->get( nam, pPartition ) : IInterface::Status::NO_INTERFACE;
87  CHECK( sc, "Cannot get partition " + nam );
88  }
90  STATUS activePartition( std::string& nam, IInterface*& pPartition ) const override {
91  STATUS sc = m_actor ? m_actor->activePartition( nam, pPartition ) : IInterface::Status::NO_INTERFACE;
92  CHECK( sc, "Cannot determine active partition." );
93  }
94 };
95 
96 // Declaration of the Tool Factory
Requested interface is not available.
MsgStream & msg() const
shortcut for the method msgStream(MSG::INFO)
STATUS create(CSTR nam, CSTR typ) override
Create a partition object. The name identifies the partition uniquely.
Implementation of property with value of concrete type.
Definition: Property.h:352
StatusCode initialize() override
Definition: AlgTool.cpp:201
STATUS finalize() override
Finalize.
void _check(STATUS sc, CSTR msg) const
STATUS activePartition(std::string &nam, IInterface *&pPartition) const override
Access the active partition object.
bool isSuccess() const
Definition: StatusCode.h:267
STATUS activate(CSTR nam) override
Activate a partition object. The name identifies the partition uniquely.
virtual StatusCode create(const std::string &name, const std::string &type)=0
Create a partition object. The name identifies the partition uniquely.
Gaudi::Property< std::string > m_actorName
STL class.
#define DECLARE_COMPONENT(type)
StatusCode finalize() override
Definition: AlgTool.cpp:268
STATUS drop(CSTR nam) override
Drop a partition object. The name identifies the partition uniquely.
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
STATUS drop(IInterface *pPartition) override
Drop a partition object. The name identifies the partition uniquely.
SmartIF< IPartitionControl > m_actor
reference to Partition Controller
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
virtual StatusCode get(const std::string &name, IInterface *&pPartition) const =0
Access a partition object. The name identifies the partition uniquely.
Definition of the basic interface.
Definition: IInterface.h:244
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:128
virtual StatusCode activePartition(std::string &name, IInterface *&pPartition) const =0
Access the active partition object.
Create / access partitions.
Base class used to extend a class implementing other interfaces.
Definition: extends.h:10
STATUS initialize() override
Initialize.
virtual StatusCode drop(const std::string &name)=0
Drop a partition object. The name identifies the partition uniquely.
virtual StatusCode activate(const std::string &name)=0
Activate a partition object. The name identifies the partition uniquely.
code_t getCode() const
Retrieve value ("checks" the StatusCode)
Definition: StatusCode.h:137
STATUS activate(IInterface *pPartition) override
Activate a partition object.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
STATUS create(CSTR nam, CSTR typ, IInterface *&pPartition) override
Create a partition object. The name identifies the partition uniquely.
#define CHECK(x, y)