Skip to content
Snippets Groups Projects

Return a failure statuscode from DictTransform::initialize() if initialisation of transform fails

Merged Christopher Rob Jones requested to merge LoKiArrayFunctors-ReturnFailureOnInitError into master
1 file
+ 21
19
Compare changes
  • Side-by-side
  • Inline
@@ -31,7 +31,9 @@ namespace LoKi
*/
template<class Transform>
class DictTransform : public GaudiTool, virtual public IParticleDictTool {
class DictTransform : public GaudiTool, virtual public IParticleDictTool
{
public:
// ======================================================================
@@ -39,7 +41,7 @@ namespace LoKi
DictTransform( const std::string& type,
const std::string& name,
const IInterface* parent)
: GaudiTool ( type, name , parent ), m_transform()
: GaudiTool ( type, name, parent )
{
declareInterface<IParticleDictTool>(this);
@@ -50,22 +52,26 @@ namespace LoKi
declareProperty
( "Options" , m_options ,
"dictionary of options passed to the Transform");
}
// ======================================================================
StatusCode initialize() override
{
StatusCode sc = GaudiTool::initialize() ;
const StatusCode sc = GaudiTool::initialize() ;
if ( sc.isFailure() ) { return sc ; } // RETURN
// acquire the DictTool
m_source = tool<IParticleDictTool>(m_sourcename, this);
if(m_source == NULL) return Error("Unable to find the source DictTool " + m_sourcename , sc ) ;
if ( !m_source )
{
return Error("Unable to find the source DictTool " + m_sourcename );
}
if(!m_transform.Init(m_options,debug().stream(),msgLevel(MSG::DEBUG))){
Error("Initialization of Transform failed.",StatusCode::FAILURE);
// initialise the transform
if ( !m_transform.Init(m_options,debug().stream(),msgLevel(MSG::DEBUG)) )
{
return Error("Initialization of Transform failed.");
}
debug() << "Successfully initialized DictTransform" << endmsg;
@@ -75,14 +81,14 @@ namespace LoKi
// ======================================================================
StatusCode fill ( const LHCb::Particle* p ,
IParticleDictTool::DICT& dict ) const override {
/// request the dictionary s from the source DictTool
IParticleDictTool::DICT& dict ) const override
{
// request the dictionary s from the source DictTool
IParticleDictTool::DICT sourceDict;
m_source->fill(p,sourceDict).ignore();
/// apply the transformation to the dictionary
/// this is delegated to the Transform
// apply the transformation to the dictionary
// this is delegated to the Transform
m_transform(sourceDict,dict);
return StatusCode::SUCCESS;
@@ -90,15 +96,11 @@ namespace LoKi
// ======================================================================
virtual ~DictTransform( ){}; ///< Destructor
// ======================================================================
protected:
IParticleDictTool* m_source;
IParticleDictTool* m_source = nullptr;
std::string m_sourcename;
/// Templated worker class to encapsulate the transformation algorithm
Transform m_transform;
std::map<std::string,std::string> m_options;
Loading