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

Public Member Functions

virtual void end (const XML_Char *pszName)
 
 ModelElement (CCopasiXMLParser &parser, SCopasiXMLParserCommon &common)
 
virtual void start (const XML_Char *pszName, const XML_Char **papszAttrs)
 
virtual ~ModelElement ()
 
- 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 {
  Model = 0, MiriamAnnotation, Comment, ListOfUnsupportedAnnotations,
  InitialExpression, ListOfCompartments, ListOfMetabolites, ListOfModelValues,
  ListOfReactions, ListOfEvents, ListOfModelParameterSets, StateTemplate,
  InitialState
}
 

Private Attributes

std::string mKey
 

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

Member Enumeration Documentation

Enum of invoked parsers

Enumerator
Model 
MiriamAnnotation 
Comment 
ListOfUnsupportedAnnotations 
InitialExpression 
ListOfCompartments 
ListOfMetabolites 
ListOfModelValues 
ListOfReactions 
ListOfEvents 
ListOfModelParameterSets 
StateTemplate 
InitialState 

Definition at line 1809 of file CCopasiXMLParser.h.

Constructor & Destructor Documentation

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

Destructor

Definition at line 1613 of file CCopasiXMLParser.cpp.

Member Function Documentation

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

End element handler

Parameters
constXML_Char *pszName

Definition at line 1834 of file CCopasiXMLParser.cpp.

References SCopasiXMLParserCommon::CharacterData, CCopasiMessage::EXCEPTION, CModel::getKey(), CCopasiMessage::getLastMessage(), CAnnotation::getUnsupportedAnnotations(), CCopasiXMLParser::mCommon, MCXML, CExpatTemplate< CExpat >::mParser, SCopasiXMLParserCommon::pModel, CModel::setCompileFlag(), CModelEntity::setInitialExpression(), CAnnotation::setMiriamAnnotation(), CAnnotation::setNotes(), CCopasiMessage::size(), START_ELEMENT, and UNKNOWN_ELEMENT.

1835 {
1836  switch (mCurrentElement)
1837  {
1838  case Model:
1839 
1840  if (strcmp(pszName, "Model"))
1842  pszName, "Model", mParser.getCurrentLineNumber());
1843 
1844  mCommon.pModel->setCompileFlag(true);
1845 
1848 
1849  /* Tell the parent element we are done. */
1850  mParser.onEndElement(pszName);
1851  break;
1852 
1853  case MiriamAnnotation:
1854 
1855  if (strcmp(pszName, "MiriamAnnotation"))
1857  pszName, "MiriamAnnotation", mParser.getCurrentLineNumber());
1858 
1860  mCommon.CharacterData = "";
1861  break;
1862 
1863  case Comment:
1864 
1865  if (strcmp(pszName, "Comment"))
1867  pszName, "Comment", mParser.getCurrentLineNumber());
1868 
1870  mCommon.CharacterData = "";
1871  break;
1872 
1874 
1875  if (strcmp(pszName, "ListOfUnsupportedAnnotations"))
1877  pszName, "ListOfUnsupportedAnnotations", mParser.getCurrentLineNumber());
1878 
1880  break;
1881 
1882  case InitialExpression:
1883 
1884  if (strcmp(pszName, "InitialExpression"))
1886  pszName, "InitialExpression", mParser.getCurrentLineNumber());
1887 
1888  {
1889  size_t Size = CCopasiMessage::size();
1890 
1892 
1893  // Remove error messages created by setExpression as this may fail
1894  // due to incomplete model specification at this time.
1895  while (CCopasiMessage::size() > Size)
1897  }
1898 
1899  // Old CopasiML files have the incorrect order and the comment may appear after
1900  // the initial expression. Therefore, we reset to MiriamAnnotation.
1902  break;
1903 
1904  case ListOfCompartments:
1905 
1906  if (strcmp(pszName, "ListOfCompartments"))
1908  pszName, "ListOfCompartments", mParser.getCurrentLineNumber());
1909 
1911  break;
1912 
1913  case ListOfMetabolites:
1914 
1915  if (strcmp(pszName, "ListOfMetabolites"))
1917  pszName, "ListOfMetabolites", mParser.getCurrentLineNumber());
1918 
1920  break;
1921 
1922  case ListOfModelValues:
1923 
1924  if (strcmp(pszName, "ListOfModelValues"))
1926  pszName, "ListOfModelValues", mParser.getCurrentLineNumber());
1927 
1929  break;
1930 
1931  case ListOfReactions:
1932 
1933  if (strcmp(pszName, "ListOfReactions"))
1935  pszName, "ListOfReactions", mParser.getCurrentLineNumber());
1936 
1938  break;
1939 
1940  case ListOfEvents:
1941 
1942  if (strcmp(pszName, "ListOfEvents"))
1944  pszName, "ListOfEvents", mParser.getCurrentLineNumber());
1945 
1947  break;
1948 
1950 
1951  if (strcmp(pszName, "ListOfModelParameterSets"))
1953  pszName, "ListOfModelParameterSets", mParser.getCurrentLineNumber());
1954 
1956  mCurrentElement = Model; // This is possibly the last element.
1957  break;
1958 
1959  case StateTemplate:
1960 
1961  if (strcmp(pszName, "StateTemplate"))
1963  pszName, "StateTemplate", mParser.getCurrentLineNumber());
1964 
1966  break;
1967 
1968  case InitialState:
1969 
1970  if (strcmp(pszName, "InitialState"))
1972  pszName, "InitialState", mParser.getCurrentLineNumber());
1973 
1975  mCurrentElement = Model; // This is possibly the last element.
1976  break;
1977 
1978  case UNKNOWN_ELEMENT:
1980  mCurrentElement = Model; // This is possibly the last element.
1981  break;
1982 
1983  default:
1985  pszName, "???", mParser.getCurrentLineNumber());
1986  break;
1987  }
1988 
1989  return;
1990 }
#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
static size_t size()
const std::string & getKey() const
Definition: CModel.cpp:1142
void setCompileFlag(bool flag=true)
Definition: CModel.cpp:607
static CCopasiMessage getLastMessage()
ListOfUnsupportedAnnotationsElement mListOfUnsupportedAnnotationsElement
UnsupportedAnnotation & getUnsupportedAnnotations()
int getCurrentLineNumber() const
Definition: CExpat.h:470
void CCopasiXMLParser::ModelElement::start ( const XML_Char *  pszName,
const XML_Char **  papszAttrs 
)
virtual

