| # Gaudi Framework, version v25r0 |

Home |  | Generated: Mon Feb 17 2014

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

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
PartitionSwitchTool.cpp
Go to the documentation of this file.
1 // $Id: PartitionSwitchTool.cpp,v 1.2 2006/01/10 20:09:25 hmd Exp $
2
3 // Framework include files
4 #include "GaudiKernel/AlgTool.h"
5 #include "GaudiKernel/SmartIF.h"
6 #include "GaudiKernel/MsgStream.h"
7 #include "GaudiKernel/Tokenizer.h"
8 #include "GaudiKernel/ToolFactory.h"
9 #include "GaudiKernel/IPartitionControl.h"
10
16 class PartitionSwitchTool: public extends1<AlgTool, IPartitionControl> {
17
18 typedef const std::string& CSTR;
19 typedef StatusCode STATUS;
20
21 private:
22
24 std::string m_actorName;
26 SmartIF<IPartitionControl> m_actor;
27
28 public:
29
31 PartitionSwitchTool(CSTR typ, CSTR nam, const IInterface* parent)
32 : base_class(typ, nam , parent)
33 {
34 declareProperty("Actor", m_actorName = "EventDataService");
35 }
37 virtual ~PartitionSwitchTool() {
38 m_actor = 0;
39 }
40
42 virtual STATUS initialize() {
44 STATUS sc = AlgTool::initialize();
45 MsgStream log(msgSvc(), name());
46 if ( !sc.isSuccess() ) {
47 log << MSG::ERROR << "Cannot initialize base class!" << endmsg;
48 return sc;
49 }
50 m_actor = 0;
51 IPartitionControl* tmpPtr = 0;
52 sc = service(m_actorName, tmpPtr);
53 m_actor = tmpPtr;
54 if ( !sc.isSuccess() ) {
55 log << MSG::ERROR << "Cannot retrieve partition controller \""
56 << m_actorName << "\"!" << endmsg;
57 return sc;
58 }
59 return sc;
60 }
62 virtual STATUS finalize() {
63 m_actor = 0;
64 return AlgTool::finalize();
65 }
66
67 void _check(STATUS sc, CSTR msg) const {
68 MsgStream log(msgSvc(), name());
69 log << MSG::ERROR << msg << " Status=" << sc.getCode() << endmsg;
70 }
71 #define CHECK(x,y) if ( !x.isSuccess() ) _check(x, y); return x;
72
74 virtual STATUS create(CSTR nam, CSTR typ) {
75 STATUS sc = m_actor ? m_actor->create(nam,typ) : NO_INTERFACE;
76 CHECK(sc, "Cannot create partition: "+nam+" of type "+typ);
77 }
79 virtual STATUS create(CSTR nam, CSTR typ, IInterface*& pPartition) {
80 STATUS sc = m_actor ? m_actor->create(nam,typ,pPartition) : NO_INTERFACE;
81 CHECK(sc, "Cannot create partition: "+nam+" of type "+typ);
82 }
84 virtual STATUS drop(CSTR nam) {
85 STATUS sc = m_actor ? m_actor->drop(nam) : NO_INTERFACE;
86 CHECK(sc, "Cannot drop partition: "+nam);
87 }
89 virtual STATUS drop(IInterface* pPartition) {
90 STATUS sc = m_actor ? m_actor->drop(pPartition) : NO_INTERFACE;
91 CHECK(sc, "Cannot drop partition by Interface.");
92 }
94 virtual STATUS activate(CSTR nam) {
95 STATUS sc = m_actor ? m_actor->activate(nam) : NO_INTERFACE;
96 CHECK(sc, "Cannot activate partition: "+nam);
97 }
99 virtual STATUS activate(IInterface* pPartition) {
100 STATUS sc = m_actor ? m_actor->activate(pPartition) : NO_INTERFACE;
101 CHECK(sc, "Cannot activate partition by Interface.");
102 }
104 virtual STATUS get(CSTR nam, IInterface*& pPartition) const {
105 STATUS sc = m_actor ? m_actor->get(nam, pPartition) : NO_INTERFACE;
106 CHECK(sc, "Cannot get partition "+nam);
107 }
109 virtual STATUS activePartition(std::string& nam, IInterface*& pPartition) const {
110 STATUS sc = m_actor ? m_actor->activePartition(nam, pPartition) : NO_INTERFACE;
111 CHECK(sc, "Cannot determine active partition.");
112 }
113 };
114
115 // Declaration of the Tool Factory
116 DECLARE_COMPONENT(PartitionSwitchTool)