Skip to content

Commit

Permalink
refs #9048 Trying to fix Coverity noise in ConvToMDSelector
Browse files Browse the repository at this point in the history
at https://scan6.coverity.com:8443/reports.htm#v29240/p10083/fileInstanceId=11025316&defectInstanceId=3876567&mergedDefectId=528357

do not understand what Coverity is complaining about -- default occurs if neither EventWS nor Matrix2D ws is provided (e.g. Table) Rewritten in a way which hopefully is more clear for Coverity
  • Loading branch information
abuts committed Feb 20, 2014
1 parent efb7a6a commit a56df79
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions Code/Mantid/Framework/MDEvents/src/ConvToMDSelector.cpp
Expand Up @@ -21,30 +21,35 @@ boost::shared_ptr<ConvToMDBase> ConvToMDSelector::convSelector(API::MatrixWorksp
boost::shared_ptr<ConvToMDBase> currentSolver)const
{
// identify what kind of workspace we expect to process
wsType inputWSType(Undefined);
if(boost::dynamic_pointer_cast<DataObjects::EventWorkspace>(inputWS)) inputWSType = EventWS;
if(boost::dynamic_pointer_cast<DataObjects::Workspace2D>(inputWS)) inputWSType = Matrix2DWS;
wsType inputWSType = Undefined;
if(boost::dynamic_pointer_cast<DataObjects::EventWorkspace>(inputWS))
inputWSType = EventWS;
if(boost::dynamic_pointer_cast<DataObjects::Workspace2D>(inputWS))
inputWSType = Matrix2DWS;

if(inputWSType == Undefined)
throw(std::invalid_argument("ConvToMDEventsSelector::got a workspace which is neither matrix nor event workspace; Can not deal with it"));

// identify what converter (if any) is currently initialized;
wsType wsConvType(Undefined);
wsType existingWsConvType(Undefined);
ConvToMDBase *pSolver = currentSolver.get();
if(pSolver)
{
if(dynamic_cast<ConvToMDEventsWS *>(pSolver)) wsConvType = EventWS;
if(dynamic_cast<ConvToMDHistoWS *>(pSolver)) wsConvType = Matrix2DWS;
if(dynamic_cast<ConvToMDEventsWS *>(pSolver)) existingWsConvType = EventWS;
if(dynamic_cast<ConvToMDHistoWS *>(pSolver)) existingWsConvType = Matrix2DWS;
}

// select a converter, which corresponds to the workspace type
if((wsConvType==Undefined)||(wsConvType!=inputWSType))
if((existingWsConvType==Undefined)||(existingWsConvType!=inputWSType))
{
switch(inputWSType)
{
case(EventWS): return boost::shared_ptr<ConvToMDBase>(new ConvToMDEventsWS());
case(Matrix2DWS): return boost::shared_ptr<ConvToMDBase>(new ConvToMDHistoWS());
default: throw(std::logic_error("ConvToMDEventsSelector: requested converter for unknown ws type"));
case(EventWS):
return boost::shared_ptr<ConvToMDBase>(new ConvToMDEventsWS());
case(Matrix2DWS):
return boost::shared_ptr<ConvToMDBase>(new ConvToMDHistoWS());
default:
throw(std::logic_error("ConvToMDEventsSelector: requested converter for unknown ws type"));
}

}
Expand Down

0 comments on commit a56df79

Please sign in to comment.