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

Public Member Functions

virtual void end (const XML_Char *pszName)
 
virtual void start (const XML_Char *pszName, const XML_Char **papszAttrs)
 
 TaskElement (CCopasiXMLParser &parser, SCopasiXMLParserCommon &common)
 
virtual ~TaskElement ()
 
- 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 { Task = 0, Report, Problem, Method }
 

Private Attributes

MethodElementmpMethodElement
 
ParameterGroupElementmpProblemElement
 
ReportInstanceElementmpReportElement
 

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

Member Enumeration Documentation

Enum of invoked parsers

Enumerator
Task 
Report 
Problem 
Method 

Definition at line 2409 of file CCopasiXMLParser.h.

Constructor & Destructor Documentation

CCopasiXMLParser::TaskElement::TaskElement ( CCopasiXMLParser parser,
SCopasiXMLParserCommon common 
)

Constructor

Definition at line 8476 of file CCopasiXMLParser.cpp.

8476  :
8478  SCopasiXMLParserCommon > (parser, common),
8479  mpReportElement(NULL),
8480  mpProblemElement(NULL),
8481  mpMethodElement(NULL)
8482 {}
ReportInstanceElement * mpReportElement
ParameterGroupElement * mpProblemElement
CCopasiXMLParser::TaskElement::~TaskElement ( )
virtual

Destructor

Definition at line 8484 of file CCopasiXMLParser.cpp.

References pdelete.

8485 {
8489 }
ReportInstanceElement * mpReportElement
#define pdelete(p)
Definition: copasi.h:215
ParameterGroupElement * mpProblemElement

Member Function Documentation

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

End element handler

Parameters
constXML_Char *pszName

Definition at line 8657 of file CCopasiXMLParser.cpp.

References CCopasiParameterGroup::elevateChildren(), CCopasiMessage::EXCEPTION, CCopasiMessage::getLastMessage(), CCopasiTask::getMethod(), CCopasiParameterGroup::getParameter(), CCopasiTask::getProblem(), CCopasiTask::getType(), CCopasiParameter::getValue(), CCopasiXMLParser::mCommon, MCXML, SCopasiXMLParserCommon::mKey2ObjectiveFunction, CExpatTemplate< CExpat >::mParser, CCopasiTask::optimization, SCopasiXMLParserCommon::pCurrentTask, pdelete, CCopasiParameter::Value::pSTRING, CCopasiContainer::remove(), CCopasiParameterGroup::setValue(), START_ELEMENT, and UNKNOWN_ELEMENT.

8658 {
8659  switch (mCurrentElement)
8660  {
8661  case Task:
8662 
8663  if (strcmp(pszName, "Task"))
8665  pszName, "Task", mParser.getCurrentLineNumber());
8666 
8667  if (mCommon.pCurrentTask == NULL)
8669 
8672  mParser.onEndElement(pszName);
8673  break;
8674 
8675  case Report:
8676 
8677  if (strcmp(pszName, "Report"))
8679  pszName, "Report", mParser.getCurrentLineNumber());
8680 
8681  // do nothing, the pointer to the correct report definition can
8682  // only be set after the report definitions have been read.
8683  break;
8684 
8685  case Problem:
8686 
8687  if (strcmp(pszName, "Problem"))
8689  pszName, "Problem", mParser.getCurrentLineNumber());
8690 
8691  // This is needed for old files containing the objective function as
8692  // part of the list of function definitions
8694  {
8696  CCopasiParameter * pParameter = pProblem->getParameter("ObjectiveFunction");
8697 
8698  if (pParameter != NULL)
8699  {
8700  if (mCommon.mKey2ObjectiveFunction.find(*pParameter->getValue().pSTRING) !=
8702  {
8703  std::string Infix = mCommon.mKey2ObjectiveFunction[*pParameter->getValue().pSTRING]->getInfix();
8704  pProblem->setValue("ObjectiveExpression", Infix);
8705  }
8706 
8707  pProblem->remove(pParameter);
8708  }
8709 
8710  std::map< std::string, CExpression * >::iterator it = mCommon.mKey2ObjectiveFunction.begin();
8711  std::map< std::string, CExpression * >::iterator end = mCommon.mKey2ObjectiveFunction.end();
8712 
8713  for (; it != end; ++it)
8714  {
8715  pdelete(it->second);
8716  }
8717 
8719  }
8720 
8722  break;
8723 
8724  case Method:
8725 
8726  if (strcmp(pszName, "Method"))
8728  pszName, "Method", mParser.getCurrentLineNumber());
8729 
8732  break;
8733 
8734  case UNKNOWN_ELEMENT:
8736  break;
8737 
8738  default:
8740  pszName, "???", mParser.getCurrentLineNumber());
8741  break;
8742  }
8743 
8744  return;
8745 }
#define pdelete(p)
Definition: copasi.h:215
#define START_ELEMENT
CCopasiProblem * getProblem()
virtual void end(const XML_Char *pszName)
#define MCXML
std::map< std::string, CExpression * > mKey2ObjectiveFunction
virtual void onEndElement(const XML_Char *pszName)
#define UNKNOWN_ELEMENT
const Value & getValue() const
bool setValue(const std::string &name, const CType &value)
virtual bool remove(CCopasiObject *pObject)
CCopasiParameter * getParameter(const std::string &name)
CCopasiMethod * getMethod()
static CCopasiMessage getLastMessage()
Type getType() const
int getCurrentLineNumber() const
Definition: CExpat.h:470
void CCopasiXMLParser::TaskElement::start ( const XML_Char *  pszName,
const XML_Char **  papszAttrs 
)
virtual

