From: Anthony Geay Date: Fri, 16 Oct 2015 16:02:03 +0000 (+0200) Subject: Deal with outputports with type different from int/double in evalyfx. X-Git-Tag: V8_0_pre~12 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=efd22dfaa4234b31e9c1b487f8b4164f9061a258;p=modules%2Fyacs.git Deal with outputports with type different from int/double in evalyfx. --- diff --git a/src/evalyfx/YACSEvalPort.cxx b/src/evalyfx/YACSEvalPort.cxx index 8cc95f235..190fa1ef2 100644 --- a/src/evalyfx/YACSEvalPort.cxx +++ b/src/evalyfx/YACSEvalPort.cxx @@ -81,6 +81,14 @@ bool YACSEvalPort::IsInputPortPublishable(const YACS::ENGINE::InputPort *port) return true; } +bool YACSEvalPort::IsOutputPortPublishable(const YACS::ENGINE::OutputPort *port) +{ + YACS::ENGINE::TypeCode *tc(port->edGetType()); + if(!tc) + throw YACS::Exception("YACSEvalPort::IsOutputPortPublishable : null type code !"); + return tc->kind()==YACS::ENGINE::Double || tc->kind()==YACS::ENGINE::Int; +} + std::string YACSEvalPort::GetTypeOfData(const YACS::ENGINE::DataPort *port) { YACS::ENGINE::TypeCode *tc(port->edGetType()); diff --git a/src/evalyfx/YACSEvalPort.hxx b/src/evalyfx/YACSEvalPort.hxx index 20985f0bb..eeb4ecf99 100644 --- a/src/evalyfx/YACSEvalPort.hxx +++ b/src/evalyfx/YACSEvalPort.hxx @@ -86,6 +86,7 @@ public: YACSEVALYFX_EXPORT virtual ~YACSEvalPort() { } public: YACSEVALYFX_EXPORT static bool IsInputPortPublishable(const YACS::ENGINE::InputPort *port); + YACSEVALYFX_EXPORT static bool IsOutputPortPublishable(const YACS::ENGINE::OutputPort *port); protected: YACSEVALYFX_EXPORT static std::string GetTypeOfData(const YACS::ENGINE::DataPort *port); }; diff --git a/src/evalyfx/YACSEvalYFXPattern.cxx b/src/evalyfx/YACSEvalYFXPattern.cxx index 19064f8c9..1feacd39c 100644 --- a/src/evalyfx/YACSEvalYFXPattern.cxx +++ b/src/evalyfx/YACSEvalYFXPattern.cxx @@ -548,17 +548,20 @@ void YACSEvalYFXRunOnlyPattern::buildOutputPorts() for(std::list< YACS::ENGINE::OutputPort *>::const_iterator it=allOutputPorts.begin();it!=allOutputPorts.end();it++) { YACS::ENGINE::OutputPort *elt(*it); - if(!elt) - throw YACS::Exception("YACSEvalYFXRunOnlyPattern::buildOutputPorts : presence of null output !"); - std::string outpName(elt->getName()); - if(outpName.empty()) - throw YACS::Exception("YACSEvalYFXRunOnlyPattern::buildOutputPorts : an output has empty name ! Should not !"); - if(std::find(allNames.begin(),allNames.end(),outpName)!=allNames.end()) + if(YACSEvalPort::IsOutputPortPublishable(elt)) { - std::ostringstream oss; oss << "YACSEvalYFXRunOnlyPattern::buildOutputPorts : output name \"" << outpName << "\" appears more than once !"; - throw YACS::Exception(oss.str()); + if(!elt) + throw YACS::Exception("YACSEvalYFXRunOnlyPattern::buildOutputPorts : presence of null output !"); + std::string outpName(elt->getName()); + if(outpName.empty()) + throw YACS::Exception("YACSEvalYFXRunOnlyPattern::buildOutputPorts : an output has empty name ! Should not !"); + if(std::find(allNames.begin(),allNames.end(),outpName)!=allNames.end()) + { + std::ostringstream oss; oss << "YACSEvalYFXRunOnlyPattern::buildOutputPorts : output name \"" << outpName << "\" appears more than once !"; + throw YACS::Exception(oss.str()); + } + _outputs.push_back(YACSEvalOutputPort(*it)); } - _outputs.push_back(YACSEvalOutputPort(*it)); } }