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

Public Member Functions

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

Private Attributes

std::string mKey
 
ModelParameterElementmpModelParameterElement
 
ModelParameterGroupElementmpModelParameterGroupElement
 

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

Member Enumeration Documentation

Enum of invoked parsers

Enumerator
ModelParameterSet 
MiriamAnnotation 
Comment 
ListOfUnsupportedAnnotations 
Content 

Definition at line 115 of file CCopasiXMLParser.h.

Constructor & Destructor Documentation

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

Destructor

Definition at line 159 of file ListOfModelParameterSets.cpp.

References pdelete.

160 {
163 }
#define pdelete(p)
Definition: copasi.h:215
ModelParameterGroupElement * mpModelParameterGroupElement

Member Function Documentation

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

End element handler

Parameters
constXML_Char *pszName

Definition at line 275 of file ListOfModelParameterSets.cpp.

References SCopasiXMLParserCommon::CharacterData, CCopasiMessage::EXCEPTION, CModelParameterSet::getKey(), CCopasiXMLParser::mCommon, MCXML, SCopasiXMLParserCommon::ModelParameterGroupStack, CExpatTemplate< CExpat >::mParser, SCopasiXMLParserCommon::pCurrentModelParameter, CAnnotation::setMiriamAnnotation(), START_ELEMENT, and UNKNOWN_ELEMENT.

276 {
277  switch (mCurrentElement)
278  {
279  case ModelParameterSet:
280 
281  if (strcmp(pszName, "ModelParameterSet"))
283  pszName, "ModelParameterSet", mParser.getCurrentLineNumber());
284 
286 
289 
290  /* Tell the parent element we are done. */
291  mParser.onEndElement(pszName);
292  break;
293 
294  case MiriamAnnotation:
295 
296  if (strcmp(pszName, "MiriamAnnotation"))
298  pszName, "MiriamAnnotation", mParser.getCurrentLineNumber());
299 
300  {
301  CModelParameterSet * pModelParameterSet = static_cast< CModelParameterSet * >(mCommon.ModelParameterGroupStack.top());
302  pModelParameterSet->setMiriamAnnotation(mCommon.CharacterData, pModelParameterSet->getKey(), mKey);
303  }
304 
305  mCommon.CharacterData = "";
306  break;
307 
308  case Comment:
309 
310  if (strcmp(pszName, "Comment"))
312  pszName, "Comment", mParser.getCurrentLineNumber());
313 
314  static_cast< CModelParameterSet * >(mCommon.ModelParameterGroupStack.top())->setNotes(mCommon.CharacterData);
315  mCommon.CharacterData = "";
316  break;
317 
319 
320  if (strcmp(pszName, "ListOfUnsupportedAnnotations"))
322  pszName, "ListOfUnsupportedAnnotations", mParser.getCurrentLineNumber());
323 
324  static_cast< CModelParameterSet * >(mCommon.ModelParameterGroupStack.top())->getUnsupportedAnnotations() =
326 
327  break;
328 
329  case Content:
330 
331  if (strcmp(pszName, "ModelParameterGroup") &&
332  strcmp(pszName, "ModelParameter"))
333  {
335  pszName, "ModelParameterGroup or ModelParameter", mParser.getCurrentLineNumber());
336  }
337 
338  if (mCommon.pCurrentModelParameter != NULL)
339  {
342  }
343 
344  // Content may be repeated therefore we set to the previous element which is ListOfUnkownAnnotations.
346  break;
347 
348  case UNKNOWN_ELEMENT:
350  break;
351 
352  default:
354  pszName, "???", mParser.getCurrentLineNumber());
355  break;
356  }
357 
358  return;
359 }
#define MCXML
const CAnnotation::UnsupportedAnnotation & getUnsupportedAnnotations() const
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
#define START_ELEMENT
std::stack< CModelParameterGroup * > ModelParameterGroupStack
ListOfUnsupportedAnnotationsElement mListOfUnsupportedAnnotationsElement
int getCurrentLineNumber() const
Definition: CExpat.h:470
CModelParameter * pCurrentModelParameter
void CCopasiXMLParser::ModelParameterSetElement::start ( const XML_Char *  pszName,
const XML_Char **  papszAttrs 
)
virtual

Start element handler

Parameters
constXML_Char *pszName
constXML_Char **papszAttrs

Definition at line 165 of file ListOfModelParameterSets.cpp.

References CCopasiVectorN< CType >::add(), CKeyFactory::addFix(), CCopasiMessage::EXCEPTION, CModel::getModelParameterSets(), SCopasiXMLParserCommon::KeyMap, CCopasiXMLParser::mCommon, MCXML, SCopasiXMLParserCommon::ModelParameterGroupStack, CExpatTemplate< CExpat >::mParser, SCopasiXMLParserCommon::pModel, CCopasiObject::setObjectName(), and UNKNOWN_ELEMENT.

167 {
168  const char * Name;
169 
170  mpCurrentHandler = NULL;
172 
173  while (mpCurrentHandler == NULL)
174  {
175  mCurrentElement++; /* We should always be on the next element */
176 
177  switch (mCurrentElement)
178  {
179  case ModelParameterSet:
180 
181  if (strcmp(pszName, "ModelParameterSet"))
183  pszName, "ModelParameterSet", mParser.getCurrentLineNumber());
184 
186 
187  // Element specific code.
188  mKey = mParser.getAttributeValue("key", papszAttrs);
189  Name = mParser.getAttributeValue("name", papszAttrs);
190 
191  {
192  CModelParameterSet * pModelParameterSet = new CModelParameterSet(Name);
193  int index = 1;
194 
195  // We need to resolve naming conflicts.
196  while (!mCommon.pModel->getModelParameterSets().add(pModelParameterSet, true))
197  {
198  std::ostringstream NewName;
199  NewName << Name << "[" << index++ << "]";
200  pModelParameterSet->setObjectName(NewName.str());
201  }
202 
203  mCommon.ModelParameterGroupStack.push(pModelParameterSet);
204  mCommon.KeyMap.addFix(mKey, pModelParameterSet);
205  }
206  return;
207 
208  case MiriamAnnotation:
209 
210  if (!strcmp(pszName, "MiriamAnnotation"))
211  {
213  mLastKnownElement = mCurrentElement;
214  }
215 
216  break;
217 
218  case Comment:
219 
220  if (!strcmp(pszName, "Comment"))
221  {
223  mLastKnownElement = mCurrentElement;
224  }
225 
226  break;
227 
229 
230  if (!strcmp(pszName, "ListOfUnsupportedAnnotations"))
232 
233  break;
234 
235  case Content:
236 
237  if (!strcmp(pszName, "ModelParameterGroup"))
238  {
239  /* If we do not have an etc element handler we create one. */
242 
244  }
245  else if (!strcmp(pszName, "ModelParameter"))
246  {
247  /* If we do not have an etc element handler we create one. */
250 
252  }
253 
254  break;
255 
256  default:
259  break;
260  }
261  }
262 
264 
266  {
267  mLastKnownElement = mCurrentElement;
268  }
269 
270  mParser.onStartElement(pszName, papszAttrs);
271 
272  return;
273 }
UnknownElement mUnknownElement
const char * getAttributeValue(const std::string &name, const char **attributes, const bool &required=true) const
Definition: CExpat.h:685
#define MCXML
#define UNKNOWN_ELEMENT
bool addFix(const std::string &key, CCopasiObject *pObject)
virtual void onStartElement(const XML_Char *pszName, const XML_Char **papszAttrs)
virtual bool add(const CType &src)
ModelParameterGroupElement * mpModelParameterGroupElement
void pushElementHandler(CXMLElementHandler< CCopasiXMLParser, SCopasiXMLParserCommon > *elementHandler)
const CCopasiVectorN< CModelParameterSet > & getModelParameterSets() const
Definition: CModel.cpp:1066
std::stack< CModelParameterGroup * > ModelParameterGroupStack
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::ModelParameterSetElement::mKey
private

The key as provided in the XML

Definition at line 155 of file CCopasiXMLParser.h.

ModelParameterElement* CCopasiXMLParser::ModelParameterSetElement::mpModelParameterElement
private

A pointer to the ModelParameter element handler

Definition at line 165 of file CCopasiXMLParser.h.

ModelParameterGroupElement* CCopasiXMLParser::ModelParameterSetElement::mpModelParameterGroupElement
private

A pointer to the ModelParameterGroup element handler

Definition at line 160 of file CCopasiXMLParser.h.


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