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

Public Member Functions

virtual void end (const XML_Char *pszName)
 
 MetaboliteElement (CCopasiXMLParser &parser, SCopasiXMLParserCommon &common)
 
virtual void start (const XML_Char *pszName, const XML_Char **papszAttrs)
 
virtual ~MetaboliteElement ()
 
- 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 {
  Metabolite = 0, MiriamAnnotation, Comment, ListOfUnsupportedAnnotations,
  Expression, InitialExpression
}
 

Private Attributes

std::string mKey
 
CMetabmpMetabolite
 

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

Member Enumeration Documentation

Constructor & Destructor Documentation

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

Destructor

Definition at line 2532 of file CCopasiXMLParser.cpp.

2533 {}

Member Function Documentation

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

End element handler

Parameters
constXML_Char *pszName

Definition at line 2652 of file CCopasiXMLParser.cpp.

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

2653 {
2654  switch (mCurrentElement)
2655  {
2656  case Metabolite:
2657 
2658  if (strcmp(pszName, "Metabolite"))
2660  pszName, "Metabolite", mParser.getCurrentLineNumber());
2661 
2664 
2665  /* Tell the parent element we are done. */
2666  mParser.onEndElement(pszName);
2667  break;
2668 
2669  case MiriamAnnotation:
2670 
2671  if (strcmp(pszName, "MiriamAnnotation"))
2673  pszName, "MiriamAnnotation", mParser.getCurrentLineNumber());
2674 
2676  mCommon.CharacterData = "";
2677  break;
2678 
2679  case Comment:
2680 
2681  if (strcmp(pszName, "Comment"))
2683  pszName, "Comment", mParser.getCurrentLineNumber());
2684 
2686  mCommon.CharacterData = "";
2687  break;
2688 
2690 
2691  if (strcmp(pszName, "ListOfUnsupportedAnnotations"))
2693  pszName, "ListOfUnsupportedAnnotations", mParser.getCurrentLineNumber());
2694 
2696 
2697  break;
2698 
2699  case Expression:
2700 
2701  if (strcmp(pszName, "Expression"))
2703  pszName, "Expression", mParser.getCurrentLineNumber());
2704 
2705  {
2706  size_t Size = CCopasiMessage::size();
2707 
2709 
2710  // Remove error messages created by setExpression as this may fail
2711  // due to incomplete model specification at this time.
2712  while (CCopasiMessage::size() > Size)
2714  }
2715 
2716  break;
2717 
2718  case InitialExpression:
2719 
2720  if (strcmp(pszName, "InitialExpression"))
2722  pszName, "InitialExpression", mParser.getCurrentLineNumber());
2723 
2724  {
2725  size_t Size = CCopasiMessage::size();
2726 
2728 
2729  // Remove error messages created by setExpression as this may fail
2730  // due to incomplete model specification at this time.
2731  while (CCopasiMessage::size() > Size)
2733  }
2734 
2735  break;
2736 
2737  case UNKNOWN_ELEMENT:
2738  break;
2739 
2740  default:
2742  pszName, "???", mParser.getCurrentLineNumber());
2743  break;
2744  }
2745 
2747  return;
2748 }
#define START_ELEMENT
void setNotes(const std::string &notes)
#define MCXML
const CAnnotation::UnsupportedAnnotation & getUnsupportedAnnotations() const
bool setInitialExpression(const std::string &expression)
void setMiriamAnnotation(const std::string &miriamAnnotation, const std::string &newId, const std::string &oldId)
virtual void onEndElement(const XML_Char *pszName)
#define UNKNOWN_ELEMENT
virtual const std::string & getKey() const
static size_t size()
static CCopasiMessage getLastMessage()
ListOfUnsupportedAnnotationsElement mListOfUnsupportedAnnotationsElement
UnsupportedAnnotation & getUnsupportedAnnotations()
int getCurrentLineNumber() const
Definition: CExpat.h:470
bool setExpression(const std::string &expression)
void CCopasiXMLParser::MetaboliteElement::start ( const XML_Char *  pszName,
const XML_Char **  papszAttrs 
)
virtual

Start element handler

Parameters
constXML_Char *pszName
constXML_Char **papszAttrs

Definition at line 2535 of file CCopasiXMLParser.cpp.

References CCopasiVector< T >::add(), CCompartment::addMetabolite(), CCopasiMessage::EXCEPTION, fatalError, CKeyFactory::get(), CModel::getMetabolites(), SCopasiXMLParserCommon::KeyMap, CCopasiXMLParser::mCommon, MCXML, CExpatTemplate< CExpat >::mParser, SCopasiXMLParserCommon::pModel, CModelEntity::REACTIONS, toEnum(), UNKNOWN_ELEMENT, and CModelEntity::XMLStatus.

