| # Gaudi Framework, version v22r0 |

Home |  | Generated: 9 Feb 2011

# PartitionSwitchTool.cpp

Go to the documentation of this file.

    00001 // $Id: PartitionSwitchTool.cpp,v 1.2 2006/01/10 20:09:25 hmd Exp $
    00002
    00003 // Framework include files
    00004 #include "GaudiKernel/AlgTool.h"
    00005 #include "GaudiKernel/SmartIF.h"
    00006 #include "GaudiKernel/MsgStream.h"
    00007 #include "GaudiKernel/Tokenizer.h"
    00008 #include "GaudiKernel/ToolFactory.h"
    00009 #include "GaudiKernel/IPartitionControl.h"
    00010
    00016 class PartitionSwitchTool: public extends1<AlgTool, IPartitionControl> {
    00017
    00018   typedef const std::string& CSTR;
    00019   typedef StatusCode         STATUS;
    00020
    00021 private:
    00022
    00024   std::string                m_actorName;
    00026   SmartIF<IPartitionControl> m_actor;
    00027
    00028 public:
    00029
    00031   PartitionSwitchTool(CSTR typ, CSTR nam, const IInterface* parent)
    00032   : base_class(typ, nam , parent)
    00033   {
    00034     declareProperty("Actor", m_actorName = "EventDataService");
    00035   }
    00037   virtual ~PartitionSwitchTool()   {
    00038     m_actor = 0;
    00039   }
    00040
    00042   virtual STATUS initialize()  {
    00044     STATUS sc = AlgTool::initialize();
    00045     MsgStream log(msgSvc(), name());
    00046     if ( !sc.isSuccess() )  {
    00047       log << MSG::ERROR << "Cannot initialize base class!" << endmsg;
    00048       return sc;
    00049     }
    00050     m_actor = 0;
    00051     IPartitionControl* tmpPtr = 0;
    00052     sc = service(m_actorName, tmpPtr);
    00053     m_actor = tmpPtr;
    00054     if ( !sc.isSuccess() )  {
    00055       log << MSG::ERROR << "Cannot retrieve partition controller \""
    00056           << m_actorName << "\"!" << endmsg;
    00057       return sc;
    00058     }
    00059     return sc;
    00060   }
    00062   virtual STATUS finalize()   {
    00063     m_actor = 0;
    00064     return AlgTool::finalize();
    00065   }
    00066
    00067   void _check(STATUS sc, CSTR msg)  const {
    00068     MsgStream log(msgSvc(), name());
    00069     log << MSG::ERROR << msg << " Status=" << sc.getCode() << endmsg;
    00070   }
    00071 #define CHECK(x,y) if ( !x.isSuccess() ) _check(x, y); return x;
    00072
    00074   virtual STATUS create(CSTR nam, CSTR typ)  {
    00075     STATUS sc = m_actor ? m_actor->create(nam,typ) : NO_INTERFACE;
    00076     CHECK(sc, "Cannot create partition: "+nam+" of type "+typ);
    00077   }
    00079   virtual STATUS create(CSTR nam, CSTR typ, IInterface*& pPartition)  {
    00080     STATUS sc = m_actor ? m_actor->create(nam,typ,pPartition) : NO_INTERFACE;
    00081     CHECK(sc, "Cannot create partition: "+nam+" of type "+typ);
    00082   }
    00084   virtual STATUS drop(CSTR nam)  {
    00085     STATUS sc = m_actor ? m_actor->drop(nam) : NO_INTERFACE;
    00086     CHECK(sc, "Cannot drop partition: "+nam);
    00087   }
    00089   virtual STATUS drop(IInterface* pPartition)  {
    00090     STATUS sc = m_actor ? m_actor->drop(pPartition) : NO_INTERFACE;
    00091     CHECK(sc, "Cannot drop partition by Interface.");
    00092   }
    00094   virtual STATUS activate(CSTR nam)  {
    00095     STATUS sc = m_actor ? m_actor->activate(nam) : NO_INTERFACE;
    00096     CHECK(sc, "Cannot activate partition: "+nam);
    00097   }
    00099   virtual STATUS activate(IInterface* pPartition)  {
    00100     STATUS sc = m_actor ? m_actor->activate(pPartition) : NO_INTERFACE;
    00101     CHECK(sc, "Cannot activate partition by Interface.");
    00102   }
    00104   virtual STATUS get(CSTR nam, IInterface*& pPartition) const  {
    00105     STATUS sc = m_actor ? m_actor->get(nam, pPartition) : NO_INTERFACE;
    00106     CHECK(sc, "Cannot get partition "+nam);
    00107   }
    00109   virtual STATUS activePartition(std::string& nam, IInterface*& pPartition) const  {
    00110     STATUS sc = m_actor ? m_actor->activePartition(nam, pPartition) : NO_INTERFACE;
    00111     CHECK(sc, "Cannot determine active partition.");
    00112   }
    00113 };
    00114
    00115 // Declaration of the Tool Factory
    00116 DECLARE_TOOL_FACTORY(PartitionSwitchTool)

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines