* \param node : node that has emitted the event
* \return the event to notify to bloc's father
*/
-YACS::Event Bloc::updateStateOnFailedEventFrom(Node *node, const Executor *execInst)
+YACS::Event Bloc::updateStateOnFailedEventFrom(Node *node)
{
node->exForwardFailed();
if(areAllSubNodesFinished())
void checkNoCyclePassingThrough(Node *node) throw(Exception);
std::vector< std::pair<OutGate *, InGate *> > getSetOfInternalCFLinks() const;
YACS::Event updateStateOnFinishedEventFrom(Node *node);
- YACS::Event updateStateOnFailedEventFrom(Node *node, const Executor *execInst);
+ YACS::Event updateStateOnFailedEventFrom(Node *node);
void initComputation() const;
void performCFComputationsOnlyOneLevel(LinkInfo& info) const;
void performCFComputations(LinkInfo& info) const;
* Calls ComposedNode::updateStateFrom to update state from task to root node
*/
void ComposedNode::notifyFrom(const Task *sender, //* I : task emitting event
- YACS::Event event, //* I : event emitted
- const Executor *execInst
+ YACS::Event event //* I : event emitted
)
{
DEBTRACE("ComposedNode::notifyFrom " << event);
ComposedNode *curLevelNode=taskTyped->_father;
if(!curLevelNode)//Specific case of loop when 0 turn is specified without any enclosing bloc.
return ;
- curEvent=curLevelNode->updateStateFrom(lminus1LevelNode,curEvent,execInst);
+ curEvent=curLevelNode->updateStateFrom(lminus1LevelNode,curEvent);
while(curEvent!=YACS::NOEVENT && curLevelNode!=this)
{
lminus1LevelNode=curLevelNode;
curLevelNode=curLevelNode->_father;
- curEvent=curLevelNode->updateStateFrom(lminus1LevelNode,curEvent,execInst);
+ curEvent=curLevelNode->updateStateFrom(lminus1LevelNode,curEvent);
}
}
* Called by ComposedNode::notifyFrom
*/
YACS::Event ComposedNode::updateStateFrom(Node *node, //* I : node emitting event
- YACS::Event event, //* I : event emitted
- const Executor *execInst
+ YACS::Event event //* I : event emitted
)
{
DEBTRACE("updateStateFrom: " << node->getName() << " " << event);
return updateStateOnFinishedEventFrom(node);
break;
case YACS::ABORT:
- return updateStateOnFailedEventFrom(node,execInst);
+ return updateStateOnFailedEventFrom(node);
break;
default:
return YACS::NOEVENT;//TODO unexpected type of event
}
//! Method used to notify the node that a child node has failed
-YACS::Event ComposedNode::updateStateOnFailedEventFrom(Node *node, const Executor *execInst)
+YACS::Event ComposedNode::updateStateOnFailedEventFrom(Node *node)
{
setState(YACS::FAILED);
return YACS::ABORT;
DeploymentTree checkDeploymentTree(bool deep) const throw(Exception);
std::vector<Task *> getNextTasks(bool& isMore);
virtual bool isPlacementPredictableB4Run() const = 0;
- void notifyFrom(const Task *sender, YACS::Event event, const Executor *execInst);
+ void notifyFrom(const Task *sender, YACS::Event event);
bool edAddLink(OutPort *start, InPort *end) throw(Exception);
virtual bool edAddDFLink(OutPort *start, InPort *end) throw(Exception);
//Node* DISOWNnode is a SWIG notation to indicate that the ownership of the node is transfered to C++
static bool splitNamesBySep(const std::string& globalName, const char separator[],
std::string& firstPart, std::string& lastPart, bool priority) throw(Exception);
virtual Node *getChildByShortName(const std::string& name) const throw(Exception) = 0;
- YACS::Event updateStateFrom(Node *node, YACS::Event event, const Executor *execInst);//update the state of this. Precondition : node->_father == this
+ YACS::Event updateStateFrom(Node *node, YACS::Event event);//update the state of this. Precondition : node->_father == this
virtual YACS::Event updateStateOnStartEventFrom(Node *node);//transition 3 doc P.R
virtual YACS::Event updateStateOnFinishedEventFrom(Node *node) = 0;//transition 9 doc P.R.
- virtual YACS::Event updateStateOnFailedEventFrom(Node *node, const Executor *execInst);//transition 9 doc P.R.
+ virtual YACS::Event updateStateOnFailedEventFrom(Node *node);//transition 9 doc P.R.
virtual void checkLinkPossibility(OutPort *start, const std::list<ComposedNode *>& pointsOfViewStart,
InPort *end, const std::list<ComposedNode *>& pointsOfViewEnd) throw(Exception);
virtual void buildDelegateOf(InPort * & port, OutPort *initialStart, const std::list<ComposedNode *>& pointsOfView);
* \param node : the child node that has failed
* \return the state change
*/
-YACS::Event DynParaLoop::updateStateOnFailedEventFrom(Node *node, const Executor *execInst)
+YACS::Event DynParaLoop::updateStateOnFailedEventFrom(Node *node)
{
DEBTRACE("DynParaLoop::updateStateOnFailedEventFrom " << node->getName());
setState(YACS::FAILED);
TypeOfNode getIdentityOfNotifyerNode(const Node *node, unsigned& id);
InputPort *getDynInputPortByAbsName(int branchNb, const std::string& name, bool initNodeAdmitted);
virtual void forwardExecStateToOriginalBody(Node *execNode);
- virtual YACS::Event updateStateOnFailedEventFrom(Node *node, const Executor *execInst);
+ virtual YACS::Event updateStateOnFailedEventFrom(Node *node);
std::vector<Node *> cloneAndPlaceNodesCoherently(const std::vector<Node *> & origNodes);
Node * checkConsistencyAndSetNode(Node* &nodeToReplace, Node* DISOWNnode);
Node * removeNode(Node* &nodeToRemove);
DEBTRACE("Executor::saveState() in " << xmlFile);
bool result = false;
try {
+ YACS::BASES::AutoLocker<YACS::BASES::Mutex> alck(&_mutexForSchedulerUpdate);
YACS::ENGINE::VisitorSaveState vst(_root);
vst.openFileDump(xmlFile.c_str());
_root->accept(&vst);
traceExec(task, "state:TOLOAD", ComputePlacement(task));
{//Critical section
YACS::BASES::AutoLocker<YACS::BASES::Mutex> alck(&_mutexForSchedulerUpdate);
- _mainSched->notifyFrom(task,YACS::START,execInst);
+ _mainSched->notifyFrom(task,YACS::START);
}//End of critical section
try
{
{//Critical section
YACS::BASES::AutoLocker<YACS::BASES::Mutex> alck(&_mutexForSchedulerUpdate);
task->aborted();
- _mainSched->notifyFrom(task,YACS::ABORT,execInst);
+ _mainSched->notifyFrom(task,YACS::ABORT);
traceExec(task, "state:"+Node::getStateName(task->getState()), ComputePlacement(task));
}//End of critical section
}
{//Critical section
YACS::BASES::AutoLocker<YACS::BASES::Mutex> alck(&_mutexForSchedulerUpdate);
task->aborted();
- _mainSched->notifyFrom(task,YACS::ABORT,execInst);
+ _mainSched->notifyFrom(task,YACS::ABORT);
traceExec(task, "state:"+Node::getStateName(task->getState()), ComputePlacement(task));
}//End of critical section
}
{//Critical section
YACS::BASES::AutoLocker<YACS::BASES::Mutex> alck(&_mutexForSchedulerUpdate);
(*iter)->aborted();
- _mainSched->notifyFrom(*iter,YACS::ABORT,this);
+ _mainSched->notifyFrom(*iter,YACS::ABORT);
}//End of critical section
}
catch(...)
{//Critical section
YACS::BASES::AutoLocker<YACS::BASES::Mutex> alck(&_mutexForSchedulerUpdate);
(*iter)->aborted();
- _mainSched->notifyFrom(*iter,YACS::ABORT,this);
+ _mainSched->notifyFrom(*iter,YACS::ABORT);
}//End of critical section
}
if((*iter)->getState() == YACS::ERROR)
{//Critical section
YACS::BASES::AutoLocker<YACS::BASES::Mutex> alck(&_mutexForSchedulerUpdate);
t->aborted();
- _mainSched->notifyFrom(t,YACS::ABORT,this);
+ _mainSched->notifyFrom(t,YACS::ABORT);
}//End of critical section
traceExec(t, "state:"+Node::getStateName(t->getState()),ComputePlacement(*iter));
}
task->aborted();
}
execInst->traceExec(task, "state:"+Node::getStateName(task->getState()),placement);
- sched->notifyFrom(task,ev,execInst);
+ sched->notifyFrom(task,ev);
}
catch(Exception& ex)
{
}
}
+ForEachLoopPassedData::ForEachLoopPassedData(const ForEachLoopPassedData& copy)
+: _passedIds(copy._passedIds),
+ _passedOutputs(copy._passedOutputs),
+ _nameOfOutputs(copy._nameOfOutputs),
+ _flagsIds(copy._flagsIds)
+{
+}
+
ForEachLoopPassedData::~ForEachLoopPassedData()
{
for(std::vector<SequenceAny *>::iterator it=_passedOutputs.begin();it!=_passedOutputs.end();it++)
return YACS::NOEVENT;
}
-YACS::Event ForEachLoop::updateStateOnFailedEventFrom(Node *node, const Executor *execInst)
+YACS::Event ForEachLoop::updateStateOnFailedEventFrom(Node *node)
{
unsigned int id;
DynParaLoop::TypeOfNode ton(getIdentityOfNotifyerNode(node,id));
- if(ton!=WORK_NODE || !execInst->getKeepGoingProperty())
- return DynParaLoop::updateStateOnFailedEventFrom(node,execInst);
+ // TODO: deal with keepgoing
+ // if(ton!=WORK_NODE || !execInst->getKeepGoingProperty())
+ if(ton!=WORK_NODE )
+ return DynParaLoop::updateStateOnFailedEventFrom(node);
else
{
_failedCounter++;
return std::vector<unsigned int>();
if(_execOutGoingPorts.empty())
return std::vector<unsigned int>();
- std::size_t sz(_execVals.size()); outputs.resize(sz); nameOfOutputs.resize(sz);
+ std::size_t sz(_execVals.size());
+ outputs.resize(sz);
+ nameOfOutputs.resize(sz);
const std::vector<AnyInputPort *>& ports(_execOutGoingPorts[0]);
for(std::size_t i=0;i<sz;i++)
{
_passedData=new ForEachLoopPassedData(passedIds,passedOutputs,nameOfOutputs);
}
+/*!
+ * This method is used to obtain the values already processed by the ForEachLoop.
+ * A new ForEachLoopPassedData object is returned. You have to delete it.
+ */
+ForEachLoopPassedData* ForEachLoop::getProcessedData()const
+{
+ std::vector<SequenceAny *> outputs;
+ std::vector<std::string> nameOfOutputs;
+ if(_execVals.empty() || _execOutGoingPorts.empty())
+ return new ForEachLoopPassedData(std::vector<unsigned int>(), outputs, nameOfOutputs);
+ std::size_t sz(_execVals.size());
+ outputs.resize(sz);
+ nameOfOutputs.resize(sz);
+ const std::vector<AnyInputPort *>& ports(_execOutGoingPorts[0]);
+ for(std::size_t i=0;i<sz;i++)
+ {
+ outputs[i]=_execVals[i]->removeUnsetItemsFromThis();
+ nameOfOutputs[i]=ports[i]->getName();
+ }
+ return new ForEachLoopPassedData(_execVals[0]->getSetItems(), outputs, nameOfOutputs);
+}
+
+void ForEachLoop::setProcessedData(ForEachLoopPassedData* processedData)
+{
+ if(_passedData)
+ delete _passedData;
+ _passedData = processedData;
+}
{
public:
ForEachLoopPassedData(const std::vector<unsigned int>& passedIds, const std::vector<SequenceAny *>& passedOutputs, const std::vector<std::string>& nameOfOutputs);
+ ForEachLoopPassedData(const ForEachLoopPassedData& copy);
~ForEachLoopPassedData();
void init();
void checkCompatibilyWithNb(int nbOfElts) const;
int toAbsIdNot(int localId) const;
int getNumberOfElementsToDo() const;
void assignAlreadyDone(const std::vector<SequenceAny *>& execVals) const;
+ const std::vector<unsigned int>& getIds()const {return _passedIds;}
+ const std::vector<SequenceAny *>& getOutputs()const {return _passedOutputs;}
+ const std::vector<std::string>& getOutputNames()const {return _nameOfOutputs;}
+ //const std::vector<bool>& getFlags()const {return _flagsIds;}
private:
std::vector<unsigned int> _passedIds;
std::vector<SequenceAny *> _passedOutputs;
int getCurrentIndex() const { return _currentIndex; }
int getNbOfElementsToBeProcessed() const;
#ifndef SWIG
+ ForEachLoopPassedData* getProcessedData()const;
+ void setProcessedData(ForEachLoopPassedData* processedData);
std::vector<unsigned int> getPassedResults(Executor *execut, std::vector<SequenceAny *>& outputs, std::vector<std::string>& nameOfOutputs) const;
void assignPassedResults(const std::vector<unsigned int>& passedIds, const std::vector<SequenceAny *>& passedOutputs, const std::vector<std::string>& nameOfOutputs);
#endif
YACS::Event updateStateForInitNodeOnFinishedEventFrom(Node *node, unsigned int id);
YACS::Event updateStateForWorkNodeOnFinishedEventFrom(Node *node, unsigned int id, bool isNormalFinish);
YACS::Event updateStateForFinalizeNodeOnFinishedEventFrom(Node *node, unsigned int id);
- YACS::Event updateStateOnFailedEventFrom(Node *node, const Executor *execInst);
+ YACS::Event updateStateOnFailedEventFrom(Node *node);
void buildDelegateOf(std::pair<OutPort *, OutPort *>& port, InPort *finalTarget, const std::list<ComposedNode *>& pointsOfView);
void getDelegateOf(std::pair<OutPort *, OutPort *>& port, InPort *finalTarget, const std::list<ComposedNode *>& pointsOfView) throw(Exception);
void releaseDelegateOf(OutPort *portDwn, OutPort *portUp, InPort *finalTarget, const std::list<ComposedNode *>& pointsOfView) throw(Exception);
* \param node : the child node that has failed
* \return the state change
*/
-YACS::Event OptimizerLoop::updateStateOnFailedEventFrom(Node *node, const Executor *execInst)
+YACS::Event OptimizerLoop::updateStateOnFailedEventFrom(Node *node)
{
DEBTRACE("OptimizerLoop::updateStateOnFailedEventFrom " << node->getName());
_alg->setError(string("Error during the execution of YACS node ") + node->getName() +
_alg->finishProxy();
_myPool.destroyAll();
DEBTRACE("OptimizerLoop::updateStateOnFailedEventFrom: returned from error notification.");
- return DynParaLoop::updateStateOnFailedEventFrom(node,execInst);
+ return DynParaLoop::updateStateOnFailedEventFrom(node);
}
void OptimizerLoop::checkNoCyclePassingThrough(Node *node) throw(YACS::Exception)
YACS::Event finalize();
protected:
- virtual YACS::Event updateStateOnFailedEventFrom(Node *node, const Executor *execInst);
+ virtual YACS::Event updateStateOnFailedEventFrom(Node *node);
void buildDelegateOf(InPort * & port, OutPort *initialStart, const std::list<ComposedNode *>& pointsOfView);
void buildDelegateOf(std::pair<OutPort *, OutPort *>& port, InPort *finalTarget, const std::list<ComposedNode *>& pointsOfView);
void checkControlDependancy(OutPort *start, InPort *end, bool cross,
namespace ENGINE
{
class Task;
- class Executor;
class Scheduler
{
virtual std::string getTaskName(Task *task) const = 0;
virtual std::vector<Task *> getNextTasks(bool& isMore) = 0;
virtual void selectRunnableTasks(std::vector<Task *>& tasks) = 0;
- virtual void notifyFrom(const Task *sender, YACS::Event event, const Executor *execInst) = 0;
+ virtual void notifyFrom(const Task *sender, YACS::Event event) = 0;
//Placement methods
virtual DeploymentTree getDeploymentTree() const = 0;
virtual bool isPlacementPredictableB4Run() const = 0;
void VisitorSaveState::visitStudyOutNode(DataNode *node)
{
visitElementaryNode(node);
-}
+}
\ No newline at end of file
SalomeOptimizerLoop.hxx
DistributedPythonNode.hxx
PyOptimizerAlg.hxx
+ VisitorSalomeSaveState.hxx
)
# --- sources ---
PyStdout.cxx
SalomeOptimizerLoop.cxx
PyOptimizerAlg.cxx
+ VisitorSalomeSaveState.cxx
)
# --- rules ---
--- /dev/null
+// Copyright (C) 2006-2015 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "VisitorSalomeSaveState.hxx"
+#include "TypeConversions.hxx"
+#include "ForEachLoop.hxx"
+#include "Proc.hxx"
+#include "Executor.hxx"
+#include "AutoLocker.hxx"
+
+#include "YacsTrace.hxx"
+
+using namespace YACS::ENGINE;
+
+VisitorSalomeSaveState::VisitorSalomeSaveState(ComposedNode *root)
+:VisitorSaveState(root)
+{
+}
+
+VisitorSalomeSaveState::~VisitorSalomeSaveState()
+{
+}
+
+void VisitorSalomeSaveState::visitForEachLoop(ForEachLoop *node)
+{
+ node->ComposedNode::accept(this);
+ if (!_out) throw Exception("No file open for dump state");
+ std::string name = _root->getName();
+ if (static_cast<ComposedNode*>(node) != _root) name = _root->getChildName(node);
+ DEBTRACE("VisitorSaveState::visitForEachLoop ------ " << name);
+ _out << " <node type='forEachLoop'>" << std::endl;
+ _out << " <name>" << name << "</name>" << std::endl;
+ _out << " <state>" << _nodeStateName[node->getState()] << "</state>" << std::endl;
+// VisitorSaveState::visitForEachLoop(node);
+ StatesForNode state = node->getState();
+ if(YACS::LOADED == state or
+ YACS::ACTIVATED == state or
+ YACS::SUSPENDED == state or
+ YACS::EXECFAILED == state or
+ YACS::PAUSE == state or
+ YACS::TORECONNECT == state or
+ YACS::INTERNALERR == state or
+ YACS::FAILED == state or
+ YACS::ERROR == state)
+ {
+ ForEachLoopPassedData* processedData = node->getProcessedData();
+ if(processedData)
+ {
+ const std::vector<unsigned int>& processedIndexes = processedData->getIds();
+ std::vector<SequenceAny *>::const_iterator it_outputs;
+ std::vector<std::string>::const_iterator it_names;
+
+ for(it_outputs = processedData->getOutputs().begin(), it_names = processedData->getOutputNames().begin();
+ it_names != processedData->getOutputNames().end();
+ it_outputs++, it_names++)
+ {
+ _out << " <loopOutputPort>" << std::endl;
+ _out << " <name>" << (*it_names) << "</name>" << std::endl;
+ for(unsigned int i = 0; i < (*it_outputs)->size(); i++)
+ {
+ AnyPtr value = (*(*it_outputs))[i];
+ _out << " <sample><index>" << processedIndexes[i]<< "</index>";
+ if(value)
+ _out << convertNeutralXml(value->getType(), value);
+ else
+ _out << "<value>None</value>";
+ _out << " </sample>" << std::endl;
+ }
+ _out << " </loopOutputPort>" << std::endl;
+ }
+
+ delete processedData;
+ processedData = NULL;
+ }
+ }
+ _out << " </node>" << std::endl;
+}
+
+
+SchemaSaveState::SchemaSaveState(Proc* proc, Executor* exec)
+: _p(proc),
+ _exec(exec)
+{
+ YASSERT(_p);
+ YASSERT(_exec);
+}
+
+SchemaSaveState::~SchemaSaveState()
+{
+}
+
+void SchemaSaveState::save(std::string xmlSchemaFile)
+{
+ YACS::BASES::AutoLocker<YACS::BASES::Mutex> alck(&(_exec->getTheMutexForSchedulerUpdate()));
+ VisitorSalomeSaveState vss(_p);
+ vss.openFileDump(xmlSchemaFile);
+ _p->accept(&vss);
+ vss.closeFileDump();
+}
--- /dev/null
+// Copyright (C) 2006-2015 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef VISITORSALOMESAVESTATE_HXX
+#define VISITORSALOMESAVESTATE_HXX
+
+#include "VisitorSaveState.hxx"
+#include "YACSRuntimeSALOMEExport.hxx"
+
+namespace YACS
+{
+ namespace ENGINE
+ {
+ class Executor;
+ class YACSRUNTIMESALOME_EXPORT VisitorSalomeSaveState : public VisitorSaveState
+ {
+ public:
+ VisitorSalomeSaveState(ComposedNode *root);
+ virtual ~VisitorSalomeSaveState();
+ virtual void visitForEachLoop(ForEachLoop *node);
+ };
+
+ class YACSLIBENGINE_EXPORT SchemaSaveState
+ {
+ public:
+ SchemaSaveState(Proc* proc, Executor* exec);
+ virtual ~SchemaSaveState();
+ virtual void save(std::string xmlSchemaFile);
+ private:
+ Proc* _p;
+ Executor* _exec;
+ };
+ }
+}
+#endif // VISITORSALOMESAVESTATE_HXX
${PROJECT_SOURCE_DIR}/src/runtime/CORBAPorts.hxx
${PROJECT_SOURCE_DIR}/src/runtime/TypeConversions.hxx
${PROJECT_SOURCE_DIR}/src/runtime/SalomeOptimizerLoop.hxx
+ ${PROJECT_SOURCE_DIR}/src/runtime/VisitorSalomeSaveState.hxx
)
SWIG_ADD_MODULE(SALOMERuntime python SALOMERuntime.i)
ADD_DEPENDENCIES(_SALOMERuntime
#include "TypeConversions.hxx"
#include "TypeCode.hxx"
#include "VisitorSaveSalomeSchema.hxx"
+#include "VisitorSalomeSaveState.hxx"
#include "SalomeOptimizerLoop.hxx"
#include "DistributedPythonNode.hxx"
#include "PyOptimizerAlg.hxx"
#include "PyStdout.hxx"
+#include "ExecutorSwig.hxx"
#include <sstream>
%}
%include "SalomeOptimizerLoop.hxx"
%include "DistributedPythonNode.hxx"
+namespace YACS
+{
+ namespace ENGINE
+ {
+ class SchemaSaveState
+ {
+ public:
+ SchemaSaveState(Proc* proc, Executor* exec);
+ virtual void save(std::string xmlSchemaFile);
+ };
+ }
+}
+
+
%extend YACS::ENGINE::OutputPresetPort
{
void setDataPy(PyObject *ob)
#include "Runtime.hxx"
#include "InputPort.hxx"
#include "ElementaryNode.hxx"
+#include "ForEachLoop.hxx"
+#include "Any.hxx"
#include <iostream>
#include <string>
else if (element == "nbdone") parser = new attrParser();
else if (element == "condition") parser = new attrParser();
else if (element == "outputPort") parser = new outputParser();
+ else if (element == "loopOutputPort") parser = new loopPortParser();
else
{
_what = "expected name, state or inputPort, got <" + element + ">";
_data = _data + data;
}
+// ----------------------------------------------------------------------------
+
+void loopPortParser::init(const xmlChar** p, xmlParserBase* father)
+{
+ DEBTRACE("loopPortParser::init()");
+ _state = XMLINPORT;
+ _father = father;
+ _stackState.push(_state);
+ if (p) getAttributes(p);
+}
+
+void loopPortParser::onStart(const XML_Char* elem, const xmlChar** p)
+{
+ DEBTRACE("loopPortParser::onStart" << elem);
+ string element(elem);
+ stateParser *parser = 0;
+ if (element == "name") parser = new attrParser();
+ else if (element == "sample") parser = new sampleParser();
+ else
+ {
+ _what = "expected name or sample, got <" + element + ">";
+ _state = XMLFATALERROR;
+ stopParse(_what);
+ }
+ if (parser)
+ {
+ _stackParser.push(parser);
+ XML_SetUserData(_xmlParser, parser);
+ parser->init(p, this);
+ }
+}
+
+void loopPortParser::onEnd(const XML_Char* name)
+{
+ string portName = _mapAttrib["name"];
+ string nodeName = _father->getAttribute("name");
+ string nodeType = _father->getAttribute("type");
+ Node *node = _p->getChildByName(nodeName);
+ if (nodeType != "forEachLoop")
+ {
+ _what = "loopOutputPort attribute is not valid for node <" + nodeName + ">";
+ _state = XMLFATALERROR;
+ stopParse(_what);
+ }
+}
+
+void loopPortParser::charData(std::string data)
+{
+}
+
+// ----------------------------------------------------------------------------
+
+void sampleParser::init(const xmlChar** p, xmlParserBase* father)
+{
+ DEBTRACE("sampleParser::init()");
+ _state = XMLINPORT;
+ _father = father;
+ _stackState.push(_state);
+ if (p) getAttributes(p);
+}
+void sampleParser::onStart(const XML_Char* elem, const xmlChar** p)
+{
+ DEBTRACE("sampleParser::onStart" << elem);
+ string element(elem);
+ stateParser *parser = 0;
+ if (element == "index") parser = new attrParser();
+ else if (element == "value") parser = new valueParser();
+ else
+ {
+ _what = "expected index or value, got <" + element + ">";
+ _state = XMLFATALERROR;
+ stopParse(_what);
+ }
+ if (parser)
+ {
+ _stackParser.push(parser);
+ XML_SetUserData(_xmlParser, parser);
+ parser->init(p, this);
+ }
+}
+
+void sampleParser::onEnd(const XML_Char* name)
+{
+ if (_mapAttrib.find("index") == _mapAttrib.end())
+ {
+ _what = "no attribute index in sample ";
+ _state = XMLFATALERROR;
+ stopParse(_what);
+ }
+ int index = atoi(_mapAttrib["index"].c_str());
+ Any * value;
+ value = xmlToAny();
+}
+
+void sampleParser::charData(std::string data)
+{
+}
+
+Any* sampleParser::xmlToAny() throw(ConversionException)
+{
+ xmlDocPtr doc;
+ xmlNodePtr cur;
+ YACS::ENGINE::Any *ob=NULL;
+ {
+ doc = xmlParseMemory(_data.c_str(), _data.length());
+ if (doc == NULL )
+ {
+ stringstream msg;
+ msg << "Problem in conversion: XML Document not parsed successfully ";
+ msg << " (" << __FILE__ << ":" << __LINE__ << ")";
+ throw ConversionException(msg.str());
+ }
+ cur = xmlDocGetRootElement(doc);
+ if (cur == NULL)
+ {
+ xmlFreeDoc(doc);
+ stringstream msg;
+ msg << "Problem in conversion: empty XML Document";
+ msg << " (" << __FILE__ << ":" << __LINE__ << ")";
+ throw ConversionException(msg.str());
+ }
+ while (cur != NULL)
+ {
+ if ((!xmlStrcmp(cur->name, (const xmlChar *)"value")))
+ {
+ ob=convertXmlNeutral(edGetType(),doc,cur);
+ break;
+ }
+ cur = cur->next;
+ }
+ xmlFreeDoc(doc);
+ if(ob==NULL)
+ {
+ stringstream msg;
+ msg << "Problem in conversion: incorrect XML value";
+ msg << " (" << __FILE__ << ":" << __LINE__ << ")";
+ throw ConversionException(msg.str());
+ }
+ }
+ return ob;
+}
// ----------------------------------------------------------------------------
#include "YACSloaderExport.hxx"
#include "xmlParserBase.hxx"
+#include "InputPort.hxx"
#include "define.hxx"
#include "Exception.hxx"
+#include <vector>
namespace YACS
{
{
class Proc;
class Runtime;
+ class SequenceAny;
+ class Any;
//! Load state from a file into a Proc
/*!
virtual void charData(std::string data);
};
+ class YACSLOADER_EXPORT loopPortParser: public stateParser
+ {
+ public:
+ virtual void init(const xmlChar** p, xmlParserBase* father=0);
+ virtual void onStart (const XML_Char* elem, const xmlChar** p);
+ virtual void onEnd (const XML_Char* name);
+ virtual void charData(std::string data);
+ std::vector<unsigned int> _ids;
+ std::vector<SequenceAny *> _outputValues;
+ std::vector<std::string> _outputNames;
+ };
+
+ class YACSLOADER_EXPORT sampleParser: public stateParser
+ {
+ public:
+ virtual void init(const xmlChar** p, xmlParserBase* father=0);
+ virtual void onStart (const XML_Char* elem, const xmlChar** p);
+ virtual void onEnd (const XML_Char* name);
+ virtual void charData(std::string data);
+ protected:
+ Any* xmlToAny()throw(ConversionException);
+ };
+
}
}
#endif
#include "Exception.hxx"
#include "Executor.hxx"
#include "parsers.hxx"
-#include "VisitorSaveState.hxx"
+#include "VisitorSalomeSaveState.hxx"
#include "VisitorSaveSalomeSchema.hxx"
#include "LoadState.hxx"
#include "Dispatcher.hxx"
bool isFinalDump = (strlen(myArgs.finalDump) != 0);
if (isFinalDump)
{
- YACS::ENGINE::VisitorSaveState vst(p);
+ YACS::ENGINE::VisitorSalomeSaveState vst(p);
vst.openFileDump(myArgs.finalDump);
p->accept(&vst);
vst.closeFileDump();
#endif
string cmd = "touch " + st->lockFile;
system(cmd.c_str());
- YACS::ENGINE::VisitorSaveState vst(p);
+ YACS::ENGINE::VisitorSalomeSaveState vst(p);
vst.openFileDump(st->dumpFile);
p->accept(&vst);
vst.closeFileDump();
bool isFinalDump = (strlen(myArgs.finalDump) != 0);
if (isFinalDump)
{
- YACS::ENGINE::VisitorSaveState vst(p);
+ YACS::ENGINE::VisitorSalomeSaveState vst(p);
vst.openFileDump(myArgs.finalDump);
p->accept(&vst);
vst.closeFileDump();