Version: 9.16.0
YACS::ENGINE::portParser Class Reference

#include <LoadState.hxx>

Inheritance diagram for YACS::ENGINE::portParser:
Collaboration diagram for YACS::ENGINE::portParser:

Public Member Functions

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 init (const xmlChar **p, xmlParserBase *father=0)
 
- Public Member Functions inherited from xmlParserBase
void setAttribute (std::string key, std::string value)
 
std::string getAttribute (std::string key)
 
virtual void addData (std::string value)
 
virtual void init (const xmlChar **p, xmlParserBase *father=0)
 

Additional Inherited Members

- Static Public Member Functions inherited from YACS::ENGINE::stateParser
static void setProc (Proc *p)
 
static void setRuntime (Runtime *runtime)
 
- Static Public Member Functions inherited from xmlParserBase
static void XMLCALL start_document (void *userData)
 
static void XMLCALL end_document (void *userData)
 
static void XMLCALL start_element (void *userData, const xmlChar *name, const xmlChar **p)
 
static void XMLCALL end_element (void *userData, const xmlChar *name)
 
static void XMLCALL characters (void *userData, const xmlChar *ch, int len)
 
static void XMLCALL comment (void *userData, const xmlChar *value)
 
static void XMLCALL warning (void *userData, const char *fmt,...)
 
static void XMLCALL error (void *userData, const char *fmt,...)
 
static void XMLCALL fatal_error (void *userData, const char *fmt,...)
 
static void XMLCALL cdata_block (void *userData, const xmlChar *value, int len)
 
static void cleanGarbage ()
 
static int getGarbageSize ()
 
static void XML_SetUserData (_xmlParserCtxt *ctxt, xmlParserBase *parser)
 
- Public Attributes inherited from xmlParserBase
std::map< std::string, int > counts
 
- Static Public Attributes inherited from YACS::ENGINE::stateParser
static XMLReadState _state
 
static std::string _what
 
- Static Public Attributes inherited from xmlParserBase
static _xmlParserCtxt * _xmlParser
 
static std::stack< xmlParserBase * > _stackParser
 
- Protected Member Functions inherited from YACS::ENGINE::stateParser
virtual void onStart (const XML_Char *elem, const xmlChar **p)
 
virtual void onEnd (const XML_Char *name)
 
virtual void charData (std::string data)
 
- Protected Member Functions inherited from xmlParserBase
void getAttributes (const xmlChar **p)
 
virtual void onStart (const XML_Char *elem, const xmlChar **p)
 
virtual void onEnd (const XML_Char *name)
 
virtual void charData (std::string data)
 
virtual void incrCount (const XML_Char *elem)
 
virtual void end ()
 
virtual void stopParse (std::string what)
 
- Protected Attributes inherited from xmlParserBase
std::map< std::string, std::string > _mapAttrib
 
std::string _data
 
xmlParserBase_father
 
- Static Protected Attributes inherited from YACS::ENGINE::stateParser
static std::stack< XMLReadState_stackState
 
static Proc_p
 
static Runtime_runtime
 
static std::map< std::string, YACS::StatesForNode_nodeStateValue
 
static std::map< std::string, YACS::StatesForNode_nodeStates
 
- Static Protected Attributes inherited from xmlParserBase
static std::list< xmlParserBase * > _garbage
 

Detailed Description

Definition at line 140 of file LoadState.hxx.

Member Function Documentation

◆ addData()

void portParser::addData ( std::string  value)
virtual

Add data on the data attribute of the parser object dedicated to an xml tag

Reimplemented from xmlParserBase.

Definition at line 554 of file LoadState.cxx.

555{
556 _data = value;
557}
std::string _data

References xmlParserBase::_data.

◆ init()

void portParser::init ( const xmlChar **  p,
xmlParserBase father = 0 
)
virtual

all parsers must know their father parser (father tag), in order to set values or attributes in father.

Reimplemented from YACS::ENGINE::stateParser.

Definition at line 522 of file LoadState.cxx.

523{
524 DEBTRACE("portParser::init()");
526 _father = father;
527 YASSERT( dynamic_cast<nodeParser*> (father));
528 _stackState.push(_state);
529 if (p) getAttributes(p);
530}
#define YASSERT(val)
YASSERT macro is always defined, used like assert, but throw a YACS::Exception instead of abort.
Definition: YacsTrace.hxx:59
#define DEBTRACE(msg)
Definition: YacsTrace.hxx:31
static std::stack< XMLReadState > _stackState
Definition: LoadState.hxx:98
static XMLReadState _state
Definition: LoadState.hxx:83
xmlParserBase * _father
void getAttributes(const xmlChar **p)
Proc * p
Definition: driver.cxx:216

