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

Public Member Functions

 COPASIElement (CCopasiXMLParser &parser, SCopasiXMLParserCommon &common)
 
virtual void end (const XML_Char *pszName)
 
virtual void start (const XML_Char *pszName, const XML_Char **papszAttrs)
 
virtual ~COPASIElement ()
 
- 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 {
  COPASI = 0, ListOfFunctions, Model, ListOfTasks,
  ListOfReports, ListOfPlots, GUI, ListOfLayouts,
  SBMLReference
}
 

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 2812 of file CCopasiXMLParser.h.

Member Enumeration Documentation

Constructor & Destructor Documentation

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

Member Function Documentation

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

End element handler

Parameters
constXML_Char *pszName

Definition at line 592 of file CCopasiXMLParser.cpp.

References C_INVALID_INDEX, CKeyFactory::get(), CCopasiVectorN< CType >::getIndex(), CCopasiObject::getKey(), CCopasiRootContainer::getKeyFactory(), CCopasiMessage::getLastMessage(), CCopasiParameter::getType(), CCopasiParameter::getValue(), CCopasiParameter::KEY, SCopasiXMLParserCommon::KeyMap, CCopasiXMLParser::mCommon, SCopasiXMLParserCommon::pFunctionList, SCopasiXMLParserCommon::pGUI, CCopasiParameter::Value::pKEY, CCopasiVectorN< CType >::remove(), CCopasiParameter::setValue(), START_ELEMENT, and SCopasiXMLParserCommon::UnmappedKeyParameters.

593 {
594  if (!strcmp(pszName, "COPASI"))
595  {
597 
598  // We need to handle the unmapped parameters of type key.
599  std::vector< std::string >::iterator it = mCommon.UnmappedKeyParameters.begin();
600  std::vector< std::string >::iterator end = mCommon.UnmappedKeyParameters.end();
601 
602  for (; it != end; ++it)
603  {
604  CCopasiParameter * pParameter =
605  dynamic_cast< CCopasiParameter * >(CCopasiRootContainer::getKeyFactory()->get(*it));
606 
607  if (pParameter != NULL &&
608  pParameter->getType() == CCopasiParameter::KEY)
609  {
610  CCopasiObject * pObject =
611  mCommon.KeyMap.get(*pParameter->getValue().pKEY);
612 
613  if (pObject != NULL)
614  pParameter->setValue(pObject->getKey());
615  else
616  pParameter->setValue(std::string(""));
617  }
618  }
619 
620  // We need to remove the no longer needed expression "Objective Function" from the function list.
621  if (mCommon.pFunctionList != NULL &&
622  mCommon.pFunctionList->getIndex("Objective Function") != C_INVALID_INDEX)
623  {
624  mCommon.pFunctionList->remove("Objective Function");
625  }
626 
627  return;
628  }
629 
630  if (!strcmp(pszName, "ParameterGroup"))
631  {
633  }
634  else if (!strcmp(pszName, "GUI") && mCommon.pGUI == NULL)
635  {
637  }
638 
640 
641  //TODO why no case statement with error checking (like in other elements)?
642 
643  return;
644 }
CCopasiVectorN< CFunction > * pFunctionList
bool setValue(const CType &value)
#define START_ELEMENT
CCopasiObject * get(const std::string &key)
#define C_INVALID_INDEX
Definition: copasi.h:222
virtual size_t getIndex(const std::string &name) const
virtual const std::string & getKey() const
const CCopasiParameter::Type & getType() const
const Value & getValue() const
virtual void end(const XML_Char *pszName)
virtual void remove(const std::string &name)
static CKeyFactory * getKeyFactory()
static CCopasiMessage getLastMessage()
std::vector< std::string > UnmappedKeyParameters
void CCopasiXMLParser::COPASIElement::start ( const XML_Char *  pszName,
const XML_Char **  papszAttrs 
)
virtual

Start element handler

Parameters
constXML_Char *pszName
constXML_Char **papszAttrs

Definition at line 471 of file CCopasiXMLParser.cpp.

References C_INT32, CCopasiXMLParser::mCommon, MCXML, CExpatTemplate< CExpat >::mParser, SCopasiXMLParserCommon::pGUI, SCopasiXMLParserCommon::pVersion, CVersion::setVersion(), strToInt(), and CCopasiMessage::WARNING.