2537 {
2538  CCompartment * pCompartment = NULL;
2539  const char * Name;
2540  const char * simulationType;
2541  CModelEntity::Status SimulationType;
2542  const char reactions[] = "reactions";
2543  const char * Compartment;
2544 
2545  mpCurrentHandler = NULL;
2547 
2548  while (mpCurrentHandler == NULL)
2549  {
2550  mCurrentElement++; /* We should always be on the next element */
2551 
2552  switch (mCurrentElement)
2553  {
2554  case Metabolite:
2555 
2556  if (strcmp(pszName, "Metabolite"))
2558  pszName, "Metabolite", mParser.getCurrentLineNumber());
2559 
2560  mKey = mParser.getAttributeValue("key", papszAttrs);
2561  Name = mParser.getAttributeValue("name", papszAttrs);
2562 
2563  simulationType = mParser.getAttributeValue("simulationType", papszAttrs, false);
2564 
2565  // We need to handle old files which used the attribute status.
2566  if (!simulationType)
2567  {
2568  simulationType = mParser.getAttributeValue("status", papszAttrs, false);
2569 
2570  if (!simulationType) // status and simulationType are both missing
2571  simulationType = mParser.getAttributeValue("simulationType", papszAttrs);
2572  else if (!strcmp(simulationType, "variable")) // reactions was named variable
2573  simulationType = reactions;
2574  }
2575 
2576  SimulationType = toEnum(simulationType, CModelEntity::XMLStatus, CModelEntity::REACTIONS);
2577  Compartment = mParser.getAttributeValue("compartment", papszAttrs);
2578 
2579  mpMetabolite = new CMetab();
2580  addFix(mKey, mpMetabolite);
2581  mpMetabolite->setObjectName(Name);
2582  mpMetabolite->setStatus(SimulationType);
2583 
2584  pCompartment =
2585  dynamic_cast< CCompartment* >(mCommon.KeyMap.get(Compartment));
2586 
2587  if (!pCompartment) fatalError();
2588 
2589  pCompartment->addMetabolite(mpMetabolite);
2591 
2593  return;
2594 
2595  case MiriamAnnotation:
2596 
2597  if (!strcmp(pszName, "MiriamAnnotation"))
2599 
2600  break;
2601 
2602  case Comment:
2603 
2604  if (!strcmp(pszName, "Comment"))
2605  {
2608  }
2609 
2610  break;
2611 
2613 
2614  if (!strcmp(pszName, "ListOfUnsupportedAnnotations"))
2616 
2617  break;
2618 
2619  case Expression:
2620 
2621  if (!strcmp(pszName, "Expression"))
2623 
2624  break;
2625 
2626  case InitialExpression:
2627 
2628  if (!strcmp(pszName, "InitialExpression"))
2630 
2631  break;
2632 
2633  default:
2636  break;
2637  }
2638  }
2639 
2641 
2643  {
2645  }
2646 
2647  mParser.onStartElement(pszName, papszAttrs);
2648 
2649  return;
2650 }
bool addMetabolite(CMetab *metabolite)
UnknownElement mUnknownElement
const CCopasiVector< CMetab > & getMetabolites() const
Definition: CModel.cpp:1051
virtual void setStatus(const CModelEntity::Status &status)
Definition: CMetab.cpp:291
CCopasiObject * get(const std::string &key)
#define fatalError()
const char * getAttributeValue(const std::string &name, const char **attributes, const bool &required=true) const
Definition: CExpat.h:685
#define MCXML
Definition: CMetab.h:178
void addFix(const std::string &key, CCopasiObject *pObject)
Definition: CXMLHandler.h:119
#define UNKNOWN_ELEMENT
virtual void onStartElement(const XML_Char *pszName, const XML_Char **papszAttrs)
void pushElementHandler(CXMLElementHandler< CCopasiXMLParser, SCopasiXMLParserCommon > *elementHandler)
CharacterDataElement mCharacterDataElement
virtual bool add(const CType &src)
static const char * XMLStatus[]
Definition: CModelValue.h:72
CType toEnum(const char *attribute, const char **enumNames, const CType &enumDefault)
Definition: utility.h:107
MiriamAnnotationElement mMiriamAnnotationElement
ListOfUnsupportedAnnotationsElement mListOfUnsupportedAnnotationsElement
int getCurrentLineNumber() const
Definition: CExpat.h:470
CommentElement mCommentElement
bool setObjectName(const std::string &name)

Member Data Documentation

std::string CCopasiXMLParser::MetaboliteElement::mKey
private

The key in the CopasiML file

Definition at line 1298 of file CCopasiXMLParser.h.

CMetab* CCopasiXMLParser::MetaboliteElement::mpMetabolite
private

A pointer to the current metabolite.

Definition at line 1293 of file CCopasiXMLParser.h.


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