PartitionSwitchAlg Class Reference

Small algorithm which switches the partition of a configurable multi-service. More...

Inheritance diagram for PartitionSwitchAlg:
Collaboration diagram for PartitionSwitchAlg:

Public Member Functions

 PartitionSwitchAlg (const std::string &name, ISvcLocator *pSvcLocator)
 Standard algorithm constructor. More...
 
 ~PartitionSwitchAlg () override=default
 Standard Destructor. More...
 
STATUS initialize () override
 Initialize. More...
 
STATUS finalize () override
 Finalize. More...
 
STATUS execute () override
 Execute procedure. More...
 
STATUS create (CSTR nam, CSTR typ) override
 Create a partition object. The name identifies the partition uniquely. More...
 
STATUS create (CSTR nam, CSTR typ, IInterface *&pPartition) override
 Create a partition object. The name identifies the partition uniquely. More...
 
STATUS drop (CSTR nam) override
 Drop a partition object. The name identifies the partition uniquely. More...
 
STATUS drop (IInterface *pPartition) override
 Drop a partition object. The name identifies the partition uniquely. More...
 
STATUS activate (CSTR nam) override
 Activate a partition object. The name identifies the partition uniquely. More...
 
STATUS activate (IInterface *pPartition) override
 Activate a partition object. More...
 
STATUS get (CSTR nam, IInterface *&pPartition) const override
 Access a partition object. The name identifies the partition uniquely. More...
 
STATUS activePartition (std::string &nam, IInterface *&pPartition) const override
 Access the active partition object. More...
 
- Public Member Functions inherited from extends< BASE, Interfaces >
void * i_cast (const InterfaceID &tid) const override
 Implementation of IInterface::i_cast. More...
 
StatusCode queryInterface (const InterfaceID &ti, void **pp) override
 Implementation of IInterface::queryInterface. More...
 
std::vector< std::string > getInterfaceNames () const override
 Implementation of IInterface::getInterfaceNames. More...
 
 ~extends () override=default
 Virtual destructor. More...
 
void * i_cast (const InterfaceID &tid) const override
 Implementation of IInterface::i_cast. More...
 
StatusCode queryInterface (const InterfaceID &ti, void **pp) override
 Implementation of IInterface::queryInterface. More...
 
std::vector< std::string > getInterfaceNames () const override
 Implementation of IInterface::getInterfaceNames. More...
 
 ~extends () override=default
 Virtual destructor. More...
 
- Public Member Functions inherited from extend_interfaces< Interfaces...>
 ~extend_interfaces () override=default
 Virtual destructor. More...
 
 ~extend_interfaces () override=default
 Virtual destructor. More...
 

Private Types

using STATUS = StatusCode
 
using CSTR = const std::string &
 

Private Member Functions

StatusCode log_ (StatusCode sc, const std::string &msg) const
 
template<typename... FArgs, typename... Args>
StatusCode fwd_ (StatusCode(IPartitionControl::*fun)(FArgs...), Args &&...args)
 
template<typename... FArgs, typename... Args>
StatusCode fwd_ (StatusCode(IPartitionControl::*fun)(FArgs...) const, Args &&...args) const
 

Private Attributes

std::string m_partName
 Job option to set the requested partition name. More...
 
std::string m_toolType
 Job option to set the tool manipulating the multi-service name. More...
 
IPartitionControlm_actor = nullptr
 reference to Partition Controller More...
 

Additional Inherited Members

- Public Types inherited from extends< BASE, Interfaces >
using base_class = extends
 Typedef to this class. More...
 
using extend_interfaces_base = extend_interfaces< Interfaces...>
 Typedef to the base of this class. More...
 
using base_class = extends
 Typedef to this class. More...
 
using extend_interfaces_base = extend_interfaces< Interfaces...>
 Typedef to the base of this class. More...
 
- Public Types inherited from extend_interfaces< Interfaces...>
using ext_iids = typename Gaudi::interface_list_cat< typename Interfaces::ext_iids...>::type
 take union of the ext_iids of all Interfaces... More...
 
using ext_iids = typename Gaudi::interface_list_cat< typename Interfaces::ext_iids...>::type
 take union of the ext_iids of all Interfaces... More...
 

Detailed Description

Small algorithm which switches the partition of a configurable multi-service.

The algorithm can be part of a sequence, which allows for e.g. buffer tampering.

Author
: M.Frank
Version
: 1.0

Definition at line 25 of file PartitionSwitchAlg.cpp.

Member Typedef Documentation

using PartitionSwitchAlg::CSTR = const std::string&
private

Definition at line 28 of file PartitionSwitchAlg.cpp.

Definition at line 27 of file PartitionSwitchAlg.cpp.

Constructor & Destructor Documentation

PartitionSwitchAlg::PartitionSwitchAlg ( const std::string &  name,
ISvcLocator pSvcLocator 
)
inline