473 {
474  mCurrentElement++; /* We should always be on the next element */
475  mpCurrentHandler = NULL;
476 
477  const char * versionMajor;
478  C_INT32 VersionMajor;
479  const char * versionMinor;
480  C_INT32 VersionMinor;
481  const char * versionDevel;
482  C_INT32 VersionDevel;
483  bool CopasiSourcesModified = true;
484 
485  switch (mCurrentElement)
486  {
487  case COPASI:
488 
489  if (!strcmp(pszName, "COPASI"))
490  {
491  versionMajor = mParser.getAttributeValue("versionMajor", papszAttrs, "0");
492  VersionMajor = strToInt(versionMajor);
493  versionMinor = mParser.getAttributeValue("versionMinor", papszAttrs, "0");
494  VersionMinor = strToInt(versionMinor);
495  versionDevel = mParser.getAttributeValue("versionDevel", papszAttrs, "0");
496  VersionDevel = strToInt(versionDevel);
497  CopasiSourcesModified = mParser.toBool(mParser.getAttributeValue("copasiSourcesModified", papszAttrs, "true"));
498 
499  mCommon.pVersion->setVersion(VersionMajor, VersionMinor, VersionDevel, CopasiSourcesModified);
500 
501  return;
502  }
503  // We may have a configuration file which starts with a parameter group
504  else if (!strcmp(pszName, "ParameterGroup"))
505  {
506  mpCurrentHandler = new ParameterGroupElement(mParser, mCommon);
507  }
508  else
509  {
511 
513  pszName, "COPASI", mParser.getCurrentLineNumber());
514  }
515 
516  break;
517 
518  case ListOfFunctions:
519 
520  if (!strcmp(pszName, "ListOfFunctions"))
521  mpCurrentHandler = new ListOfFunctionsElement(mParser, mCommon);
522 
523  break;
524 
525  case Model:
526 
527  if (!strcmp(pszName, "Model"))
528  mpCurrentHandler = new ModelElement(mParser, mCommon);
529 
530  break;
531 
532  case ListOfTasks:
533 
534  if (!strcmp(pszName, "ListOfTasks"))
535  mpCurrentHandler = new ListOfTasksElement(mParser, mCommon);
536 
537  break;
538 
539  case ListOfReports:
540 
541  if (!strcmp(pszName, "ListOfReports"))
542  mpCurrentHandler = new ListOfReportsElement(mParser, mCommon);
543 
544  break;
545 
546  case ListOfPlots:
547 
548  if (!strcmp(pszName, "ListOfPlots"))
549  mpCurrentHandler = new ListOfPlotsElement(mParser, mCommon);
550 
551  break;
552 
553  case GUI:
554 
555  if (!strcmp(pszName, "GUI"))
556  {
557  if (mCommon.pGUI)
558  mpCurrentHandler = new GUIElement(mParser, mCommon);
559  else
561  }
562 
563  break;
564 
565  case ListOfLayouts:
566 
567  if (!strcmp(pszName, "ListOfLayouts"))
568  mpCurrentHandler = new ListOfLayoutsElement(mParser, mCommon);
569 
570  break;
571 
572  case SBMLReference:
573 
574  if (!strcmp(pszName, "SBMLReference"))
575  mpCurrentHandler = new SBMLReferenceElement(mParser, mCommon);
576 
577  break;
578 
579  default:
581  break;
582  }
583 
584  if (mpCurrentHandler)
586 
587  mParser.onStartElement(pszName, papszAttrs);
588 
589  return;
590 }
UnknownElement mUnknownElement
static bool toBool(const char *attribute)
Definition: CExpat.h:728
void setVersion(const C_INT32 &major, const C_INT32 &minor, const C_INT32 &devel, const bool &sourcesModified, const std::string &comment="", const std::string &creator="")
Definition: CVersion.cpp:102
const char * getAttributeValue(const std::string &name, const char **attributes, const bool &required=true) const
Definition: CExpat.h:685
#define MCXML
#define C_INT32
Definition: copasi.h:90
virtual void onStartElement(const XML_Char *pszName, const XML_Char **papszAttrs)
void pushElementHandler(CXMLElementHandler< CCopasiXMLParser, SCopasiXMLParserCommon > *elementHandler)
int getCurrentLineNumber() const
Definition: CExpat.h:470
C_INT32 strToInt(const char *str, char const **pTail)
Definition: utility.cpp:354

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