COPASI API  4.16.103
Public Member Functions | Private Types | List of all members
CCopasiXMLParser::ModelParameterElement Class Reference
Inheritance diagram for CCopasiXMLParser::ModelParameterElement:
Inheritance graph
[legend]
Collaboration diagram for CCopasiXMLParser::ModelParameterElement:
Collaboration graph
[legend]

Public Member Functions

virtual void end (const XML_Char *pszName)
 
 ModelParameterElement (CCopasiXMLParser &parser, SCopasiXMLParserCommon &common)
 
virtual void start (const XML_Char *pszName, const XML_Char **papszAttrs)
 
virtual ~ModelParameterElement ()
 
- Public Member Functions inherited from CXMLElementHandler< CCopasiXMLParser, SCopasiXMLParserCommon >
 CXMLElementHandler (CCopasiXMLParser &parser, SCopasiXMLParserCommon &common)
 
virtual void end (const XML_Char *C_UNUSED(pszName))
 
virtual void reset ()
 
virtual void start (const XML_Char *C_UNUSED(pszName), const XML_Char **C_UNUSED(papszAttrs))
 
virtual ~CXMLElementHandler ()
 

Private Types

enum  Element { ModelParameter = 0, InitialExpression }
 

Additional Inherited Members

- Protected Member Functions inherited from CXMLElementHandler< CCopasiXMLParser, SCopasiXMLParserCommon >
void addFix (const std::string &key, CCopasiObject *pObject)
 
void deleteCurrentHandler ()
 
- Protected Attributes inherited from CXMLElementHandler< CCopasiXMLParser, SCopasiXMLParserCommon >
SCopasiXMLParserCommonmCommon
 
C_INT32 mCurrentElement
 
C_INT32 mLastKnownElement
 
CCopasiXMLParsermParser
 
CXMLElementHandlermpCurrentHandler
 

Detailed Description

Definition at line 10 of file CCopasiXMLParser.h.

Member Enumeration Documentation

Enum of invoked parsers

Enumerator
ModelParameter 
InitialExpression 

Definition at line 18 of file CCopasiXMLParser.h.

88 {

Constructor & Destructor Documentation

CCopasiXMLParser::ModelParameterElement::ModelParameterElement ( CCopasiXMLParser parser,
SCopasiXMLParserCommon common 
)
CCopasiXMLParser::ModelParameterElement::~ModelParameterElement ( )
virtual

Destructor

Definition at line 507 of file ListOfModelParameterSets.cpp.

508 {}

Member Function Documentation

void CCopasiXMLParser::ModelParameterElement::end ( const XML_Char *  pszName)
virtual

End element handler

Parameters
constXML_Char *pszName

Definition at line 604 of file ListOfModelParameterSets.cpp.

References SCopasiXMLParserCommon::CharacterData, CCopasiMessage::EXCEPTION, CCopasiMessage::getLastMessage(), CCopasiXMLParser::mCommon, MCXML, CExpatTemplate< CExpat >::mParser, SCopasiXMLParserCommon::pCurrentModelParameter, CModelParameter::setInitialExpression(), CCopasiMessage::size(), START_ELEMENT, and UNKNOWN_ELEMENT.

605 {
606  switch (mCurrentElement)
607  {
608  case ModelParameter:
609 
610  if (strcmp(pszName, "ModelParameter"))
612  pszName, "ModelParameter", mParser.getCurrentLineNumber());
613 
616 
617  /* Tell the parent element we are done. */
618  mParser.onEndElement(pszName);
619  break;
620 
621  case InitialExpression:
622 
623  if (strcmp(pszName, "InitialExpression"))
625  pszName, "InitialExpression", mParser.getCurrentLineNumber());
626 
627  {
628  size_t Size = CCopasiMessage::size();
629 
631 
632  // Remove error messages created by setExpression as this may fail
633  // due to incomplete model specification at this time.
634  while (CCopasiMessage::size() > Size)
636  }
637 
639 
640  break;
641 
642  case UNKNOWN_ELEMENT:
644  break;
645 
646  default:
648  pszName, "???", mParser.getCurrentLineNumber());
649  break;
650  }
651 
652  return;
653 }
#define MCXML
virtual void onEndElement(const XML_Char *pszName)
#define UNKNOWN_ELEMENT
void setInitialExpression(const std::string &initialExpression)
#define START_ELEMENT
static size_t size()
static CCopasiMessage getLastMessage()
int getCurrentLineNumber() const
Definition: CExpat.h:470
CModelParameter * pCurrentModelParameter
void CCopasiXMLParser::ModelParameterElement::start ( const XML_Char *  pszName,
const XML_Char **  papszAttrs 
)
virtual