Start element handler

Parameters
constXML_Char *pszName
constXML_Char **papszAttrs

Definition at line 1618 of file CCopasiXMLParser.cpp.

References CModel::AreaUnitNames, C_FLOAT64, CModel::deterministic, CCopasiMessage::EXCEPTION, CModel::getModelParameterSets(), CModel::LengthUnitNames, CModel::m, CModel::m2, CCopasiXMLParser::mCommon, MCXML, CModel::min, CModel::ml, CModel::mMol, CModel::ModelTypeNames, CExpatTemplate< CExpat >::mParser, CModel::OldMinute, CModel::OldXML, SCopasiXMLParserCommon::pDataModel, SCopasiXMLParserCommon::pModel, CModel::QuantityUnitNames, CModel::QuantityUnitOldXMLNames, CModel::s, CModel::setAreaUnit(), CModel::setAvogadro(), CModel::setLengthUnit(), CModel::setModelType(), CCopasiObject::setObjectName(), CModel::setQuantityUnit(), CModel::setTimeUnit(), CModel::setVolumeUnit(), CModel::TimeUnitNames, toEnum(), UNKNOWN_ELEMENT, and CModel::VolumeUnitNames.

1620 {
1621  const char * Name;
1622  const char * timeUnit;
1623  CModel::TimeUnit TimeUnit;
1624  const char * volumeUnit;
1625  CModel::VolumeUnit VolumeUnit;
1626  const char * areaUnit;
1627  CModel::AreaUnit AreaUnit;
1628  const char * lengthUnit;
1629  CModel::LengthUnit LengthUnit;
1630  const char * quantityUnit;
1631  CModel::QuantityUnit QuantityUnit;
1632  CModel::ModelType ModelType;
1633  C_FLOAT64 Avogadro;
1634 
1635  mpCurrentHandler = NULL;
1636  mCurrentElement++; /* We should always be on the next element */
1637 
1638  switch (mCurrentElement)
1639  {
1640  case Model:
1641 
1642  if (strcmp(pszName, "Model"))
1644  pszName, "Model", mParser.getCurrentLineNumber());
1645 
1646  mKey = mParser.getAttributeValue("key", papszAttrs);
1647  Name = mParser.getAttributeValue("name", papszAttrs);
1648 
1649  timeUnit = mParser.getAttributeValue("timeUnit", papszAttrs);
1650  TimeUnit = toEnum(timeUnit, CModel::TimeUnitNames, CModel::OldMinute);
1651 
1652  if (TimeUnit == CModel::OldMinute)
1653  {
1654  if (strcmp(timeUnit, "m"))
1655  TimeUnit = CModel::s;
1656  else
1657  TimeUnit = CModel::min;
1658  }
1659 
1660  volumeUnit = mParser.getAttributeValue("volumeUnit", papszAttrs);
1661  VolumeUnit = toEnum(volumeUnit, CModel::VolumeUnitNames, CModel::ml);
1662 
1663  //the next 2 attributes are introduced in Build 31, they have a default for
1664  //reading older cps files
1665  areaUnit = mParser.getAttributeValue("areaUnit", papszAttrs, "m\xc2\xb2");
1666  AreaUnit = toEnum(areaUnit, CModel::AreaUnitNames, CModel::m2);
1667 
1668  lengthUnit = mParser.getAttributeValue("lengthUnit", papszAttrs, "m");
1669  LengthUnit = toEnum(lengthUnit, CModel::LengthUnitNames, CModel::m);
1670 
1671  quantityUnit = mParser.getAttributeValue("quantityUnit", papszAttrs);
1672  QuantityUnit = toEnum(quantityUnit, CModel::QuantityUnitNames, CModel::OldXML);
1673 
1674  if (QuantityUnit == CModel::OldXML)
1675  QuantityUnit = toEnum(quantityUnit, CModel::QuantityUnitOldXMLNames, CModel::mMol);
1676 
1677  ModelType = toEnum(mParser.getAttributeValue("type", papszAttrs, "deterministic"),
1679 
1680  Avogadro = CCopasiXMLInterface::DBL(mParser.getAttributeValue("avogadroConstant", papszAttrs, "6.0221415e23"));
1681 
1683 
1684  // We remove the default parameter set:
1685  mCommon.pModel->getModelParameterSets().CCopasiVector< CModelParameterSet >::remove((size_t) 0);
1686 
1687  addFix(mKey, mCommon.pModel);
1688  mCommon.pModel->setObjectName(Name);
1689  mCommon.pModel->setTimeUnit(TimeUnit);
1690  mCommon.pModel->setVolumeUnit(VolumeUnit);
1691  mCommon.pModel->setAreaUnit(AreaUnit);
1692  mCommon.pModel->setLengthUnit(LengthUnit);
1693  mCommon.pModel->setQuantityUnit(QuantityUnit);
1694  mCommon.pModel->setModelType(ModelType);
1695  mCommon.pModel->setAvogadro(Avogadro);
1696 
1697  return;
1698  break;
1699 
1700  case MiriamAnnotation:
1701 
1702  if (!strcmp(pszName, "MiriamAnnotation"))
1703  {
1706  }
1707 
1708  break;
1709 
1710  case Comment:
1711 
1712  if (!strcmp(pszName, "Comment"))
1713  {
1716  }
1717 
1718  break;
1719 
1721 
1722  if (!strcmp(pszName, "ListOfUnsupportedAnnotations"))
1723  {
1726  }
1727 
1728  break;
1729 
1730  case InitialExpression:
1731 
1732  if (!strcmp(pszName, "InitialExpression"))
1733  {
1736  }
1737 
1738  break;
1739 
1740  case ListOfCompartments:
1741 
1742  if (!strcmp(pszName, "ListOfCompartments"))
1743  {
1744  mpCurrentHandler = new ListOfCompartmentsElement(mParser, mCommon);
1746  }
1747 
1748  break;
1749 
1750  case ListOfMetabolites:
1751 
1752  if (!strcmp(pszName, "ListOfMetabolites"))
1753  {
1754  mpCurrentHandler = new ListOfMetabolitesElement(mParser, mCommon);
1756  }
1757 
1758  break;
1759 
1760  case ListOfModelValues:
1761 
1762  if (!strcmp(pszName, "ListOfModelValues"))
1763  {
1764  mpCurrentHandler = new ListOfModelValuesElement(mParser, mCommon);
1766  }
1767 
1768  break;
1769 
1770  case ListOfReactions:
1771 
1772  if (!strcmp(pszName, "ListOfReactions"))
1773  {
1774  mpCurrentHandler = new ListOfReactionsElement(mParser, mCommon);
1776  }
1777 
1778  break;
1779 
1780  case ListOfEvents:
1781 
1782  if (!strcmp(pszName, "ListOfEvents"))
1783  {
1784  mpCurrentHandler = new ListOfEventsElement(mParser, mCommon);
1786  }
1787 
1788  break;
1789 
1791 
1792  if (!strcmp(pszName, "ListOfModelParameterSets"))
1793  {
1796  }
1797 
1798  break;
1799 
1800  case StateTemplate:
1801 
1802  if (!strcmp(pszName, "StateTemplate"))
1803  {
1804  mpCurrentHandler = new StateTemplateElement(mParser, mCommon);
1806  }
1807 
1808  break;
1809 
1810  case InitialState:
1811 
1812  if (!strcmp(pszName, "InitialState"))
1813  {
1814  mpCurrentHandler = new InitialStateElement(mParser, mCommon);
1816  }
1817 
1818  break;
1819 
1820  default:
1823  break;
1824  }
1825 
1826  if (mpCurrentHandler)
1828 
1829  mParser.onStartElement(pszName, papszAttrs);
1830 
1831  return;
1832 }
static const char * LengthUnitNames[]
Definition: CModel.h:81
static const char * ModelTypeNames[]
Definition: CModel.h:117
CCopasiDataModel * pDataModel
bool setAreaUnit(const std::string &name)
Definition: CModel.cpp:2182
UnknownElement mUnknownElement
bool setVolumeUnit(const std::string &name)
Definition: CModel.cpp:2159
bool setLengthUnit(const std::string &name)
Definition: CModel.cpp:2204
AreaUnit
Definition: CModel.h:66
bool setTimeUnit(const std::string &name)
Definition: CModel.cpp:2227
const char * getAttributeValue(const std::string &name, const char **attributes, const bool &required=true) const
Definition: CExpat.h:685
#define MCXML
VolumeUnit
Definition: CModel.h:56
void addFix(const std::string &key, CCopasiObject *pObject)
Definition: CXMLHandler.h:119
ModelType
Definition: CModel.h:112
#define UNKNOWN_ELEMENT
LengthUnit
Definition: CModel.h:76
virtual void onStartElement(const XML_Char *pszName, const XML_Char **papszAttrs)
void pushElementHandler(CXMLElementHandler< CCopasiXMLParser, SCopasiXMLParserCommon > *elementHandler)
CharacterDataElement mCharacterDataElement
const CCopasiVectorN< CModelParameterSet > & getModelParameterSets() const
Definition: CModel.cpp:1066
TimeUnit
Definition: CModel.h:86
CType toEnum(const char *attribute, const char **enumNames, const CType &enumDefault)
Definition: utility.h:107
MiriamAnnotationElement mMiriamAnnotationElement
static const char * AreaUnitNames[]
Definition: CModel.h:71
#define C_FLOAT64
Definition: copasi.h:92
ListOfUnsupportedAnnotationsElement mListOfUnsupportedAnnotationsElement
bool setQuantityUnit(const std::string &name)
Definition: CModel.cpp:2250
int getCurrentLineNumber() const
Definition: CExpat.h:470
Definition: CModel.h:50
CommentElement mCommentElement
void setAvogadro(const C_FLOAT64 &avogadro)
Definition: CModel.cpp:2342
static const char * TimeUnitNames[]
Definition: CModel.h:91
bool setObjectName(const std::string &name)
void setModelType(const ModelType &modelType)
Definition: CModel.cpp:2336
static const char * QuantityUnitOldXMLNames[]
Definition: CModel.h:102
static const char * QuantityUnitNames[]
Definition: CModel.h:107
static const char * VolumeUnitNames[]
Definition: CModel.h:61
QuantityUnit
Definition: CModel.h:96

Member Data Documentation

std::string CCopasiXMLParser::ModelElement::mKey
private

The key in the CopasiML file

Definition at line 1829 of file CCopasiXMLParser.h.


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