COPASI API  4.16.103
CMiaseParser.cpp
Go to the documentation of this file.
1 // Begin CVS Header
2 // $Source: /Volumes/Home/Users/shoops/cvs/copasi_dev/copasi/miase/CMiaseParser.cpp,v $
3 // $Revision: 1.14 $
4 // $Name: $
5 // $Author: shoops $
6 // $Date: 2009/10/27 16:52:48 $
7 // End CVS Header
8 
9 // Copyright (C) 2008 by Pedro Mendes, Virginia Tech Intellectual
10 // Properties, Inc., EML Research, gGmbH, University of Heidelberg,
11 // and The University of Manchester.
12 // All rights reserved.
13 
14 #include "CMiaseParser.h"
15 #include "CMiaseBase.h"
16 #include "CMiaseSimulation.h"
17 #include "CMiaseTask.h"
18 #include "CMiaseModel.h"
19 #include "CMiaseOutput.h"
20 #include <vector>
21 
22 //#include "/Users/anton/copasi/copasi_dev/copasi/utilities/utility.cpp"
23 
24 XML_Char CMiaseParser::mVersion_1_0[] = {'1', '.', '0', 0};
25 XML_Char CMiaseParser::mNameSpace[] = "http://www.miase.org/";
26 XML_Char CMiaseParser::mEncoding[] = {'u', 't', 'f', '-', 8};
27 
29 {
30  myParser = this;
31  this->mXmlParser = XML_ParserCreate(NULL);
34  this->mMiase = NULL;
35  this->mContent = "";
36  this->createAllowedStateTags();
37  this->mTmpDepth = 0;
38  this->mDepth = 0;
39 
40  XML_SetXmlDeclHandler(myParser->mXmlParser, myParser->xmldecl_handler);
41  XML_SetElementHandler(myParser->mXmlParser, myParser->start, myParser->end);
42  XML_SetCharacterDataHandler(myParser->mXmlParser, myParser->charhndl);
43 }
44 
46 {
47  XML_ParserFree(myParser->mXmlParser);
48  // delete *myParser;
49 }
50 
52 {
53  std::vector<std::string> tmpAllowedTags;
54  int i;
55 
56  for (i = 0; i <= (int)STATE_STOPPED; i++)
57  {this->mAllowedStateTags.push_back(tmpAllowedTags);}
58 
59  tmpAllowedTags.push_back("Notes");
60  tmpAllowedTags.push_back("Annotation");
61 
62  for (i = (int)STATE_MIASE; i < (int)STATE_LAST; i++)
63  {this->mAllowedStateTags.push_back(tmpAllowedTags);}
64 
65  this->mAllowedStateTags[STATE_READY_TO_READ].push_back("MiaseML");
66 
67  this->mAllowedStateTags[STATE_MIASE].push_back("Sed");
68 
69  this->mAllowedStateTags[STATE_SED].push_back("listOfSimulations");
70  this->mAllowedStateTags[STATE_SED].push_back("listOfModels");
71  this->mAllowedStateTags[STATE_SED].push_back("listOfTasks");
72  this->mAllowedStateTags[STATE_SED].push_back("listOfOutputs");
73 
74  this->mAllowedStateTags[STATE_LIST_OF_SIMULATIONS].push_back("UniformTimeCourse");
75  this->mAllowedStateTags[STATE_LIST_OF_SIMULATIONS].push_back("SteadyStateAnalysis");
76  this->mAllowedStateTags[STATE_LIST_OF_SIMULATIONS].push_back("AnySimulationType");
77 
78  this->mAllowedStateTags[STATE_LIST_OF_MODELS].push_back("Model");
79 
80  this->mAllowedStateTags[STATE_MODEL].push_back("listOfChanges");
81 
82  this->mAllowedStateTags[STATE_LIST_OF_CHANGES].push_back("ChangeAttribute");
83  this->mAllowedStateTags[STATE_LIST_OF_CHANGES].push_back("ChangeMath");
84 
85  this->mAllowedStateTags[STATE_LIST_OF_TASKS].push_back("Task");
86 
87  this->mAllowedStateTags[STATE_TASK].push_back("listOfMeasurement");
88 
89  this->mAllowedStateTags[STATE_LIST_OF_MEASUREMENT].push_back("MeasurementData");
90 
91  this->mAllowedStateTags[STATE_LIST_OF_OUTPUTS].push_back("Output");
92 
93  tmpAllowedTags.clear();
94  this->mAllowedStateTags.push_back(tmpAllowedTags);
95  /*Only for testing
96  int k, l, size;
97  for (k=0;k<=(int)LAST;k++)
98  {
99  size = myParser->mAllowedStateTags[k].size();
100  for (l=0;l<size;l++)
101  {
102  printf("%s\n", this->mAllowedStateTags[k][l].c_str());
103  }
104  printf("\n");
105  } */
106 }
107 
108 void XMLCALL
109 CMiaseParser::charhndl(void *userData, const XML_Char *s, int len)
110 {myParser->newContent(s, len);}
111 
112 void XMLCALL
113 CMiaseParser::start(void *data, const char *el, const char **attr)
114 {myParser->startElement(el, attr);}
115 
116 void XMLCALL
117 CMiaseParser::end(void *data, const char *el)
118 {myParser->endElement(el);}
119 
120 void XMLCALL
121 CMiaseParser::xmldecl_handler(void *userData, const XML_Char *version,
122  const XML_Char *encoding, int standalone)
123 {myParser->xmlDecl(version, encoding);}
124 
125 void CMiaseParser::newContent(const XML_Char *s, int len)
126 {
127  std::string tmpContent;
128 
129  if ((myParser->mActState == STATE_NOTES)
132  {
133  tmpContent = s;
134  tmpContent = tmpContent.substr(0, len);
135  myParser->mContent += tmpContent;
136  }
137 }
138 
139 void CMiaseParser::newNotes(const char **attr)
140 {
141  int i;
142  myParser->mContent = "";
143  myParser->mTmpDepth = 0;
144  CMiaseBase * tmpMiaseObj;
145 
147 
148  for (i = 0; attr[i]; i += 2)
149  {
150  if (strcmp(attr[i], "xmlns") == 0)
151  {newNotes->setXmlNs(attr[i + 1]);}
152  }
153 
154  switch (myParser->mActState)
155  {
156  case STATE_MIASE:
157  myParser->mMiase->addNotes(newNotes);
158  break;
159  case STATE_SED:
160  myParser->mMiase->getSed()->addNotes(newNotes);
161  break;
163  tmpMiaseObj = myParser->mMiase->getSed()->getLastSimulation();
164 
165  if (tmpMiaseObj != NULL)
166  {tmpMiaseObj->addNotes(new CMiaseNotes());}
167  else
168  {myParser->error("invalid Notes before Change");}
169 
170  break;
171  case STATE_MODEL:
172  myParser->mMiase->getSed()->getLastModel()->addNotes(newNotes);
173  break;
175  tmpMiaseObj = myParser->mMiase->getSed()->getLastModel()->getLastChange();
176 
177  if (tmpMiaseObj != NULL)
178  {tmpMiaseObj->addNotes(newNotes);}
179  else
180  {myParser->error("invalid Notes before Change");}
181 
182  break;
183  case STATE_TASK:
184  myParser->mMiase->getSed()->getLastTask()->addNotes(newNotes);
185  break;
187  tmpMiaseObj = myParser->mMiase->getSed()->getLastTask()->getLastMeasurement();
188 
189  if (tmpMiaseObj != NULL)
190  {tmpMiaseObj->addNotes(newNotes);}
191  else
192  {myParser->error("invalid Notes before Measurement");}
193 
194  break;
195  case STATE_OUTPUT:
196  myParser->mMiase->getSed()->getLastOutput()->addNotes(newNotes);
197  break;
198  default:
199  break;
200  }
201 
203 }
204 
205 void CMiaseParser::newAnnotation(const char **attr)
206 {
207  int i;
208  myParser->mContent = "";
209  myParser->mTmpDepth = 0;
210  CMiaseBase * tmpMiaseObj;
211 
213 
214  for (i = 0; attr[i]; i += 2)
215  {
216  if (strcmp(attr[i], "xmlns") == 0)
217  {newAnnotation->setXmlNs(attr[i + 1]);}
218  }
219 
220  switch (myParser->mActState)
221  {
222  case STATE_MIASE:
223  myParser->mMiase->addAnnotation(newAnnotation);
224  break;
225  case STATE_SED:
226  myParser->mMiase->getSed()->addAnnotation(newAnnotation);
227  break;
229  tmpMiaseObj = myParser->mMiase->getSed()->getLastSimulation();
230 
231  if (tmpMiaseObj != NULL)
232  {tmpMiaseObj->addAnnotation(newAnnotation);}
233  else
234  {myParser->error("invalid Annotation before Change");}
235 
236  break;
237  case STATE_MODEL:
238  myParser->mMiase->getSed()->getLastModel()->addAnnotation(newAnnotation);
239  break;
241  tmpMiaseObj = myParser->mMiase->getSed()->getLastModel()->getLastChange();
242 
243  if (tmpMiaseObj != NULL)
244  {tmpMiaseObj->addAnnotation(newAnnotation);}
245  else
246  {myParser->error("invalid Annotation before Change");}
247 
248  break;
249  case STATE_TASK:
250  myParser->mMiase->getSed()->getLastTask()->addAnnotation(newAnnotation);
251  break;
253  tmpMiaseObj = myParser->mMiase->getSed()->getLastTask()->getLastMeasurement();
254 
255  if (tmpMiaseObj != NULL)
256  {tmpMiaseObj->addAnnotation(newAnnotation);}
257  else
258  {myParser->error("invalid Annotation before Measurement");}
259 
260  break;
261  case STATE_OUTPUT:
262  myParser->mMiase->getSed()->getLastOutput()->addAnnotation(newAnnotation);
263  break;
264  default:
265  break;
266  }
267 
269 }
270 
271 void CMiaseParser::newModel(const char **attr)
272 {
273  int i;
275 
277 
278  for (i = 0; attr[i]; i += 2)
279  {
280  if (strcmp(attr[i], "id") == 0)
281  {myParser->mMiase->getSed()->getLastModel()->setId(attr[i + 1]);}
282  else if (strcmp(attr[i], "name") == 0)
283  {myParser->mMiase->getSed()->getLastModel()->setName(attr[i + 1]);}
284  else if (strcmp(attr[i], "type") == 0)
285  {myParser->mMiase->getSed()->getLastModel()->setType(attr[i + 1]);}
286  else if (strcmp(attr[i], "source") == 0)
287  {myParser->mMiase->getSed()->getLastModel()->setSource(attr[i + 1]);}
288  }
289 }
290 
291 void CMiaseParser::newSimulation(const char *el, const char **attr)
292 {
293  int i;
294 
295  if (strcmp(el, "UniformTimeCourse") == 0)
296  {
298 
299  for (i = 0; attr[i]; i += 2)
300  {
301  if (strcmp(attr[i], "id") == 0)
302  {
304  ->getLastSimulation())->setId(attr[i + 1]);
305  }
306  else if (strcmp(attr[i], "name") == 0)
307  {
309  ->getLastSimulation())->setName(attr[i + 1]);
310  }
311  else if (strcmp(attr[i], "initialTime") == 0)
312  {
314  ->getLastSimulation())->setInitialTime(strToDouble(attr[i + 1], 0));
315  }
316  else if (strcmp(attr[i], "outputStartTime") == 0)
317  {
319  ->getLastSimulation())->setOutputStartTime(strToDouble(attr[i + 1], 0));
320  }
321  else if (strcmp(attr[i], "outputEndTime") == 0)
322  {
324  ->getLastSimulation())->setOutputEndTime(strToDouble(attr[i + 1], 0));
325  }
326  else if (strcmp(attr[i], "numberOfPoints") == 0)
327  {
329  ->getLastSimulation())->setNumberOfPoints(strToDouble(attr[i + 1], 0));
330  }
331  }
332  }
333  else if (strcmp(el, "SteadyStateAnalysis") == 0)
334  {
335  //TODO
336  }
337  else if (strcmp(el, "AnySimulationType") == 0)
338  {
339  //TODO
340  }
341 }
342 
343 void CMiaseParser::newChange(const char *el, const char **attr)
344 {
345  int i;
346 
347  if (strcmp(el, "ChangeAttribute") == 0)
348  {
351 
352  for (i = 0; attr[i]; i += 2)
353  {
354  if (strcmp(attr[i], "newValue") == 0)
355  {
357  ->getLastChange())->setNewValue(attr[i + 1]);
358  }
359  else if (strcmp(attr[i], "target") == 0)
360  {
362  ->getLastChange())->setTarget(attr[i + 1]);
363  }
364  }
365  }
366  else if (strcmp(el, "ChangeMath") == 0)
367  {
369  ->addChange(new CMiaseChangeMath());
370 
371  for (i = 0; attr[i]; i += 2)
372  {
373  if (strcmp(attr[i], "newMath") == 0)
374  {
376  ->getLastChange())->setNewMath(attr[i + 1]);
377  }
378  else if (strcmp(attr[i], "target") == 0)
379  {
381  ->getLastChange())->setTarget(attr[i + 1]);
382  }
383  }
384  }
385 }
386 
387 void CMiaseParser::newTask(const char **attr)
388 {
389  int i;
391 
393 
394  for (i = 0; attr[i]; i += 2)
395  {
396  if (strcmp(attr[i], "id") == 0)
397  {
398  myParser->mMiase->getSed()->getLastTask()->setId(attr[i + 1]);
399  }
400  else if (strcmp(attr[i], "name") == 0)
401  {
402  myParser->mMiase->getSed()->getLastTask()->setName(attr[i + 1]);
403  }
404  else if (strcmp(attr[i], "modelReference") == 0)
405  {
407  attr[i + 1]);
408  }
409  else if (strcmp(attr[i], "simulationReference") == 0)
410  {
412  attr[i + 1]);
413  }
414  }
415 }
416 
417 void CMiaseParser::newMeasurementData(const char **attr)
418 {
419  int i;
422 
423  for (i = 0; attr[i]; i += 2)
424  {
425  if (strcmp(attr[i], "name") == 0)
426  {
428  ->getLastMeasurement()->setName(attr[i + 1]);
429  }
430  else if (strcmp(attr[i], "source") == 0)
431  {
433  ->getLastMeasurement()->setSource(attr[i + 1]);
434  }
435  }
436 }
437 
438 void CMiaseParser::newOutput(const char **attr)
439 {
440  myParser->mContent = "";
441  myParser->mTmpDepth = 0;
442  int i;
444 
446 
447  for (i = 0; attr[i]; i += 2)
448  {
449  if (strcmp(attr[i], "id") == 0)
450  {myParser->mMiase->getSed()->getLastOutput()->setId(attr[i + 1]);}
451  else if (strcmp(attr[i], "name") == 0)
452  {myParser->mMiase->getSed()->getLastOutput()->setName(attr[i + 1]);}
453  }
454 }
455 
456 void CMiaseParser::newMiase(const char **attr)
457 {
458  int i;
460 
461  myParser->mMiase = new CMiaseML();
462 
463  for (i = 0; attr[i]; i += 2)
464  {
465  if (strcmp(attr[i], "xmlns") == 0)
466  {myParser->mMiase->setXmlns(attr[i + 1]);}
467  else if (strcmp(attr[i], "version") == 0)
468  {myParser->mMiase->setVersion(attr[i + 1]);}
469  }
470 }
471 
472 void CMiaseParser::startElement(const char *el, const char **attr)
473 {
474  if (myParser->isValid(el))
475  {
476  if ((strcmp(el, "Notes") == 0) && (myParser->mActState != STATE_NOTES))
477  {myParser->newNotes(attr);}
478  else if ((strcmp(el, "Annotation") == 0)
480  {myParser->newAnnotation(attr);}
481  else
482  {
483  switch (myParser->mActState)
484  {
486 
487  if (strcmp(el, "Model") == 0)
488  {myParser->newModel(attr);}
489 
490  break;
491  case STATE_MODEL:
492 
493  if (strcmp(el, "listOfChanges") == 0)
495 
496  break;
498 
499  if ((strcmp(el, "ChangeAttribute") == 0)
500  || (strcmp(el, "ChangeMath") == 0))
501  {myParser->newChange(el, attr);}
502 
503  break;
505 
506  if ((strcmp(el, "UniformTimeCourse") == 0)
507  || (strcmp(el, "SteadyStateAnalysis") == 0)
508  || (strcmp(el, "AnySimulationType") == 0))
509  {myParser->newSimulation(el, attr);}
510 
511  break;
512  case STATE_LIST_OF_TASKS:
513 
514  if (strcmp(el, "Task") == 0)
515  {myParser->newTask(attr);}
516 
517  break;
518  case STATE_TASK:
519 
520  if (strcmp(el, "listOfMeasurement") == 0)
522 
523  break;
525 
526  if (strcmp(el, "MeasurementData") == 0)
527  {myParser->newMeasurementData(attr);}
528 
529  break;
531 
532  if (strcmp(el, "Output") == 0)
533  {myParser->newOutput(attr);}
534 
535  break;
536  case STATE_SED:
537 
538  if (strcmp(el, "listOfSimulations") == 0)
540  else if (strcmp(el, "listOfOutputs") == 0)
542  else if (strcmp(el, "listOfTasks") == 0)
544  else if (strcmp(el, "listOfModels") == 0)
546 
547  break;
548  case STATE_MIASE:
549 
550  if (strcmp(el, "Sed") == 0)
551  {
554  }
555 
556  break;
557  case STATE_READY_TO_READ:
558 
559  if (strcmp(el, "MiaseML") == 0)
560  {myParser->newMiase(attr);}
561 
562  break;
563  case STATE_NOTES:
564  myParser->addContent(el, attr);
565  break;
566  case STATE_ANNOTATION:
567  myParser->addContent(el, attr);
568  break;
569  case STATE_OUTPUT:
570  myParser->addContent(el, attr);
571  break;
572  default:
573  break;
574  }
575  }
576 
577  /* int i;
578  for (i = 0; i < myParser->mDepth; i++)
579  printf(" ");
580 
581  printf("%s", el);
582  for (i = 0; attr[i]; i += 2)
583  printf(" %s='%s'", attr[i], attr[i + 1]);
584 
585  printf("\n");
586  */
587  }
588 
589  myParser->mDepth++;
590  myParser->mTmpDepth++;
591 }
592 
593 void CMiaseParser::addContent(const char *el, const char **attr)
594 {
595  //myParser->mContent += "\n";
596  int i;
597 
598  for (i = 0; i < myParser->mTmpDepth; i++)
599  myParser->mContent += " ";
600 
601  myParser->mContent += "<";
602  myParser->mContent += el /*c_str()*/;
603 
604  for (i = 0; attr[i]; i += 2)
605  {
606  myParser->mContent += " "; // + attr[i] + " " + attr[i + 1];
607  myParser->mContent += attr[i];
608  myParser->mContent += " ";
609  myParser->mContent += attr[i + 1];
610  }
611 
612  myParser->mContent += ">\n";
613 }
614 
615 void CMiaseParser::endElement(const char *el)
616 {
617  int i;
618  CMiaseBase *tmpObj;
619 
620  myParser->mDepth--;
621  myParser->mTmpDepth--;
622 
623  if ((strcmp(el, "Notes") == 0) && (myParser->mTmpDepth == 0))
624  {
625  tmpObj = myParser->getLastObj();
626  tmpObj->getNotes()->setNotes(myParser->mContent);
628  }
629  else if (((myParser->mActState == STATE_NOTES)
632  && (myParser->mTmpDepth != 0))
633  {
634  for (i = 0; i < myParser->mTmpDepth; i++)
635  myParser->mContent += " ";
636 
637  myParser->mContent += "</";
638  myParser->mContent += el;
639  myParser->mContent += ">\n";
640  }
641  else if ((strcmp(el, "Annotation") == 0) && (myParser->mTmpDepth == 0))
642  {
643  tmpObj = myParser->getLastObj();
646  }
647  else if (strcmp(el, "Model") == 0)
649  else if (strcmp(el, "listOfChanges") == 0)
651  else if (strcmp(el, "listOfMeasurement") == 0)
653  else if ((strcmp(el, "listOfSimulations") == 0)
654  || (strcmp(el, "listOfTasks") == 0)
655  || (strcmp(el, "listOfModels") == 0)
656  || (strcmp(el, "listOfOutputs") == 0))
658  else if (strcmp(el, "Task") == 0)
660  else if (strcmp(el, "Output") == 0)
661  {
663 
664  //TODO: addContent to Output
666  }
667  else if ((strcmp(el, "Sed") == 0) || (strcmp(el, "Miase") == 0))
669 }
670 
672 {
673  switch (myParser->mLastState)
674  {
675  case STATE_OUTPUT:
676  return myParser->mMiase->getSed()->getLastOutput();
677  break;
680  break;
681  case STATE_TASK:
682  return myParser->mMiase->getSed()->getLastTask();
683  break;
686  break;
687  case STATE_MODEL:
688  return myParser->mMiase->getSed()->getLastModel();
689  break;
691  return myParser->mMiase->getSed()->getLastSimulation();
692  break;
693  case STATE_SED:
694  return myParser->mMiase->getSed();
695  break;
696  case STATE_MIASE:
697  return myParser->mMiase;
698  break;
699  default:
700  break;
701  }
702 
703  myParser->error("Last Obj is NULL");
704  return NULL;
705 }
706 
708 {
709  //myParser->mContent = "";
712 }
713 
714 void CMiaseParser::xmlDecl(const XML_Char *version,
715  const XML_Char *encoding)
716 {
717 
718  unsigned int i;
719 
720  for (i = 0; i < (sizeof(myParser->mVersion_1_0) /
721  sizeof(myParser->mVersion_1_0[0])); ++i)
722  {
723  if (version[i] != myParser->mVersion_1_0[i])
724  {
725  XML_StopParser(myParser->mXmlParser, false);
726  fprintf(stderr, "Read error\n");
727  }
728  }
729 
730  for (i = 0; i < std::min(sizeof(myParser->mEncoding), sizeof(encoding)); i++)
731  {
732  if (encoding[i] != myParser->mEncoding[i])
733  {
734  XML_StopParser(myParser->mXmlParser, false);
735  fprintf(stderr, "Read error\n");
736  }
737  }
738 }
739 
740 void CMiaseParser::load(std::string filename)
741 {
742  FILE * file = fopen(filename.c_str(), "r");
743 
744  if (! myParser->mXmlParser)
745  {
746  fprintf(stderr, "Couldn't allocate memory for parser\n");
747  exit(-1);
748  }
749 
750  for (;;)
751  {
752 
753  int done;
754  int len;
755 
756  len = (int)fread(myParser->mBuff, 1, BUFFSIZE, file);
757 
758  if (ferror(file))
759  {
760  fprintf(stderr, "Read error\n");
761  exit(-1);
762  }
763 
764  done = feof(file);
765 
766  if (XML_Parse(myParser->mXmlParser, myParser->mBuff, len, done)
767  == XML_STATUS_ERROR)
768  {
769  fprintf(stderr, "Parse error at line %" XML_FMT_INT_MOD "u:\n%s\n",
770  XML_GetCurrentLineNumber(myParser->mXmlParser),
771  XML_ErrorString(XML_GetErrorCode(myParser->mXmlParser)));
772  exit(-1);
773  }
774 
775  if (done)
776  break;
777  }
778 
779  XML_ParserFree(myParser->mXmlParser);
780 }
781 
782 void CMiaseParser::error(std::string errorString)
783 {
785 }
786 
787 bool CMiaseParser::isValid(const char *el)
788 {
789  unsigned int i;
790 
794  {return true;}
795  else if (myParser->mActState == STATE_STOPPED)
796  {
797  myParser->error("PARSE ERROR");
798  return false;
799  }
800 
801  std::vector<std::string> tmpAllowedStateTags =
803 
804  for (i = 0; i < tmpAllowedStateTags.size(); i++)
805  {
806  if (strcmp(el, tmpAllowedStateTags[i].c_str()) == 0)
807  {return true;}
808  }
809 
810  myParser->error("PARSE ERROR");
811  return false;
812 }
813 
815 {
816  int i;
817  int j;
818  //testing whether structure was loaded
819  std::cout << "-------------------------DataStructure------------------------------- " << std::endl << std::endl << std::endl;
820 
821  if (myParser->mMiase)
822  {
823  std::cout <<
824  myParser->mMiase->getSed()->getNotes()->getNotes() << std::endl;
825 
826  if (myParser->mMiase->getSed()->getNumOfSimulations() > 0)
827  {
828  std::cout << "NumOfSimulations: " <<
829  myParser->mMiase->getSed()->getNumOfSimulations() << std::endl << std::endl;
830 
831  for (i = 0 ; i < myParser->mMiase->getSed()->getNumOfSimulations() ; i++)
832  {
833  std::cout << " Simulation nr. :" << i << std::endl;
834 
835  std::cout << " id: " <<
836  ((CMiaseUniformTimeCourse*)myParser->mMiase->getSed()->getSimulation(i))->getId() << std::endl;
837  std::cout << " name: " <<
838  ((CMiaseUniformTimeCourse*)myParser->mMiase->getSed()->getSimulation(i))->getName() << std::endl;
839 
840  std::cout << " InitialTime: " <<
841  ((CMiaseUniformTimeCourse*)myParser->mMiase->getSed()->getSimulation(i))->getInitialTime() << std::endl;
842  std::cout << " OutputStartTime: " <<
843  ((CMiaseUniformTimeCourse*)myParser->mMiase->getSed()->getSimulation(i))->getOutputStartTime() << std::endl;
844  std::cout << " OutputEndTime: " <<
845  ((CMiaseUniformTimeCourse*)myParser->mMiase->getSed()->getSimulation(i))->getOutputEndTime() << std::endl;
846  std::cout << " NumberOfPoints: " <<
847  ((CMiaseUniformTimeCourse*)myParser->mMiase->getSed()->getSimulation(i))->getNumberOfPoints() << std::endl;
848  }
849  }
850 
851  std::cout << std::endl << std::endl;
852 
853  if (myParser->mMiase->getSed()->getNumOfModels() > 0)
854  {
855  std::cout << "NumOfModels: " <<
856  myParser->mMiase->getSed()->getNumOfModels() << std::endl << std::endl;
857 
858  for (i = 0 ; i < myParser->mMiase->getSed()->getNumOfModels() ; i++)
859  {
860  std::cout << " Model nr. :" << i << std::endl;
861 
862  std::cout << " id: " <<
863  myParser->mMiase->getSed()->getModel(i)->getId() << std::endl;
864  std::cout << " name: " <<
865  myParser->mMiase->getSed()->getModel(i)->getName() << std::endl;
866 
867  std::cout << " type: " <<
868  myParser->mMiase->getSed()->getModel(i)->getType() << std::endl;
869  std::cout << " source: " <<
870  myParser->mMiase->getSed()->getModel(i)->getSource() << std::endl;
871 
872  if (myParser->mMiase->getSed()->getModel(i)->getNumOfChanges() > 0)
873  {
874  std::cout << " NumOfChanges: " <<
875  myParser->mMiase->getSed()->getModel(i)->getNumOfChanges() << std::endl << std::endl;
876 
877  for (j = 0 ; j < myParser->mMiase->getSed()->getModel(i)->getNumOfChanges() ; j++)
878  {
879  std::cout << " Change nr. :" << j << std::endl;
880 
882  {
883  std::cout << " Change the ATTRIBUTE: " << std::endl;
884  std::cout << " NewValue: " <<
885  ((CMiaseChangeAttribute*)myParser->mMiase->getSed()->getModel(i)->getChange(j))->getNewValue() << std::endl;
886  std::cout << " Target: " <<
887  ((CMiaseChangeAttribute*)myParser->mMiase->getSed()->getModel(i)->getChange(j))->getTarget() << std::endl;
888  }
889 
891  {
892  std::cout << " Change the MATH: " << std::endl;
893  std::cout << " NewMath: " <<
894  ((CMiaseChangeMath*)myParser->mMiase->getSed()->getModel(i)->getChange(j))->getNewMath() << std::endl;
895  std::cout << " Target: " <<
896  ((CMiaseChangeMath*)myParser->mMiase->getSed()->getModel(i)->getChange(j))->getTarget() << std::endl;
897  }
898  }
899  }
900  }
901  }
902 
903  std::cout << std::endl << std::endl;
904 
905  if (myParser->mMiase->getSed()->getNumOfTasks() > 0)
906  {
907  std::cout << "NumOfTasks: " <<
908  myParser->mMiase->getSed()->getNumOfTasks() << std::endl << std::endl;
909 
910  for (i = 0 ; i < myParser->mMiase->getSed()->getNumOfTasks() ; i++)
911  {
912  std::cout << " Task nr. :" << i << std::endl;
913 
914  std::cout << " id: " <<
915  ((CMiaseUniformTimeCourse*)myParser->mMiase->getSed()->getTask(i))->getId() << std::endl;
916  std::cout << " name: " <<
917  ((CMiaseUniformTimeCourse*)myParser->mMiase->getSed()->getTask(i))->getName() << std::endl;
918 
919  std::cout << " notes: " <<
920  myParser->mMiase->getSed()->getTask(i)->getNotes()->getNotes() << std::endl;
921 
923  {
924  std::cout << " NumberOfMeasurements: " <<
925  myParser->mMiase->getSed()->getTask(i) << std::endl << std::endl;
926 
927  for (j = 0 ; j < myParser->mMiase->getSed()->getTask(i)->
928  getNumberOfMeasurements() ; j++)
929  {
930  std::cout << " Measurement nr. :" << j << std::endl;
931 
932  std::cout << " source: " <<
933  myParser->mMiase->getSed()->getTask(i)->getMeasurement(j)->getSource() << std::endl;
934  std::cout << " name: " <<
935  myParser->mMiase->getSed()->getTask(i)->getMeasurement(j)->getName() << std::endl;
936  }
937  }
938  }
939  }
940 
941  std::cout << std::endl << std::endl;
942 
943  if (myParser->mMiase->getSed()->getNumOfOutputs() > 0)
944  {
945  std::cout << "NumOfOutputs: " <<
946  myParser->mMiase->getSed()->getNumOfOutputs() << std::endl << std::endl;
947 
948  for (i = 0 ; i < myParser->mMiase->getSed()->getNumOfOutputs() ; i++)
949  {
950  std::cout << "output nr: " << i << std::endl;
951  std::cout << myParser->mMiase->getSed()->getOutput(i)->getWholeOutput() << std::endl;
952  }
953  }
954  }
955 }
std::string getId()
Definition: CMiaseBase.cpp:117
CMiaseModel * getLastModel()
Definition: CMiaseML.cpp:118
CMiaseTask * getTask(int num)
Definition: CMiaseML.cpp:74
void newContent(const XML_Char *s, int len)
void setXmlNs(std::string xmlNs)
Definition: CMiaseBase.cpp:38
void addTask(CMiaseTask *task)
Definition: CMiaseML.cpp:32
CMiaseNotes * getNotes()
Definition: CMiaseBase.cpp:104
CMiaseOutput * getOutput(int num)
Definition: CMiaseML.cpp:128
void setAnyNote(std::string anyAnnotation)
Definition: CMiaseBase.cpp:61
CMiaseMeasurementData * getMeasurement(int num)
Definition: CMiaseTask.cpp:58
static void XMLCALL start(void *data, const char *el, const char **attr)
void addChange(CMiaseChange *chnage)
void setName(std::string name)
Definition: CMiaseTask.cpp:37
void testDataStructure()
int getNumOfChanges()
CMiaseTask * getLastTask()
Definition: CMiaseML.cpp:91
void newMiase(const char **attr)
CMiaseOutput * getLastOutput()
Definition: CMiaseML.cpp:145
void load(std::string filename)
void setSource(std::string source)
Definition: CMiaseTask.cpp:32
int getNumOfOutputs()
Definition: CMiaseML.cpp:150
static XML_Char mVersion_1_0[]
Definition: CMiaseParser.h:44
void setMiaseSed(CMiaseSed *sed)
Definition: CMiaseML.cpp:163
void addContent(const char *el, const char **attr)
static CMiaseParser * myParser
Definition: CMiaseParser.h:148
CMiaseMeasurementData * getLastMeasurement()
Definition: CMiaseTask.cpp:68
static void XMLCALL xmldecl_handler(void *userData, const XML_Char *version, const XML_Char *encoding, int standalone)
void addNotes(CMiaseNotes *notes)
Definition: CMiaseBase.cpp:99
void setId(std::string id)
Definition: CMiaseBase.cpp:127
void setNotes(std::string notes)
Definition: CMiaseBase.cpp:28
CMiaseChange * getChange(int num)
static char mNameSpace[]
Definition: CMiaseParser.h:45
int getNumberOfMeasurements()
Definition: CMiaseTask.cpp:63
void setSimulationReference(std::string simulation)
Definition: CMiaseTask.cpp:78
void addMeasurement(CMiaseMeasurementData *measurement)
Definition: CMiaseTask.cpp:53
void newTask(const char **attr)
void newOutput(const char **attr)
CMiaseSimulation * getSimulation(int num)
Definition: CMiaseML.cpp:47
CMiaseSed * getSed()
Definition: CMiaseML.cpp:168
void setXmlns(std::string xmlns)
Definition: CMiaseML.cpp:183
CMiaseModel * getModel(int num)
Definition: CMiaseML.cpp:101
States mActState
Definition: CMiaseParser.h:96
void error(std::string errorString)
void setName(std::string name)
Definition: CMiaseBase.cpp:132
States mLastState
Definition: CMiaseParser.h:97
void newMeasurementData(const char **attr)
#define XML_FMT_INT_MOD
Definition: CMiaseParser.h:34
std::string getWholeOutput()
void addModel(CMiaseModel *model)
Definition: CMiaseML.cpp:37
void xmlDecl(const XML_Char *version, const XML_Char *encoding)
CMiaseAnnotation * getAnnotation()
Definition: CMiaseBase.cpp:94
void newChange(const char *el, const char **attr)
void setXmlNs(std::string xmlNs)
Definition: CMiaseBase.cpp:66
void setVersion(std::string version)
Definition: CMiaseML.cpp:188
static void XMLCALL charhndl(void *userData, const XML_Char *s, int len)
void saveWholeOutput(std::string output)
int getNumOfModels()
Definition: CMiaseML.cpp:123
int getNumOfSimulations()
Definition: CMiaseML.cpp:69
void startElement(const char *el, const char **attr)
void newState(States newState)
void endElement(const char *el)
void setModelReference(std::string model)
Definition: CMiaseTask.cpp:73
void addOutput(CMiaseOutput *output)
Definition: CMiaseML.cpp:42
bool isValid(const char *el)
std::string getSource()
Definition: CMiaseTask.cpp:22
std::string mContent
Definition: CMiaseParser.h:102
XML_Parser mXmlParser
Definition: CMiaseParser.h:100
std::string getType()
Definition: CMiaseModel.cpp:93
double strToDouble(const char *str, char const **pTail)
Definition: utility.cpp:325
CMiaseSimulation * getLastSimulation()
Definition: CMiaseML.cpp:64
CMiaseML * mMiase
Definition: CMiaseParser.h:95
void newModel(const char **attr)
#define BUFFSIZE
Definition: CMiaseParser.h:37
std::string getSource()
Definition: CMiaseModel.cpp:98
static void XMLCALL end(void *data, const char *el)
std::string getName()
Definition: CMiaseTask.cpp:27
void createAllowedStateTags()
CMiaseChange * getLastChange()
int getNumOfTasks()
Definition: CMiaseML.cpp:96
std::string getNotes()
Definition: CMiaseBase.cpp:23
void newNotes(const char **attr)
void newSimulation(const char *el, const char **attr)
void addAnnotation(CMiaseAnnotation *ann)
Definition: CMiaseBase.cpp:89
void setType(std::string type)
CMiaseBase * getLastObj()
char mBuff[8192]
Definition: CMiaseParser.h:101
void newAnnotation(const char **attr)
std::vector< std::vector< std::string > > mAllowedStateTags
Definition: CMiaseParser.h:103
static char mEncoding[]
Definition: CMiaseParser.h:46
void addSimulation(CMiaseSimulation *simulation)
Definition: CMiaseML.cpp:27
#define min(a, b)
Definition: f2c.h:175
void setSource(std::string source)
std::string getName()
Definition: CMiaseBase.cpp:122