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

Public Member Functions

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

Private Attributes

std::string mKey
 
CCompartmentmpCompartment
 

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

Member Enumeration Documentation

Constructor & Destructor Documentation

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

Destructor

Definition at line 2242 of file CCopasiXMLParser.cpp.

2243 {}

Member Function Documentation

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

End element handler

Parameters
constXML_Char *pszName

Definition at line 2339 of file CCopasiXMLParser.cpp.

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

2340 {
2341  switch (mCurrentElement)
2342  {
2343  case Compartment:
2344 
2345  if (strcmp(pszName, "Compartment"))
2347  pszName, "Compartment", mParser.getCurrentLineNumber());
2348 
2351 
2352  /* Tell the parent element we are done. */
2353  mParser.onEndElement(pszName);
2354  break;
2355 
2356  case MiriamAnnotation:
2357 
2358  if (strcmp(pszName, "MiriamAnnotation"))
2360  pszName, "MiriamAnnotation", mParser.getCurrentLineNumber());
2361 
2363  mCommon.CharacterData = "";
2364  break;
2365 
2366  case Comment:
2367 
2368  if (strcmp(pszName, "Comment"))
2370  pszName, "Comment", mParser.getCurrentLineNumber());
2371 
2373  mCommon.CharacterData = "";
2374  break;
2375 
2377 
2378  if (strcmp(pszName, "ListOfUnsupportedAnnotations"))
2380  pszName, "ListOfUnsupportedAnnotations", mParser.getCurrentLineNumber());
2381 
2383 
2384  break;
2385 
2386  case Expression:
2387 
2388  if (strcmp(pszName, "Expression"))
2390  pszName, "Expression", mParser.getCurrentLineNumber());
2391 
2392  {
2393  size_t Size = CCopasiMessage::size();
2394 
2396 
2397  // Remove error messages created by setExpression as this may fail
2398  // due to incomplete model specification at this time.
2399  while (CCopasiMessage::size() > Size)
2401  }
2402  break;
2403 
2404  case InitialExpression:
2405 
2406  if (strcmp(pszName, "InitialExpression"))
2408  pszName, "InitialExpression", mParser.getCurrentLineNumber());
2409 
2410  {
2411  size_t Size = CCopasiMessage::size();
2412 
2414 
2415  // Remove error messages created by setExpression as this may fail
2416  // due to incomplete model specification at this time.
2417  while (CCopasiMessage::size() > Size)
2419  }
2420 
2421  break;
2422 
2423  case UNKNOWN_ELEMENT:
2424  break;
2425 
2426  default:
2428  pszName, "???", mParser.getCurrentLineNumber());
2429  break;
2430  }
2431 
2433  return;
2434 }
#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::CompartmentElement::start ( const XML_Char *  pszName,
const XML_Char **  papszAttrs 
)
virtual

Start element handler

Parameters
constXML_Char *pszName
constXML_Char **papszAttrs

Definition at line 2245 of file CCopasiXMLParser.cpp.

References CCopasiVectorN< CType >::add(), CCopasiMessage::EXCEPTION, CModelEntity::FIXED, CModel::getCompartments(), CCopasiXMLParser::mCommon, MCXML, CExpatTemplate< CExpat >::mParser, SCopasiXMLParserCommon::pModel, strToUnsignedInt(), toEnum(), UNKNOWN_ELEMENT, and CModelEntity::XMLStatus.

2247 {
2248  const char * Name;
2249  const char * simulationType;
2250  const char * Dimensionality;
2251  CModelEntity::Status SimulationType;
2252 
2253  mpCurrentHandler = NULL;
2255 
2256  while (mpCurrentHandler == NULL)
2257  {
2258  mCurrentElement++; /* We should always be on the next element */
2259 
2260  switch (mCurrentElement)
2261  {
2262  case Compartment:
2263 
2264  if (strcmp(pszName, "Compartment"))
2266  pszName, "Compartment", mParser.getCurrentLineNumber());
2267 
2268  mKey = mParser.getAttributeValue("key", papszAttrs);
2269  Name = mParser.getAttributeValue("name", papszAttrs);
2270  simulationType = mParser.getAttributeValue("simulationType", papszAttrs, "fixed");
2271  SimulationType = toEnum(simulationType, CModelEntity::XMLStatus, CModel::FIXED);
2272  Dimensionality = mParser.getAttributeValue("dimensionality", papszAttrs, "3");
2273 
2274  mpCompartment = new CCompartment();
2275  addFix(mKey, mpCompartment);
2276 
2278  mpCompartment->setStatus(SimulationType);
2280 
2283  return;
2284 
2285  case MiriamAnnotation:
2286 
2287  if (!strcmp(pszName, "MiriamAnnotation"))
2289 
2290  break;
2291 
2292  case Comment:
2293 
2294  if (!strcmp(pszName, "Comment"))
2296 
2297  break;
2298 
2300 
2301  if (!strcmp(pszName, "ListOfUnsupportedAnnotations"))
2303 
2304  break;
2305 
2306  case Expression:
2307 
2308  if (!strcmp(pszName, "Expression"))
2310 
2311  break;
2312 
2313  case InitialExpression:
2314 
2315  if (!strcmp(pszName, "InitialExpression"))
2317 
2318  break;
2319 
2320  default:
2323  break;
2324  }
2325  }
2326 
2328 
2330  {
2332  }
2333 
2334  mParser.onStartElement(pszName, papszAttrs);
2335 
2336  return;
2337 }
UnknownElement mUnknownElement
bool setDimensionality(unsigned C_INT32 dim)
const char * getAttributeValue(const std::string &name, const char **attributes, const bool &required=true) const
Definition: CExpat.h:685
#define MCXML
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)
virtual bool add(const CType &src)
virtual void setStatus(const CModelEntity::Status &status)
void pushElementHandler(CXMLElementHandler< CCopasiXMLParser, SCopasiXMLParserCommon > *elementHandler)
CharacterDataElement mCharacterDataElement
unsigned C_INT32 strToUnsignedInt(const char *str, char const **pTail)
Definition: utility.cpp:384
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
CCopasiVectorNS< CCompartment > & getCompartments()
Definition: CModel.cpp:1145
ListOfUnsupportedAnnotationsElement mListOfUnsupportedAnnotationsElement
int getCurrentLineNumber() const
Definition: CExpat.h:470
CommentElement mCommentElement
bool setObjectName(const std::string &name)

Member Data Documentation

std::string CCopasiXMLParser::CompartmentElement::mKey
private

The key in the CopasiML file

Definition at line 1397 of file CCopasiXMLParser.h.

CCompartment* CCopasiXMLParser::CompartmentElement::mpCompartment
private

A pointer to the current compartment

Definition at line 1392 of file CCopasiXMLParser.h.


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