The Gaudi Framework  v30r3 (a5ef0a68)
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 
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"};
22 
23 public:
24  using extends::extends;
25 
27  STATUS initialize() override
28  {
31  if ( !sc.isSuccess() ) {
32  error() << "Cannot initialize base class!" << endmsg;
33  return sc;
34  }
35  m_actor = nullptr;
36  IPartitionControl* tmpPtr = nullptr;
37  sc = service( m_actorName, tmpPtr );
38  m_actor = tmpPtr;
39  if ( !sc.isSuccess() ) {
40  error() << "Cannot retrieve partition controller \"" << m_actorName.value() << "\"!" << endmsg;
41  return sc;
42  }
43  return sc;
44  }
46  STATUS finalize() override
47  {
48  m_actor = nullptr;
49  return AlgTool::finalize();
50  }
51 
52  void _check( STATUS sc, CSTR msg ) const { error() << msg << " Status=" << sc.getCode() << endmsg; }
53 #define CHECK( x, y ) \
54  if ( !x.isSuccess() ) _check( x, y ); \
55  return x;
56 
58  STATUS create( CSTR nam, CSTR typ ) override
59  {
60  STATUS sc = m_actor ? m_actor->create( nam, typ ) : IInterface::Status::NO_INTERFACE;
61  CHECK( sc, "Cannot create partition: " + nam + " of type " + typ );
62  }
64  STATUS create( CSTR nam, CSTR typ, IInterface*& pPartition ) override
65  {
66  STATUS sc = m_actor ? m_actor->create( nam, typ, pPartition ) : IInterface::Status::NO_INTERFACE;
67  CHECK( sc, "Cannot create partition: " + nam + " of type " + typ );
68  }
70  STATUS drop( CSTR nam ) override
71  {
72  STATUS sc = m_actor ? m_actor->drop( nam ) : IInterface::Status::NO_INTERFACE;
73  CHECK( sc, "Cannot drop partition: " + nam );
74  }
76  STATUS drop( IInterface* pPartition ) override
77  {
78  STATUS sc = m_actor ? m_actor->drop( pPartition ) : IInterface::Status::NO_INTERFACE;
79  CHECK( sc, "Cannot drop partition by Interface." );
80  }
82  STATUS activate( CSTR nam ) override
83  {
84  STATUS sc = m_actor ? m_actor->activate( nam ) : IInterface::Status::NO_INTERFACE;
85  CHECK( sc, "Cannot activate partition: " + nam );
86  }
88  STATUS activate( IInterface* pPartition ) override
89  {
90  STATUS sc = m_actor ? m_actor->activate( pPartition ) : IInterface::Status::NO_INTERFACE;
91  CHECK( sc, "Cannot activate partition by Interface." );
92  }
94  STATUS get( CSTR nam, IInterface*& pPartition ) const override
95  {
96  STATUS sc = m_actor ? m_actor->get( nam, pPartition ) : IInterface::Status::NO_INTERFACE;
97  CHECK( sc, "Cannot get partition " + nam );
98  }
100  STATUS activePartition( std::string& nam, IInterface*& pPartition ) const override
101  {
102  STATUS sc = m_actor ? m_actor->activePartition( nam, pPartition ) : IInterface::Status::NO_INTERFACE;
103  CHECK( sc, "Cannot determine active partition." );
104  }
105 };
106 
107 // 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:381
StatusCode initialize() override
Definition: AlgTool.cpp:223
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:287
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:293
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:51
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:277
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:129
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:146
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:209
STATUS create(CSTR nam, CSTR typ, IInterface *&pPartition) override
Create a partition object. The name identifies the partition uniquely.
#define CHECK(x, y)