Start element handler

Parameters
constXML_Char *pszName
constXML_Char **papszAttrs

Definition at line 8491 of file CCopasiXMLParser.cpp.

References CCopasiParameterGroup::assertParameter(), CCopasiTask::crosssection, CCopasiMessage::EXCEPTION, CCopasiTask::fluxMode, CCopasiTask::getProblem(), CCopasiTask::lna, CCopasiTask::lyap, CCopasiTask::mca, CCopasiXMLParser::mCommon, MCXML, CCopasiTask::moieties, CExpatTemplate< CExpat >::mParser, CCopasiTask::optimization, CCopasiTask::parameterFitting, SCopasiXMLParserCommon::pCurrentTask, SCopasiXMLParserCommon::pModel, SCopasiXMLParserCommon::pTaskList, CCopasiMessage::RAW, CCopasiTask::scan, CCopasiTask::sens, CCopasiProblem::setModel(), CCopasiTask::setScheduled(), CCopasiTask::setUpdateModel(), CCopasiTask::steadyState, CCopasiParameter::STRING, CCopasiTask::timeCourse, toEnum(), CCopasiTask::tssAnalysis, UNKNOWN_ELEMENT, CCopasiTask::unset, and CCopasiTask::XMLType.

8492 {
8493  mCurrentElement++; /* We should always be on the next element */
8494  mpCurrentHandler = NULL;
8495 
8496  const char * Key;
8497  const char * type;
8498  CCopasiTask::Type Type;
8499  bool Scheduled = false;
8500  bool UpdateModel = false;
8501 
8502  switch (mCurrentElement)
8503  {
8504  case Task:
8505 
8506  if (strcmp(pszName, "Task"))
8508  pszName, "Task", mParser.getCurrentLineNumber());
8509 
8510  mCommon.pCurrentTask = NULL;
8511 
8512  Key = mParser.getAttributeValue("key", papszAttrs, false);
8513  type = mParser.getAttributeValue("type", papszAttrs);
8515  Scheduled = mParser.toBool(mParser.getAttributeValue("scheduled", papszAttrs, "false"));
8516  UpdateModel = mParser.toBool(mParser.getAttributeValue("updateModel", papszAttrs, "false"));
8517 
8518  // create a new CCopasiTask element depending on the type
8519  switch (Type)
8520  {
8523  break;
8524 
8527  break;
8528 
8529  case CCopasiTask::scan:
8531  break;
8532 
8533  case CCopasiTask::fluxMode:
8535  break;
8536 
8539  mCommon.pCurrentTask->getProblem()->assertParameter("Steady-State", CCopasiParameter::STRING, std::string(""));
8540  mCommon.pCurrentTask->getProblem()->assertParameter("Time-Course", CCopasiParameter::STRING, std::string(""));
8541  break;
8542 
8545  break;
8546 
8547  case CCopasiTask::mca:
8549  break;
8550 
8551  case CCopasiTask::lna:
8553  break;
8554 
8555  case CCopasiTask::lyap:
8557  break;
8558 
8559  case CCopasiTask::sens:
8561  break;
8562 
8565  break;
8566 
8567  case CCopasiTask::moieties:
8569  break;
8570 
8573  break;
8574 
8575  default:
8577  mParser.onStartElement(pszName, papszAttrs);
8578 
8580  type, mParser.getCurrentLineNumber());
8581  break;
8582  }
8583 
8584  if (mCommon.pCurrentTask != NULL)
8585  {
8586  mCommon.pCurrentTask->setScheduled(Scheduled);
8587  mCommon.pCurrentTask->setUpdateModel(UpdateModel);
8589 
8590  if (Key != NULL)
8591  {
8592  addFix(Key, mCommon.pCurrentTask);
8593  }
8594  }
8595 
8596  return;
8597  break;
8598 
8599  case Report:
8600 
8601  if (!strcmp(pszName, "Report"))
8602  {
8603  if (!mpReportElement)
8604  {
8605  mpReportElement = new ReportInstanceElement(mParser, mCommon);
8606  }
8607 
8609  }
8610 
8611  break;
8612 
8613  case Problem:
8614 
8615  if (!strcmp(pszName, "Problem"))
8616  {
8617  if (!mpProblemElement)
8618  {
8619  mpProblemElement = new ParameterGroupElement(mParser, mCommon);
8620  }
8621 
8624  }
8625 
8626  break;
8627 
8628  case Method:
8629 
8630  if (!strcmp(pszName, "Method"))
8631  {
8632  if (!mpMethodElement)
8633  {
8634  mpMethodElement = new MethodElement(mParser, mCommon);
8635  }
8636 
8638  }
8639 
8640  break;
8641 
8642  default:
8646  break;
8647  }
8648 
8649  if (mpCurrentHandler)
8651 
8652  mParser.onStartElement(pszName, papszAttrs);
8653 
8654  return;
8655 }
CCopasiVectorN< CCopasiTask > * pTaskList
ReportInstanceElement * mpReportElement
ParameterGroupElement * mpProblemElement
UnknownElement mUnknownElement
void setScheduled(const bool &scheduled)
CCopasiProblem * getProblem()
static bool toBool(const char *attribute)
Definition: CExpat.h:728
const char * getAttributeValue(const std::string &name, const char **attributes, const bool &required=true) const
Definition: CExpat.h:685
#define MCXML
virtual bool setModel(CModel *pModel)
void addFix(const std::string &key, CCopasiObject *pObject)
Definition: CXMLHandler.h:119
static const char * XMLType[]
Definition: CCopasiTask.h:72
#define UNKNOWN_ELEMENT
virtual void onStartElement(const XML_Char *pszName, const XML_Char **papszAttrs)
void pushElementHandler(CXMLElementHandler< CCopasiXMLParser, SCopasiXMLParserCommon > *elementHandler)
CType toEnum(const char *attribute, const char **enumNames, const CType &enumDefault)
Definition: utility.h:107
int getCurrentLineNumber() const
Definition: CExpat.h:470
CCopasiParameter * assertParameter(const std::string &name, const CCopasiParameter::Type type, const CType &defaultValue)
void setDerivedElement(CCopasiParameterGroup *pDerivedElement)
void setUpdateModel(const bool &updateModel)

Member Data Documentation

MethodElement* CCopasiXMLParser::TaskElement::mpMethodElement
private

Definition at line 2419 of file CCopasiXMLParser.h.

ParameterGroupElement* CCopasiXMLParser::TaskElement::mpProblemElement
private

Definition at line 2418 of file CCopasiXMLParser.h.

ReportInstanceElement* CCopasiXMLParser::TaskElement::mpReportElement
private

Definition at line 2417 of file CCopasiXMLParser.h.


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