Gaudi Framework, version v23r5

Home   Generated: Wed Nov 28 2012
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
PartitionSwitchAlg.cpp
Go to the documentation of this file.
1 // $Header: /tmp/svngaudi/tmp.jEpFh25751/Gaudi/GaudiSvc/src/DataSvc/PartitionSwitchAlg.cpp,v 1.2 2006/01/19 07:27:21 mato Exp $
2 // ====================================================================
3 // PartitionSwitchAlg.cpp
4 // --------------------------------------------------------------------
5 //
6 // Author : Markus Frank
7 //
8 // ====================================================================
10 #include "GaudiKernel/AlgFactory.h"
11 #include "GaudiKernel/Algorithm.h"
12 #include "GaudiKernel/MsgStream.h"
13 #include "GaudiKernel/IToolSvc.h"
14 #include "GaudiKernel/IAlgTool.h"
15 #include "GaudiKernel/SmartIF.h"
16 
26 class PartitionSwitchAlg : public extends1<Algorithm, IPartitionControl> {
27 
28  typedef StatusCode STATUS;
29  typedef const std::string& CSTR;
30 
31 private:
32 
39 
40 public:
41 
44  : base_class(name, pSvcLocator), m_actor(0)
45  {
46  declareProperty("Partition", m_partName);
47  declareProperty("Tool", m_toolType="PartitionSwitchTool");
48  }
50  virtual ~PartitionSwitchAlg() {
51  }
52 
54  virtual STATUS initialize() {
55  MsgStream log(msgSvc(), name());
57  STATUS sc = toolSvc()->retrieveTool(m_toolType,m_actor,this);
58  if ( sc.isFailure() ) {
59  log << MSG::ERROR << "Unable to load PartitionSwitchTool "
60  << m_toolType << endmsg;
61  return sc;
62  }
64  if ( tool ) toolSvc()->releaseTool(tool);
66  IInterface* partititon = 0;
67  sc = m_actor->get(m_partName, partititon);
68  if ( !sc.isSuccess() ) {
69  log << MSG::ERROR << "Cannot access partition \""
70  << m_partName << "\"" << endmsg;
71  }
72  return sc;
73  }
74 
76  virtual STATUS finalize() {
78  if ( tool ) toolSvc()->releaseTool(tool);
79  m_actor = 0;
80  return STATUS::SUCCESS;
81  }
82 
84  virtual STATUS execute() {
85  if ( m_actor ) {
87  if ( !sc.isSuccess() ) {
88  MsgStream log(msgSvc(), name());
89  log << MSG::ERROR << "Cannot activate partition \""
90  << m_partName << "\"!" << endmsg;
91  }
92  return sc;
93  }
94  MsgStream log(msgSvc(), name());
95  log << MSG::ERROR << "The partition control tool \"" << name()
96  << "." << m_toolType << "\" cannot be accessed!" << endmsg;
97  return STATUS::FAILURE;
98  }
99 
100  void _check(STATUS sc, CSTR msg) const {
101  MsgStream log(msgSvc(), name());
102  log << MSG::ERROR << msg << " Status=" << sc.getCode() << endmsg;
103  }
104 #define CHECK(x,y) if ( !x.isSuccess() ) _check(x, y); return x;
105 
107  virtual STATUS create(CSTR nam, CSTR typ) {
108  STATUS sc = m_actor ? m_actor->create(nam,typ) : NO_INTERFACE;
109  CHECK(sc, "Cannot create partition: "+nam+" of type "+typ);
110  }
112  virtual STATUS create(CSTR nam, CSTR typ, IInterface*& pPartition) {
113  STATUS sc = m_actor ? m_actor->create(nam,typ,pPartition) : NO_INTERFACE;
114  CHECK(sc, "Cannot create partition: "+nam+" of type "+typ);
115  }
117  virtual STATUS drop(CSTR nam) {
119  CHECK(sc, "Cannot drop partition: "+nam);
120  }
122  virtual STATUS drop(IInterface* pPartition) {
123  STATUS sc = m_actor ? m_actor->drop(pPartition) : NO_INTERFACE;
124  CHECK(sc, "Cannot drop partition by Interface.");
125  }
127  virtual STATUS activate(CSTR nam) {
129  CHECK(sc, "Cannot activate partition: "+nam);
130  }
132  virtual STATUS activate(IInterface* pPartition) {
133  STATUS sc = m_actor ? m_actor->activate(pPartition) : NO_INTERFACE;
134  CHECK(sc, "Cannot activate partition by Interface.");
135  }
137  virtual STATUS get(CSTR nam, IInterface*& pPartition) const {
138  STATUS sc = m_actor ? m_actor->get(nam, pPartition) : NO_INTERFACE;
139  CHECK(sc, "Cannot get partition "+nam);
140  }
142  virtual STATUS activePartition(std::string& nam, IInterface*& pPartition) const {
143  STATUS sc = m_actor ? m_actor->activePartition(nam, pPartition) : NO_INTERFACE;
144  CHECK(sc, "Cannot determine active partition.");
145  }
146 };
147 

Generated at Wed Nov 28 2012 12:17:10 for Gaudi Framework, version v23r5 by Doxygen version 1.8.2 written by Dimitri van Heesch, © 1997-2004