47std::string stateParser::_what;
48std::stack<XMLReadState> stateParser::_stackState;
51std::map<std::string, YACS::StatesForNode> stateParser::_nodeStateValue;
52std::map<std::string, YACS::StatesForNode> stateParser::_nodeStates;
55void stateParser::setProc(
Proc*
p)
98 _what =
"expected <graphState>, got <" + element +
">";
137 string element(elem);
142 _what =
"expected <node>, got <" + element +
">";
157 std::map<std::string, YACS::StatesForNode>::const_iterator it;
161 string nodeName = it->first;
162 DEBTRACE(
"nodeName = " << 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();
178 DEBTRACE(
" fromNode = " << fromName);
197 _stackState.push(_state);
198 if (
p) getAttributes(
p);
203 string element(elem);
209 _what =
"expected name or value, got <" + element +
">";
215 _stackParser.push(
parser);
216 XML_SetUserData(_xmlParser,
parser);
247 DEBTRACE(
"nodeParser::onStart" << elem);
248 string element(elem);
257 else if (element ==
"loopOutputPort")
265 _what =
"expected name, state or inputPort, got <" + element +
">";
282 DEBTRACE(
"nodeName: " << nodeName <<
" nodeType: " << nodeType <<
" nodeState: " << nodeState );
295 if (nodeType ==
"forLoop")
303 int nsteps = atoi(
_mapAttrib[
"nsteps"].c_str());
311 int nbdone = atoi(
_mapAttrib[
"nbdone"].c_str());
312 DEBTRACE(
"nsteps = " << nsteps <<
", nbdone = " << nbdone);
325 else if (nodeType ==
"whileLoop")
333 int nbdone = atoi(
_mapAttrib[
"nbdone"].c_str());
341 bool condition = atoi(
_mapAttrib[
"condition"].c_str());
342 DEBTRACE(
"condition = " << condition <<
", nbdone = " << nbdone);
355 else if (nodeType ==
"switch")
363 int condition = atoi(
_mapAttrib[
"condition"].c_str());
364 DEBTRACE(
"condition = " << condition);
375 else if (nodeType ==
"forEachLoop")
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;
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);
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"];
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__ <<
")";
501 string element(elem);
502 _what =
"expected nothing, got <" + element +
">";
535 DEBTRACE(
"portParser::onStart" << elem);
536 string element(elem);
542 _what =
"expected name or value, got <" + element +
">";
565 if (nodeType ==
"elementaryNode")
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")
601 string what=
"no way to set a port value on port " +
_mapAttrib[
"name"];
602 what +=
" in node " + nodeName +
" of type " + nodeType;
623 string element(elem);
624 DEBTRACE(
"value type " << element );
639 _data =
"<value>" + value +
"</value>";
646 string elem = (
char *) name;
666 string element(elem);
672 _what =
"expected data, got <" + element +
">";
686 string val =
"<array>" + value +
"</array>";
713 string element(elem);
719 _what =
"expected value, got <" + element +
">";
739 string val =
"<data>";
755 DEBTRACE(
"simpleTypeParser::init()");
764 string element(elem);
765 _what =
"expected nothing, got <" + element +
">";
772 string val = string(
"<") + (
char*) name +
">" +
_data +
"</" + (
char*) name +
">";
798 DEBTRACE(
"loopPortParser::onStart" << elem);
799 string element(elem);
805 _what =
"expected name or sample, got <" + element +
">";
828 _ids.push_back(index);
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.
std::string getChildName(const Node *node) const
Node * getChildByName(const std::string &name) const
std::string getName() const
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.
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)
std::list< std::string > _dataList
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)
std::vector< std::string > _sampleData
virtual void init(const xmlChar **p, xmlParserBase *father=0)
std::vector< unsigned int > _ids
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)
std::list< loopPortParser * > _loopSamples
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 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
virtual void addData(std::string value)
void setAttribute(std::string key, std::string value)
static std::stack< xmlParserBase * > _stackParser
std::map< std::string, std::string > _mapAttrib
void getAttributes(const xmlChar **p)
std::string getAttribute(std::string key)
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)