Start element handler

Parameters
constXML_Char *pszName
constXML_Char **papszAttrs

Definition at line 510 of file ListOfModelParameterSets.cpp.

References C_FLOAT64, CModelParameter::Compartment, CCopasiMessage::EXCEPTION, CModelEntity::FIXED, CCopasiXMLParser::mCommon, MCXML, SCopasiXMLParserCommon::ModelParameterGroupStack, CExpatTemplate< CExpat >::mParser, CModelParameter::ParticleNumbers, SCopasiXMLParserCommon::pCurrentModelParameter, CModelParameter::ReactionParameter, CModelParameter::setCN(), CModelParameter::setSimulationType(), CModelParameter::setValue(), CModelParameter::Species, toEnum(), CModelParameter::TypeNames, CModelParameter::unknown, UNKNOWN_ELEMENT, and CModelEntity::XMLStatus.

512 {
513  const char * CN;
514  const char * pValue;
515  C_FLOAT64 Value = std::numeric_limits< C_FLOAT64 >::quiet_NaN();
516  const char * pType;
518  const char * pSimulationType;
519  CModelEntity::Status SimulationType;
520 
521  mpCurrentHandler = NULL;
523 
524  while (mpCurrentHandler == NULL)
525  {
526  mCurrentElement++; /* We should always be on the next element */
527 
528  switch (mCurrentElement)
529  {
530  case ModelParameter:
531 
532  if (strcmp(pszName, "ModelParameter"))
534  pszName, "ModelParameter", mParser.getCurrentLineNumber());
535 
537 
538  // Element specific code.
539  CN = mParser.getAttributeValue("cn", papszAttrs);
540  pValue = mParser.getAttributeValue("value", papszAttrs);
541  pType = mParser.getAttributeValue("type", papszAttrs);
542  pSimulationType = mParser.getAttributeValue("simulationType", papszAttrs);
543 
544  if (pValue != NULL)
545  {
546  Value = CCopasiXMLInterface::DBL(pValue);
547  }
548 
550 
551  switch (Type)
552  {
555  break;
556 
559  break;
560 
563  break;
564 
565  default:
567  break;
568  }
569 
570  mCommon.pCurrentModelParameter->setCN(std::string(CN));
571 
572  SimulationType = toEnum(pSimulationType, CModelEntity::XMLStatus, CModelEntity::FIXED);
574 
576  return;
577 
578  case InitialExpression:
579 
580  if (!strcmp(pszName, "InitialExpression"))
582 
583  break;
584 
585  default:
588  break;
589  }
590  }
591 
593 
595  {
596  mLastKnownElement = mCurrentElement;
597  }
598 
599  mParser.onStartElement(pszName, papszAttrs);
600 
601  return;
602 }
UnknownElement mUnknownElement
const char * getAttributeValue(const std::string &name, const char **attributes, const bool &required=true) const
Definition: CExpat.h:685
#define MCXML
static const char * TypeNames[]
#define UNKNOWN_ELEMENT
virtual void onStartElement(const XML_Char *pszName, const XML_Char **papszAttrs)
virtual void setValue(const double &value, const Framework &framework)
void pushElementHandler(CXMLElementHandler< CCopasiXMLParser, SCopasiXMLParserCommon > *elementHandler)
CharacterDataElement mCharacterDataElement
static const char * XMLStatus[]
Definition: CModelValue.h:72
CType toEnum(const char *attribute, const char **enumNames, const CType &enumDefault)
Definition: utility.h:107
std::stack< CModelParameterGroup * > ModelParameterGroupStack
#define C_FLOAT64
Definition: copasi.h:92
virtual void setCN(const CCopasiObjectName &cn)
int getCurrentLineNumber() const
Definition: CExpat.h:470
bool setSimulationType(const CModelEntity::Status &simulationType)
CModelParameter * pCurrentModelParameter

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