Version: 8.3.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)
 

Additional Inherited Members

- Static Public Member Functions inherited from YACS::ENGINE::stateParser
static void setProc (Proc *p)
 
static void setRuntime (Runtime *runtime)
 
- 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
 
- Protected Member Functions inherited from YACS::ENGINE::stateParser
virtual void charData (std::string data)
 
- 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
 

Detailed Description

Definition at line 140 of file LoadState.hxx.

Member Function Documentation

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 }
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.

References DEBTRACE, YACS::ENGINE::XMLINPORT, and YASSERT.

523 {
524  DEBTRACE("portParser::init()");
525  _state = XMLINPORT;
526  _father = father;
527  YASSERT( dynamic_cast<nodeParser*> (father));
528  _stackState.push(_state);
529  if (p) getAttributes(p);
530 }
void portParser::onEnd ( const XML_Char name)
virtual

Reimplemented from YACS::ENGINE::stateParser.

Definition at line 559 of file LoadState.cxx.

References DEBTRACE, YACS::ENGINE::InputPort::edInit(), YACS::ENGINE::Node::getChildByName(), YACS::ENGINE::ElementaryNode::getInputPort(), YACS::ENGINE::ForEachLoop::getInputPort(), YACS::ENGINE::stateParser::onEnd(), and YASSERT.

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 }
void portParser::onStart ( const XML_Char elem,
const xmlChar **  p 
)
virtual

Reimplemented from YACS::ENGINE::stateParser.

Definition at line 533 of file LoadState.cxx.

References DEBTRACE, YACS::ENGINE::stateParser::init(), and YACS::ENGINE::XMLFATALERROR.

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 + ">";
544  stopParse(_what);
545  }
546  if (parser)
547  {
548  _stackParser.push(parser);
549  XML_SetUserData(_xmlParser, parser);
550  parser->init(p, this);
551  }
552 }

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