| The Gaudi Framework v27r1

- 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/SmartIF.h"
4 #include "GaudiKernel/MsgStream.h"
5 #include "GaudiKernel/IPartitionControl.h"
6
12 class PartitionSwitchTool: public extends<AlgTool,
13 IPartitionControl> {
14
15 using CSTR = const std::string&;
16 using STATUS = StatusCode;
17
18 private:
19
21 std::string m_actorName;
23 SmartIF<IPartitionControl> m_actor;
24
25 public:
26
28 PartitionSwitchTool(const std::string& typ, const std::string& nam, const IInterface* parent)
29 : base_class( typ, nam , parent)
30 {
31 declareProperty("Actor", m_actorName = "EventDataService");
32 }
34 ~PartitionSwitchTool() override = default;
35
37 STATUS initialize() override {
39 STATUS sc = AlgTool::initialize();
40 if ( !sc.isSuccess() ) {
41 error() << "Cannot initialize base class!" << endmsg;
42 return sc;
43 }
44 m_actor = nullptr;
45 IPartitionControl* tmpPtr = nullptr;
46 sc = service(m_actorName, tmpPtr);
47 m_actor = tmpPtr;
48 if ( !sc.isSuccess() ) {
49 error() << "Cannot retrieve partition controller \""
50 << m_actorName << "\"!" << endmsg;
51 return sc;
52 }
53 return sc;
54 }
56 STATUS finalize() override {
57 m_actor = nullptr;
58 return AlgTool::finalize();
59 }
60
61 void _check(STATUS sc, CSTR msg) const {
62 error() << msg << " Status=" << sc.getCode() << endmsg;
63 }
64 #define CHECK(x,y) if ( !x.isSuccess() ) _check(x, y); return x;
65
67 STATUS create(CSTR nam, CSTR typ) override {
68 STATUS sc = m_actor ? m_actor->create(nam,typ) : NO_INTERFACE;
69 CHECK(sc, "Cannot create partition: "+nam+" of type "+typ);
70 }
72 STATUS create(CSTR nam, CSTR typ, IInterface*& pPartition) override {
73 STATUS sc = m_actor ? m_actor->create(nam,typ,pPartition) : NO_INTERFACE;
74 CHECK(sc, "Cannot create partition: "+nam+" of type "+typ);
75 }
77 STATUS drop(CSTR nam) override {
78 STATUS sc = m_actor ? m_actor->drop(nam) : NO_INTERFACE;
79 CHECK(sc, "Cannot drop partition: "+nam);
80 }
82 STATUS drop(IInterface* pPartition) override {
83 STATUS sc = m_actor ? m_actor->drop(pPartition) : NO_INTERFACE;
84 CHECK(sc, "Cannot drop partition by Interface.");
85 }
87 STATUS activate(CSTR nam) override {
88 STATUS sc = m_actor ? m_actor->activate(nam) : NO_INTERFACE;
89 CHECK(sc, "Cannot activate partition: "+nam);
90 }
92 STATUS activate(IInterface* pPartition) override {
93 STATUS sc = m_actor ? m_actor->activate(pPartition) : NO_INTERFACE;
94 CHECK(sc, "Cannot activate partition by Interface.");
95 }
97 STATUS get(CSTR nam, IInterface*& pPartition) const override {
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 STATUS sc = m_actor ? m_actor->activePartition(nam, pPartition) : NO_INTERFACE;
104 CHECK(sc, "Cannot determine active partition.");
105 }
106 };
107
108 // Declaration of the Tool Factory
109 DECLARE_COMPONENT(PartitionSwitchTool)
SmartIF< IPartitionControl >
CommonMessagingBase::msg
MsgStream & msg() const
shortcut for the method msgStream(MSG::INFO)
Definition: CommonMessaging.h:133
PartitionSwitchTool::create
STATUS create(CSTR nam, CSTR typ) override
Create a partition object. The name identifies the partition uniquely.
Definition: PartitionSwitchTool.cpp:67
IPartitionControl::activePartition
virtual StatusCode activePartition(std::string &name, IInterface *&pPartition) const =0
Access the active partition object.
StatusCode::getCode
unsigned long getCode() const
Get the status code by value.
Definition: StatusCode.h:93
MsgStream.h
AlgTool::initialize
StatusCode initialize() override
Definition: AlgTool.cpp:290
PartitionSwitchTool::finalize
STATUS finalize() override
Finalize.
Definition: PartitionSwitchTool.cpp:56
PartitionSwitchTool::_check
void _check(STATUS sc, CSTR msg) const
Definition: PartitionSwitchTool.cpp:61
StatusCode::isSuccess
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:76
AlgTool.h
PartitionSwitchTool::activate
STATUS activate(CSTR nam) override
Activate a partition object. The name identifies the partition uniquely.
Definition: PartitionSwitchTool.cpp:87
IPartitionControl::create
virtual StatusCode create(const std::string &name, const std::string &type)=0
Create a partition object. The name identifies the partition uniquely.
merge_files.sc
int sc
Definition: merge_files.py:167
DECLARE_COMPONENT
#define DECLARE_COMPONENT(type)
Definition: PluginService.h:36
PartitionSwitchTool::activePartition
STATUS activePartition(std::string &nam, IInterface *&pPartition) const override
Access the active partition object.
Definition: PartitionSwitchTool.cpp:102
PartitionSwitchTool::m_actorName
std::string m_actorName
Job option to set the multi-service name.
Definition: PartitionSwitchTool.cpp:21
std::string
STL class.
AlgTool::finalize
StatusCode finalize() override
Definition: AlgTool.cpp:360
PartitionSwitchTool::drop
STATUS drop(CSTR nam) override
Drop a partition object. The name identifies the partition uniquely.
Definition: PartitionSwitchTool.cpp:77
CHECK
#define CHECK(x, y)
Definition: PartitionSwitchTool.cpp:64
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:118
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:82
PartitionSwitchTool::m_actor
SmartIF< IPartitionControl > m_actor
reference to Partition Controller
Definition: PartitionSwitchTool.cpp:23
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
AlgTool::declareProperty
Property * declareProperty(const std::string &name, T &property, const std::string &doc="none") const
Declare the named property.
Definition: AlgTool.h:249
IInterface
Definition of the basic interface.
Definition: IInterface.h:234
SmartIF.h
IPartitionControl::get
virtual StatusCode get(const std::string &name, IInterface *&pPartition) const =0
Access a partition object. The name identifies the partition uniquely.
PartitionSwitchTool::PartitionSwitchTool
PartitionSwitchTool(const std::string &typ, const std::string &nam, const IInterface *parent)
Standard constructor.
Definition: PartitionSwitchTool.cpp:28
AlgTool::service
StatusCode service(const std::string &name, T *&svc, bool createIf=true) const
Access a service by name, creating it if it doesn't already exist.
Definition: AlgTool.h:195
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:37
CommonMessaging
Definition: CommonMessaging.h:58
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:92
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
PartitionSwitchTool::create
STATUS create(CSTR nam, CSTR typ, IInterface *&pPartition) override
Create a partition object. The name identifies the partition uniquely.
Definition: PartitionSwitchTool.cpp:72
AlgTool::parent
const IInterface * parent() const override
Retrieve parent of the sub-algtool.
Definition: AlgTool.cpp:79