References xmlParserBase::_father, YACS::ENGINE::stateParser::_stackState, YACS::ENGINE::stateParser::_state, DEBTRACE, xmlParserBase::getAttributes(), p, YACS::ENGINE::XMLINPORT, and YASSERT.

◆ onEnd()

void portParser::onEnd ( const XML_Char name)
virtual

Reimplemented from YACS::ENGINE::stateParser.

Definition at line 559 of file LoadState.cxx.

560{
561 DEBTRACE("portName: " << _mapAttrib["name"] << "value: " << _data );
562 string nodeName = _father->getAttribute("name");
563 string nodeType = _father->getAttribute("type");
564 Node *node = _p->getChildByName(nodeName);
565 if (nodeType == "elementaryNode")
566 {
567 ElementaryNode* eNode = dynamic_cast<ElementaryNode*>(node);
568 YASSERT(eNode);
569 InputPort *port = eNode->getInputPort(_mapAttrib["name"]);
570 if(_data != "")
571 port->edInit("XML",_data.c_str());
572 }
573 else if (nodeType == "forLoop")
574 {
575 string what="no way to set a port value on port " + _mapAttrib["name"];
576 what += " in node " + nodeName + " of type " + nodeType;
577 throw Exception(what);
578 }
579 else if (nodeType == "whileLoop")
580 {
581 string what="no way to set a port value on port " + _mapAttrib["name"];
582 what += " in node " + nodeName + " of type " + nodeType;
583 throw Exception(what);
584 }
585 else if (nodeType == "switch")
586 {
587 string what="no way to set a port value on port " + _mapAttrib["name"];
588 what += " in node " + nodeName + " of type " + nodeType;
589 throw Exception(what);
590 }
591 else if (nodeType == "forEachLoop")
592 {
593 ForEachLoop* eNode = dynamic_cast<ForEachLoop*>(node);
594 YASSERT(eNode);
595 InputPort *port = eNode->getInputPort(_mapAttrib["name"]);
596 if(_data != "")
597 port->edInit("XML",_data.c_str());
598 }
599 else
600 {
601 string what="no way to set a port value on port " + _mapAttrib["name"];
602 what += " in node " + nodeName + " of type " + nodeType;
603 throw Exception(what);
604 }
605
606 stateParser::onEnd(name);
607}
Node * getChildByName(const std::string &name) 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.
Loop node for parametric calculation.
Base class for Input Ports.
Definition: InputPort.hxx:44
void edInit(T value)
Definition: InputPort.hxx:129
Base class for all nodes.
Definition: Node.hxx:70
virtual void onEnd(const XML_Char *name)
Definition: LoadState.cxx:111
std::map< std::string, std::string > _mapAttrib
std::string getAttribute(std::string key)

References xmlParserBase::_data, xmlParserBase::_father, xmlParserBase::_mapAttrib, YACS::ENGINE::stateParser::_p, DEBTRACE, YACS::ENGINE::InputPort::edInit(), xmlParserBase::getAttribute(), YACS::ENGINE::ComposedNode::getChildByName(), YACS::ENGINE::ElementaryNode::getInputPort(), YACS::ENGINE::ForEachLoopGen::getInputPort(), YACS::ENGINE::stateParser::onEnd(), and YASSERT.

◆ onStart()

void portParser::onStart ( const XML_Char elem,
const xmlChar **  p 
)
virtual

Reimplemented from YACS::ENGINE::stateParser.

Definition at line 533 of file LoadState.cxx.

534{
535 DEBTRACE("portParser::onStart" << elem);
536 string element(elem);
537 stateParser *parser = 0;
538 if (element == "name") parser = new attrParser();
539 else if (element == "value") parser = new valueParser();
540 else
541 {
542 _what = "expected name or value, got <" + element + ">";
545 }
546 if (parser)
547 {
548 _stackParser.push(parser);
550 parser->init(p, this);
551 }
552}
specialized parser to load SALOME execution saved states.
Definition: LoadState.hxx:81
virtual void init(const xmlChar **p, xmlParserBase *father=0)
Definition: LoadState.cxx:65
static std::string _what
Definition: LoadState.hxx:84
static void XML_SetUserData(_xmlParserCtxt *ctxt, xmlParserBase *parser)
virtual void stopParse(std::string what)
static _xmlParserCtxt * _xmlParser
static std::stack< xmlParserBase * > _stackParser

References xmlParserBase::_stackParser, YACS::ENGINE::stateParser::_state, YACS::ENGINE::stateParser::_what, xmlParserBase::_xmlParser, DEBTRACE, YACS::parser::init(), p, xmlParserBase::stopParse(), xmlParserBase::XML_SetUserData(), and YACS::ENGINE::XMLFATALERROR.


The documentation for this class was generated from the following files: