70 _stackState.push(_state);
98 _what =
"expected <graphState>, got <" + element +
">";
104 _stackParser.push(
parser);
105 XML_SetUserData(_xmlParser,
parser);
114 _state = _stackState.top();
131 _stackState.push(_state);
132 if (
p) getAttributes(
p);
137 string element(elem);
142 _what =
"expected <node>, got <" + element +
">";
148 _stackParser.push(
parser);
149 XML_SetUserData(_xmlParser,
parser);
157 std::map<std::string, YACS::StatesForNode>::const_iterator it;
158 for (it = _nodeStates.begin(); it != _nodeStates.end(); it++)
161 string nodeName = it->first;
162 DEBTRACE(
"nodeName = " << nodeName);
163 if(_p->getName() == nodeName)
170 for (list<OutGate*>::iterator io = backlinks.begin(); io != backlinks.end(); io++)
172 Node* fromNode = (*io)->getNode();
174 if (fromNode == _p) fromName = fromNode->
getName();
175 else fromName = _p->getChildName(fromNode);
178 DEBTRACE(
" fromNode = " << fromName);
197 _stackState.push(_state);
198 if (
p) getAttributes(
p);
203 string element(elem);
205 if (element ==
"name") parser =
new attrParser();
206 else if (element ==
"value") parser =
new valueParser();
209 _what =
"expected name or value, got <" + element +
">";
215 _stackParser.push(parser);
216 XML_SetUserData(_xmlParser, parser);
217 parser->
init(
p,
this);
237 _loopSamples.clear();
240 _stackState.push(_state);
241 if (
p) getAttributes(
p);
247 DEBTRACE(
"nodeParser::onStart" << elem);
248 string element(elem);
257 else if (element ==
"loopOutputPort")
260 _loopSamples.push_back(sparser);
265 _what =
"expected name, state or inputPort, got <" + element +
">";
271 _stackParser.push(
parser);
272 XML_SetUserData(_xmlParser,
parser);
279 string nodeName = _mapAttrib[
"name"];
280 string nodeType = _mapAttrib[
"type"];
281 string nodeState = _mapAttrib[
"state"];
282 DEBTRACE(
"nodeName: " << nodeName <<
" nodeType: " << nodeType <<
" nodeState: " << nodeState );
285 _nodeStates[nodeName] = _nodeStateValue[nodeState];
287 if(_p->getName() == nodeName)
292 YASSERT(_nodeStateValue.find(nodeState) != _nodeStateValue.end());
295 if (nodeType ==
"forLoop")
297 if (_mapAttrib.find(
"nsteps") == _mapAttrib.end())
299 _what =
"no attribute nsteps in forLoop " + _mapAttrib[
"name"];
303 int nsteps = atoi(_mapAttrib[
"nsteps"].c_str());
305 if (_mapAttrib.find(
"nbdone") == _mapAttrib.end())
307 _what =
"no attribute nbdone in forLoop " + _mapAttrib[
"name"];
311 int nbdone = atoi(_mapAttrib[
"nbdone"].c_str());
312 DEBTRACE(
"nsteps = " << nsteps <<
", nbdone = " << nbdone);
317 _what =
"node is not a ForLoop: " + _mapAttrib[
"name"];
325 else if (nodeType ==
"whileLoop")
327 if (_mapAttrib.find(
"nbdone") == _mapAttrib.end())
329 _what =
"no attribute nbdone in forLoop " + _mapAttrib[
"name"];
333 int nbdone = atoi(_mapAttrib[
"nbdone"].c_str());
335 if (_mapAttrib.find(
"condition") == _mapAttrib.end())
337 _what =
"no attribute condition in forLoop " + _mapAttrib[
"name"];
341 bool condition = atoi(_mapAttrib[
"condition"].c_str());
342 DEBTRACE(
"condition = " << condition <<
", nbdone = " << nbdone);
347 _what =
"node is not a WhileLoop: " + _mapAttrib[
"name"];
355 else if (nodeType ==
"switch")
357 if (_mapAttrib.find(
"condition") == _mapAttrib.end())
359 _what =
"no attribute condition in switch " + _mapAttrib[
"name"];
363 int condition = atoi(_mapAttrib[
"condition"].c_str());
364 DEBTRACE(
"condition = " << condition);
369 _what =
"node is not a Switch: " + _mapAttrib[
"name"];
375 else if (nodeType ==
"forEachLoop")
380 _what =
"node is not a ForEachLoop: " + _mapAttrib[
"name"];
386 std::vector<unsigned int> passedIds;
387 std::vector<SequenceAny *> passedOutputs;
388 std::vector<std::string> nameOfOutputs;
389 bool firstPort =
true;
390 std::list<loopPortParser*>::const_iterator itPort;
391 for(itPort=_loopSamples.begin(); itPort!=_loopSamples.end(); itPort++)
393 const std::string& portName =(*itPort)->getPortName();
394 nameOfOutputs.push_back(portName);
398 _what =
"Impossible to find the type of the port " + portName;
403 unsigned int nbSamples = (*itPort)->getNbSamples();
405 passedOutputs.push_back(seqValues);
406 for(
unsigned int i = 0;
i < nbSamples;
i++)
408 unsigned int sampleId = (*itPort)->getSampleId(
i);
409 const std::string& sampleData = (*itPort)->getSampleData(
i);
410 Any* value = xmlToAny(sampleData, tc);
413 passedIds.push_back(sampleId);
418 unsigned int pos = 0;
419 while(pos < passedIds.size() && sampleId != passedIds[pos])
421 if(pos < passedIds.size())
425 _what =
"Inconsistent sample id in foreach node " + _mapAttrib[
"name"];
428 itPort=_loopSamples.end();
449 doc = xmlParseMemory(data.c_str(), data.length());
453 msg <<
"Problem in conversion: XML Document not parsed successfully ";
454 msg <<
" (" << __FILE__ <<
":" << __LINE__ <<
")";
457 cur = xmlDocGetRootElement(
doc);
462 msg <<
"Problem in conversion: empty XML Document";
463 msg <<
" (" << __FILE__ <<
":" << __LINE__ <<
")";
468 if ((!xmlStrcmp(cur->name, (
const xmlChar *)
"value")))
479 msg <<
"Problem in conversion: incorrect XML value";
480 msg <<
" (" << __FILE__ <<
":" << __LINE__ <<
")";
494 _stackState.push(_state);
495 if (
p) getAttributes(
p);
501 string element(elem);
502 _what =
"expected nothing, got <" + element +
">";
516 _father->setAttribute((
char*)name, _attrValue);
528 _stackState.push(_state);
529 if (
p) getAttributes(
p);
535 DEBTRACE(
"portParser::onStart" << elem);
536 string element(elem);
542 _what =
"expected name or value, got <" + element +
">";
548 _stackParser.push(
parser);
549 XML_SetUserData(_xmlParser,
parser);
561 DEBTRACE(
"portName: " << _mapAttrib[
"name"] <<
"value: " << _data );
562 string nodeName = _father->getAttribute(
"name");
563 string nodeType = _father->getAttribute(
"type");
565 if (nodeType ==
"elementaryNode")
571 port->
edInit(
"XML",_data.c_str());
573 else if (nodeType ==
"forLoop")
575 string what=
"no way to set a port value on port " + _mapAttrib[
"name"];
576 what +=
" in node " + nodeName +
" of type " + nodeType;
579 else if (nodeType ==
"whileLoop")
581 string what=
"no way to set a port value on port " + _mapAttrib[
"name"];
582 what +=
" in node " + nodeName +
" of type " + nodeType;
585 else if (nodeType ==
"switch")
587 string what=
"no way to set a port value on port " + _mapAttrib[
"name"];
588 what +=
" in node " + nodeName +
" of type " + nodeType;
591 else if (nodeType ==
"forEachLoop")
597 port->
edInit(
"XML",_data.c_str());
601 string what=
"no way to set a port value on port " + _mapAttrib[
"name"];
602 what +=
" in node " + nodeName +
" of type " + nodeType;
616 _stackState.push(_state);
617 if (
p) getAttributes(
p);
623 string element(elem);
624 DEBTRACE(
"value type " << element );
631 _stackParser.push(
parser);
632 XML_SetUserData(_xmlParser,
parser);
639 _data =
"<value>" + value +
"</value>";
645 _father->addData(_data);
646 string elem = (
char *) name;
659 _stackState.push(_state);
660 if (
p) getAttributes(
p);
666 string element(elem);
672 _what =
"expected data, got <" + element +
">";
678 _stackParser.push(
parser);
679 XML_SetUserData(_xmlParser,
parser);
686 string val =
"<array>" + value +
"</array>";
695 _father->addData(_data);
706 _stackState.push(_state);
707 if (
p) getAttributes(
p);
713 string element(elem);
719 _what =
"expected value, got <" + element +
">";
725 _stackParser.push(
parser);
726 XML_SetUserData(_xmlParser,
parser);
733 _dataList.push_back(value);
739 string val =
"<data>";
740 while (!_dataList.empty())
742 val += _dataList.front();
743 _dataList.pop_front();
747 _father->addData(val);
755 DEBTRACE(
"simpleTypeParser::init()");
758 _stackState.push(_state);
759 if (
p) getAttributes(
p);
764 string element(elem);
765 _what =
"expected nothing, got <" + element +
">";
772 string val = string(
"<") + (
char*) name +
">" + _data +
"</" + (
char*) name +
">";
774 _father->addData(val);
780 _data = _data + data;
790 _stackState.push(_state);
793 if (
p) getAttributes(
p);
798 DEBTRACE(
"loopPortParser::onStart" << elem);
799 string element(elem);
805 _what =
"expected name or sample, got <" + element +
">";
811 _stackParser.push(
parser);
812 XML_SetUserData(_xmlParser,
parser);
828 _ids.push_back(index);
829 _sampleData.push_back(data);
844 return _sampleData[
i];
849 return _mapAttrib.at(
"name");
856 _sampleFather(father)
871 DEBTRACE(
"sampleParser::onStart" << elem);
872 string element(elem);
878 _what =
"expected index or value, got <" + element +
">";
894 _what =
"no attribute index in sample ";
898 int index = atoi(
_mapAttrib[
"index"].c_str());
937 string what =
"Abort Parse: " +
parser->_what;
943 string what =
"Abort Parse: unknown execution problem";
952 DEBTRACE(
"YACS::ENGINE::loadState");
957 myStateLoader.
parse(xmlStateFile);
#define YASSERT(val)
YASSERT macro is always defined, used like assert, but throw a YACS::Exception instead of abort.
: Interface for management of storage of data formated dynamically in its TypeCode....
void init(bool start=true)
Initialize the bloc.
void exUpdateState()
Update the bloc state.
Base class for all calculation nodes.
InputPort * getInputPort(const std::string &name) const
InputPort * getInputPort(const std::string &name) const
Get an input port given its name.
void assignPassedResults(const std::vector< unsigned int > &passedIds, const std::vector< SequenceAny * > &passedOutputs, const std::vector< std::string > &nameOfOutputs)
const TypeCode * getOutputPortType(const std::string &portName) const
Loop node for parametric calculation.
InputPort * edGetNbOfTimesInputPort()
void setPrecursorDone(OutGate *fromgate)
std::list< OutGate * > getBackLinks()
Base class for all nodes.
virtual Node * getChildByName(const std::string &name) const =0
const std::string & getName() const
Base class for all schema objects.
void setEltAtRank(int i, const Any *elem)
static SequenceAny * New(const std::vector< T > &vec)
Control node that emulates the C switch.
InputPort * edGetConditionPort()
Base class for all type objects.
InputPort * edGetConditionPort()
virtual void onStart(const XML_Char *elem, const xmlChar **p)
virtual void addData(std::string value)
virtual void init(const xmlChar **p, xmlParserBase *father=0)
virtual void onEnd(const XML_Char *name)
virtual void charData(std::string data)
virtual void onEnd(const XML_Char *name)
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 addData(std::string value)
virtual void onStart(const XML_Char *elem, const xmlChar **p)
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 init(const xmlChar **p, xmlParserBase *father=0)
virtual void init(const xmlChar **p, xmlParserBase *father=0)
void addSample(int index, const std::string data)
virtual void charData(std::string data)
virtual void onEnd(const XML_Char *name)
const std::string & getPortName() const
unsigned int getNbSamples() const
unsigned int getSampleId(unsigned int i) const
const std::string & getSampleData(unsigned int i) const
virtual void onStart(const XML_Char *elem, const xmlChar **p)
virtual void onStart(const XML_Char *elem, const xmlChar **p)
virtual void init(const xmlChar **p, xmlParserBase *father=0)
virtual void onEnd(const XML_Char *name)
Any * xmlToAny(const std::string &data, const TypeCode *tc) const
virtual void addData(std::string value)
virtual void onEnd(const XML_Char *name)
virtual void init(const xmlChar **p, xmlParserBase *father=0)
virtual void onStart(const XML_Char *elem, const xmlChar **p)
virtual void init(const xmlChar **p, xmlParserBase *father=0)
virtual void onStart(const XML_Char *elem, const xmlChar **p)
sampleParser(loopPortParser *father)
virtual void charData(std::string data)
virtual void onEnd(const XML_Char *name)
loopPortParser * _sampleFather
virtual void init(const xmlChar **p, xmlParserBase *father=0)
virtual void charData(std::string data)
virtual void onEnd(const XML_Char *name)
virtual void onStart(const XML_Char *elem, const xmlChar **p)
class for parse an xml file, use a dedicated parser, to load a saved state of a SALOME execution.
virtual void parse(std::string xmlState)
stateLoader(xmlParserBase *parser, YACS::ENGINE::Proc *p)
specialized parser to load SALOME execution saved states.
virtual void onStart(const XML_Char *elem, const xmlChar **p)
static std::stack< XMLReadState > _stackState
static Runtime * _runtime
virtual void init(const xmlChar **p, xmlParserBase *father=0)
virtual void onEnd(const XML_Char *name)
static void setProc(Proc *p)
static void setRuntime(Runtime *runtime)
virtual void charData(std::string data)
static XMLReadState _state
static std::map< std::string, YACS::StatesForNode > _nodeStates
static std::map< std::string, YACS::StatesForNode > _nodeStateValue
virtual void init(const xmlChar **p, xmlParserBase *father=0)
virtual void onEnd(const XML_Char *name)
virtual void addData(std::string value)
virtual void onStart(const XML_Char *elem, const xmlChar **p)
virtual void onStart(const XML_Char *elem, const xmlChar **p)
virtual void init(const xmlChar **p, xmlParserBase *father=0)
virtual void onEnd(const XML_Char *name)
virtual void addData(std::string)
base class for xml parsers, runtime independant
static void XML_SetUserData(_xmlParserCtxt *ctxt, xmlParserBase *parser)
virtual void stopParse(std::string what)
static _xmlParserCtxt * _xmlParser
static std::stack< xmlParserBase * > _stackParser
std::map< std::string, std::string > _mapAttrib
void getAttributes(const xmlChar **p)
base class for parse an xml file, use a dedicated parser, runtime independant.
virtual void parse(std::string xmlFile)
xmlParserBase * _rootParser
void YACSLIBENGINE_EXPORT NbDoneLoader(Loop *node, int val)
YACSLIBENGINE_EXPORT Runtime * getRuntime()
void YACSLIBENGINE_EXPORT StateLoader(Node *node, YACS::StatesForNode state)
YACSLOADER_EXPORT void loadState(YACS::ENGINE::Proc *p, const std::string &xmlStateFile)
Load state from a file into a Proc.
YACS::ENGINE::Any * convertXmlNeutral(const TypeCode *t, xmlDocPtr doc, xmlNodePtr cur)