Standard algorithm constructor.

Definition at line 42 of file PartitionSwitchAlg.cpp.

43  : base_class(name, pSvcLocator)
44  {
45  declareProperty("Partition", m_partName);
46  declareProperty("Tool", m_toolType="PartitionSwitchTool");
47  }
extends base_class
Typedef to this class.
Definition: extends.h:14
std::string m_partName
Job option to set the requested partition name.
std::string m_toolType
Job option to set the tool manipulating the multi-service name.
PartitionSwitchAlg::~PartitionSwitchAlg ( )
overridedefault

Standard Destructor.

Member Function Documentation

STATUS PartitionSwitchAlg::activate ( CSTR  nam)
inlineoverride

Activate a partition object. The name identifies the partition uniquely.

Definition at line 133 of file PartitionSwitchAlg.cpp.

133  {
134  auto sc = fwd_<CSTR>(&IPartitionControl::activate,nam);
135  return sc.isSuccess() ? sc : log_(sc, "Cannot activate partition: "+nam);
136  }
StatusCode log_(StatusCode sc, const std::string &msg) const
virtual StatusCode activate(const std::string &name)=0
Activate a partition object. The name identifies the partition uniquely.
STATUS PartitionSwitchAlg::activate ( IInterface pPartition)
inlineoverride

Activate a partition object.

Definition at line 138 of file PartitionSwitchAlg.cpp.

138  {
139  auto sc = fwd_<IInterface*>(&IPartitionControl::activate, pPartition);
140  return sc.isSuccess() ? sc : log_(sc, "Cannot activate partition by Interface.");
141  }
StatusCode log_(StatusCode sc, const std::string &msg) const
virtual StatusCode activate(const std::string &name)=0
Activate a partition object. The name identifies the partition uniquely.
STATUS PartitionSwitchAlg::activePartition ( std::string &  nam,
IInterface *&  pPartition 
) const
inlineoverride

Access the active partition object.

Definition at line 148 of file PartitionSwitchAlg.cpp.

148  {
149  auto sc = fwd_<std::string&,IInterface*&>(&IPartitionControl::activePartition,nam,pPartition);
150  return sc.isSuccess() ? sc : log_(sc, "Cannot determine active partition.");
151  }
virtual StatusCode activePartition(std::string &name, IInterface *&pPartition) const =0
Access the active partition object.
StatusCode log_(StatusCode sc, const std::string &msg) const
STATUS PartitionSwitchAlg::create ( CSTR  nam,
CSTR  typ 
)
inlineoverride

Create a partition object. The name identifies the partition uniquely.

Definition at line 113 of file PartitionSwitchAlg.cpp.

113  {
114  auto sc = fwd_<CSTR,CSTR>(&IPartitionControl::create,nam,typ);
115  return sc.isSuccess() ? sc : log_(sc, "Cannot create partition: "+nam+" of type "+typ);
116  }
StatusCode log_(StatusCode sc, const std::string &msg) const
virtual StatusCode create(const std::string &name, const std::string &type)=0
Create a partition object. The name identifies the partition uniquely.
STATUS PartitionSwitchAlg::create ( CSTR  nam,
CSTR  typ,
IInterface *&  pPartition 
)
inlineoverride

Create a partition object. The name identifies the partition uniquely.

Definition at line 118 of file PartitionSwitchAlg.cpp.

118  {
119  auto sc = fwd_<CSTR,CSTR,IInterface*&>(&IPartitionControl::create,nam,typ,pPartition);
120  return sc.isSuccess() ? sc : log_(sc, "Cannot create partition: "+nam+" of type "+typ);
121  }
StatusCode log_(StatusCode sc, const std::string &msg) const
virtual StatusCode create(const std::string &name, const std::string &type)=0
Create a partition object. The name identifies the partition uniquely.
STATUS PartitionSwitchAlg::drop ( CSTR  nam)
inlineoverride

Drop a partition object. The name identifies the partition uniquely.

Definition at line 123 of file PartitionSwitchAlg.cpp.

123  {
124  auto sc = fwd_<CSTR>(&IPartitionControl::drop,nam);
125  return sc.isSuccess() ? sc : log_(sc, "Cannot drop partition: "+nam);
126  }
StatusCode log_(StatusCode sc, const std::string &msg) const
virtual StatusCode drop(const std::string &name)=0
Drop a partition object. The name identifies the partition uniquely.
STATUS PartitionSwitchAlg::drop ( IInterface pPartition)
inlineoverride

Drop a partition object. The name identifies the partition uniquely.

Definition at line 128 of file PartitionSwitchAlg.cpp.

