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"
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;
27 
28 public:
29 
32  : base_class(typ, nam , parent)
33  {
34  declareProperty("Actor", m_actorName = "EventDataService");
35  }
38  m_actor = 0;
39  }
40 
42  virtual STATUS 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
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
unsigned long getCode() const
Get the status code by value.
Definition: StatusCode.h:92
virtual StatusCode finalize()
Finalize (from INITIALIZED to CONFIGURED).
Definition: AlgTool.cpp:434
Requested interface is not available.
Definition: IInterface.h:221
void _check(STATUS sc, CSTR msg) const
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:75
virtual STATUS create(CSTR nam, CSTR typ)
Create a partition object. The name identifies the partition uniquely.
virtual STATUS drop(CSTR nam)
Drop a partition object. The name identifies the partition uniquely.
virtual STATUS activate(IInterface *pPartition)
Activate a partition object.
virtual ~PartitionSwitchTool()
Standard destructor.
#define DECLARE_COMPONENT(type)
Definition: PluginService.h:36
std::string m_actorName
Job option to set the multi-service name.
virtual STATUS initialize()
Initialize.
#define CHECK(x, y)
IMessageSvc * msgSvc() const
Retrieve pointer to message service.
Definition: AlgTool.cpp:79
SmartIF< IPartitionControl > m_actor
reference to Partition Controller
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:30
Property * declareProperty(const std::string &name, T &property, const std::string &doc="none") const
Declare the named property.
Definition: AlgTool.h:234
Definition of the basic interface.
Definition: IInterface.h:160
Base class used to extend a class implementing other interfaces.
Definition: extends.h:10
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:179
TYPE * get() const
Get interface pointer.
Definition: SmartIF.h:62
PartitionSwitchTool(CSTR typ, CSTR nam, const IInterface *parent)
Standard constructor.
virtual STATUS activate(CSTR nam)
Activate a partition object. The name identifies the partition uniquely.
virtual STATUS activePartition(std::string &nam, IInterface *&pPartition) const
Access the active partition object.
Create / access partitions.
virtual const IInterface * parent() const
Retrieve parent of the sub-algtool.
Definition: AlgTool.cpp:65
virtual StatusCode initialize()
Initialization (from CONFIGURED to INITIALIZED).
Definition: AlgTool.cpp:307
virtual STATUS finalize()
Finalize.
virtual STATUS drop(IInterface *pPartition)
Drop a partition object. The name identifies the partition uniquely.
virtual const std::string & name() const
Retrieve full identifying name of the concrete tool object.
Definition: AlgTool.cpp:51
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
virtual STATUS create(CSTR nam, CSTR typ, IInterface *&pPartition)
Create a partition object. The name identifies the partition uniquely.
const std::string & CSTR