Gaudi Framework, version v25r0

Home   Generated: Mon Feb 17 2014
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
PartitionSwitchAlg.cpp
Go to the documentation of this file.
1 // ====================================================================
2 // PartitionSwitchAlg.cpp
3 // --------------------------------------------------------------------
4 //
5 // Author : Markus Frank
6 //
7 // ====================================================================
10 #include "GaudiKernel/MsgStream.h"
11 #include "GaudiKernel/IToolSvc.h"
12 #include "GaudiKernel/IAlgTool.h"
13 #include "GaudiKernel/SmartIF.h"
14 
24 class PartitionSwitchAlg : public extends1<Algorithm, IPartitionControl> {
25 
26  typedef StatusCode STATUS;
27  typedef const std::string& CSTR;
28 
29 private:
30 
37 
38 public:
39 
42  : base_class(name, pSvcLocator), m_actor(0)
43  {
44  declareProperty("Partition", m_partName);
45  declareProperty("Tool", m_toolType="PartitionSwitchTool");
46  }
48  virtual ~PartitionSwitchAlg() {
49  }
50 
52  virtual STATUS initialize() {
53  MsgStream log(msgSvc(), name());
55  STATUS sc = toolSvc()->retrieveTool(m_toolType,m_actor,this);
56  if ( sc.isFailure() ) {
57  log << MSG::ERROR << "Unable to load PartitionSwitchTool "
58  << m_toolType << endmsg;
59  return sc;
60  }
62  if ( tool ) toolSvc()->releaseTool(tool);
64  IInterface* partititon = 0;
65  sc = m_actor->get(m_partName, partititon);
66  if ( !sc.isSuccess() ) {
67  log << MSG::ERROR << "Cannot access partition \""
68  << m_partName << "\"" << endmsg;
69  }
70  return sc;
71  }
72 
74  virtual STATUS finalize() {
76  if ( tool ) toolSvc()->releaseTool(tool);
77  m_actor = 0;
78  return STATUS::SUCCESS;
79  }
80 
82  virtual STATUS execute() {
83  if ( m_actor ) {
85  if ( !sc.isSuccess() ) {
86  MsgStream log(msgSvc(), name());
87  log << MSG::ERROR << "Cannot activate partition \""
88  << m_partName << "\"!" << endmsg;
89  }
90  return sc;
91  }
92  MsgStream log(msgSvc(), name());
93  log << MSG::ERROR << "The partition control tool \"" << name()
94  << "." << m_toolType << "\" cannot be accessed!" << endmsg;
95  return STATUS::FAILURE;
96  }
97 
98  void _check(STATUS sc, CSTR msg) const {
99  MsgStream log(msgSvc(), name());
100  log << MSG::ERROR << msg << " Status=" << sc.getCode() << endmsg;
101  }
102 #define CHECK(x,y) if ( !x.isSuccess() ) _check(x, y); return x;
103 
105  virtual STATUS create(CSTR nam, CSTR typ) {
106  STATUS sc = m_actor ? m_actor->create(nam,typ) : NO_INTERFACE;
107  CHECK(sc, "Cannot create partition: "+nam+" of type "+typ);
108  }
110  virtual STATUS create(CSTR nam, CSTR typ, IInterface*& pPartition) {
111  STATUS sc = m_actor ? m_actor->create(nam,typ,pPartition) : NO_INTERFACE;
112  CHECK(sc, "Cannot create partition: "+nam+" of type "+typ);
113  }
115  virtual STATUS drop(CSTR nam) {
117  CHECK(sc, "Cannot drop partition: "+nam);
118  }
120  virtual STATUS drop(IInterface* pPartition) {
121  STATUS sc = m_actor ? m_actor->drop(pPartition) : NO_INTERFACE;
122  CHECK(sc, "Cannot drop partition by Interface.");
123  }
125  virtual STATUS activate(CSTR nam) {
127  CHECK(sc, "Cannot activate partition: "+nam);
128  }
130  virtual STATUS activate(IInterface* pPartition) {
131  STATUS sc = m_actor ? m_actor->activate(pPartition) : NO_INTERFACE;
132  CHECK(sc, "Cannot activate partition by Interface.");
133  }
135  virtual STATUS get(CSTR nam, IInterface*& pPartition) const {
136  STATUS sc = m_actor ? m_actor->get(nam, pPartition) : NO_INTERFACE;
137  CHECK(sc, "Cannot get partition "+nam);
138  }
140  virtual STATUS activePartition(std::string& nam, IInterface*& pPartition) const {
141  STATUS sc = m_actor ? m_actor->activePartition(nam, pPartition) : NO_INTERFACE;
142  CHECK(sc, "Cannot determine active partition.");
143  }
144 };
145 

Generated at Mon Feb 17 2014 14:37:39 for Gaudi Framework, version v25r0 by Doxygen version 1.8.2 written by Dimitri van Heesch, © 1997-2004