From efd22dfaa4234b31e9c1b487f8b4164f9061a258 Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Fri, 16 Oct 2015 18:02:03 +0200 Subject: [PATCH] Deal with outputports with type different from int/double in evalyfx. --- src/evalyfx/YACSEvalPort.cxx | 8 ++++++++ src/evalyfx/YACSEvalPort.hxx | 1 + src/evalyfx/YACSEvalYFXPattern.cxx | 21 ++++++++++++--------- 3 files changed, 21 insertions(+), 9 deletions(-) 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)); } } -- 2.39.2