128  {
129  auto sc = fwd_<IInterface*>(&IPartitionControl::drop,pPartition);
130  return sc.isSuccess() ? sc : log_(sc, "Cannot drop partition by Interface.");
131  }
StatusCode log_(StatusCode sc, const std::string &msg) const
virtual StatusCode drop(const std::string &name)=0
Drop a partition object. The name identifies the partition uniquely.
STATUS PartitionSwitchAlg::execute ( )
inlineoverride

Execute procedure.

Definition at line 82 of file PartitionSwitchAlg.cpp.

82  {
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  }
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:76
std::string m_partName
Job option to set the requested partition name.
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
IPartitionControl * m_actor
reference to Partition Controller
virtual StatusCode activate(const std::string &name)=0
Activate a partition object. The name identifies the partition uniquely.
std::string m_toolType
Job option to set the tool manipulating the multi-service name.
STATUS PartitionSwitchAlg::finalize ( )
inlineoverride

Finalize.

Definition at line 74 of file PartitionSwitchAlg.cpp.

74  {
76  if ( tool ) toolSvc()->releaseTool(tool);
77  m_actor = nullptr;
78  return STATUS::SUCCESS;
79  }
Small smart pointer class with automatic reference counting for IInterface.
Definition: IConverter.h:14
IPartitionControl * m_actor
reference to Partition Controller
template<typename... FArgs, typename... Args>
StatusCode PartitionSwitchAlg::fwd_ ( StatusCode(IPartitionControl::*)(FArgs...)  fun,
Args &&...  args 
)
inlineprivate

Definition at line 104 of file PartitionSwitchAlg.cpp.

104  {
105  return m_actor ? (m_actor->*fun)(std::forward<Args>(args)...) : NO_INTERFACE;
106  }
list args
Definition: gaudirun.py:290
double fun(const std::vector< double > &x)
Definition: PFuncTest.cpp:26
IPartitionControl * m_actor
reference to Partition Controller
template<typename... FArgs, typename... Args>
StatusCode PartitionSwitchAlg::fwd_ ( StatusCode(IPartitionControl::*)(FArgs...) const  fun,
Args &&...  args 
) const
inlineprivate

Definition at line 108 of file PartitionSwitchAlg.cpp.

108  {
109  return m_actor ? (m_actor->*fun)(std::forward<Args>(args)...) : NO_INTERFACE;
110  }
list args
Definition: gaudirun.py:290
double fun(const std::vector< double > &x)
Definition: PFuncTest.cpp:26
IPartitionControl * m_actor
reference to Partition Controller
STATUS PartitionSwitchAlg::get ( CSTR  nam,
IInterface *&  pPartition 
) const
inlineoverride

Access a partition object. The name identifies the partition uniquely.

Definition at line 143 of file PartitionSwitchAlg.cpp.

143  {
144  auto sc = fwd_<CSTR,IInterface*&>(&IPartitionControl::get, nam, pPartition);
145  return sc.isSuccess() ? sc : log_(sc, "Cannot get partition "+nam);
146  }
StatusCode log_(StatusCode sc, const std::string &msg) const
virtual StatusCode get(const std::string &name, IInterface *&pPartition) const =0
Access a partition object. The name identifies the partition uniquely.
STATUS PartitionSwitchAlg::initialize ( )
inlineoverride

Initialize.

Release old tool

Now check if the partition is present. If not: try to create it

Definition at line 52 of file PartitionSwitchAlg.cpp.

52  {
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 = nullptr;
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  }
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
Small smart pointer class with automatic reference counting for IInterface.
Definition: IConverter.h:14
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:76
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:86
std::string m_partName
Job option to set the requested partition name.
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
Definition of the basic interface.
Definition: IInterface.h:234
virtual StatusCode get(const std::string &name, IInterface *&pPartition) const =0
Access a partition object. The name identifies the partition uniquely.
IPartitionControl * m_actor
reference to Partition Controller
std::string m_toolType
Job option to set the tool manipulating the multi-service name.
StatusCode PartitionSwitchAlg::log_ ( StatusCode  sc,
const std::string &  msg 
) const
inlineprivate

Definition at line 98 of file PartitionSwitchAlg.cpp.

98  {
99  MsgStream log(msgSvc(), name());
100  log << MSG::ERROR << msg << " Status=" << sc.getCode() << endmsg;
101  return sc;
102  }
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
unsigned long getCode() const
Get the status code by value.
Definition: StatusCode.h:93

Member Data Documentation

IPartitionControl* PartitionSwitchAlg::m_actor = nullptr
private

reference to Partition Controller

Definition at line 37 of file PartitionSwitchAlg.cpp.

std::string PartitionSwitchAlg::m_partName
private

Job option to set the requested partition name.

Definition at line 33 of file PartitionSwitchAlg.cpp.

std::string PartitionSwitchAlg::m_toolType
private

Job option to set the tool manipulating the multi-service name.

Definition at line 35 of file PartitionSwitchAlg.cpp.


The documentation for this class was generated from the following file: