1 /**
2 * @file SedDocument.cpp
3 * @brief Implementation of the SedDocument class.
4 * @author DEVISER
5 *
6 * <!--------------------------------------------------------------------------
7 * This file is part of libSEDML. Please visit http://sed-ml.org for more
8 * information about SED-ML. The latest version of libSEDML can be found on
9 * github: https://github.com/fbergmann/libSEDML/
10 *
11
12 * Copyright (c) 2013-2019, Frank T. Bergmann
13 * All rights reserved.
14 *
15
16 * Redistribution and use in source and binary forms, with or without
17 * modification, are permitted provided that the following conditions are met:
18 *
19
20 * 1. Redistributions of source code must retain the above copyright notice,
21 * this
22 * list of conditions and the following disclaimer.
23 * 2. Redistributions in binary form must reproduce the above copyright notice,
24 * this list of conditions and the following disclaimer in the documentation
25 * and/or other materials provided with the distribution.
26 *
27 * This library is free software; you can redistribute it and/or modify it
28 * under the terms of the GNU Lesser General Public License as published by the
29 * Free Software Foundation. A copy of the license agreement is provided in the
30 * file named "LICENSE.txt" included with this software distribution and also
31 * available online as http://sbml.org/software/libsbml/license.html
32 * ------------------------------------------------------------------------ -->
33 */
34 #include <sedml/SedDocument.h>
35 #include <sbml/xml/XMLInputStream.h>
36
37 #include <sedml/SedUniformTimeCourse.h>
38 #include <sedml/SedOneStep.h>
39 #include <sedml/SedSteadyState.h>
40 #include <sedml/SedAnalysis.h>
41 #include <sedml/SedTask.h>
42 #include <sedml/SedRepeatedTask.h>
43 #include <sedml/SedParameterEstimationTask.h>
44 #include <sedml/SedReport.h>
45 #include <sedml/SedPlot2D.h>
46 #include <sedml/SedPlot3D.h>
47 #include <sedml/SedFigure.h>
48 #include <sedml/SedParameterEstimationResultPlot.h>
49
50
51 using namespace std;
52
53
54
55 LIBSEDML_CPP_NAMESPACE_BEGIN
56
57
58
59
60 #ifdef __cplusplus
61
62
63 /*
64 * Creates a new SedDocument using the given SED-ML Level and @ p version
65 * values.
66 */
SedDocument(unsigned int level,unsigned int version)67 SedDocument::SedDocument(unsigned int level, unsigned int version)
68 : SedBase(level, version)
69 , mLevel (SEDML_INT_MAX)
70 , mIsSetLevel (false)
71 , mVersion (SEDML_INT_MAX)
72 , mIsSetVersion (false)
73 , mAlgorithmParameters (level, version)
74 , mDataDescriptions (level, version)
75 , mModels (level, version)
76 , mSimulations (level, version)
77 , mAbstractTasks (level, version)
78 , mDataGenerators (level, version)
79 , mOutputs (level, version)
80 , mStyles (level, version)
81 {
82 setSedNamespacesAndOwn(new SedNamespaces(level, version));
83 setLevel(level);
84 setVersion(version);
85 setSedDocument(this);
86 connectToChild();
87 }
88
89
90 /*
91 * Creates a new SedDocument using the given SedNamespaces object @p sedmlns.
92 */
SedDocument(SedNamespaces * sedmlns)93 SedDocument::SedDocument(SedNamespaces *sedmlns)
94 : SedBase(sedmlns)
95 , mLevel (SEDML_INT_MAX)
96 , mIsSetLevel (false)
97 , mVersion (SEDML_INT_MAX)
98 , mIsSetVersion (false)
99 , mAlgorithmParameters (sedmlns)
100 , mDataDescriptions (sedmlns)
101 , mModels (sedmlns)
102 , mSimulations (sedmlns)
103 , mAbstractTasks (sedmlns)
104 , mDataGenerators (sedmlns)
105 , mOutputs (sedmlns)
106 , mStyles (sedmlns)
107 {
108 setElementNamespace(sedmlns->getURI());
109 setLevel(sedmlns->getLevel());
110 setVersion(sedmlns->getVersion());
111 setSedDocument(this);
112 connectToChild();
113 }
114
115
116 /*
117 * Copy constructor for SedDocument.
118 */
SedDocument(const SedDocument & orig)119 SedDocument::SedDocument(const SedDocument& orig)
120 : SedBase( orig )
121 , mLevel ( orig.mLevel )
122 , mIsSetLevel ( orig.mIsSetLevel )
123 , mVersion ( orig.mVersion )
124 , mIsSetVersion ( orig.mIsSetVersion )
125 , mAlgorithmParameters (orig.mAlgorithmParameters)
126 , mDataDescriptions ( orig.mDataDescriptions )
127 , mModels ( orig.mModels )
128 , mSimulations ( orig.mSimulations )
129 , mAbstractTasks ( orig.mAbstractTasks )
130 , mDataGenerators ( orig.mDataGenerators )
131 , mOutputs ( orig.mOutputs )
132 , mStyles ( orig.mStyles )
133 {
134 setSedDocument(this);
135
136 connectToChild();
137 }
138
139
140 /*
141 * Assignment operator for SedDocument.
142 */
143 SedDocument&
operator =(const SedDocument & rhs)144 SedDocument::operator=(const SedDocument& rhs)
145 {
146 if (&rhs != this)
147 {
148 SedBase::operator=(rhs);
149 mLevel = rhs.mLevel;
150 mIsSetLevel = rhs.mIsSetLevel;
151 mVersion = rhs.mVersion;
152 mIsSetVersion = rhs.mIsSetVersion;
153 mAlgorithmParameters = rhs.mAlgorithmParameters;
154 mDataDescriptions = rhs.mDataDescriptions;
155 mModels = rhs.mModels;
156 mSimulations = rhs.mSimulations;
157 mAbstractTasks = rhs.mAbstractTasks;
158 mDataGenerators = rhs.mDataGenerators;
159 mOutputs = rhs.mOutputs;
160 mStyles = rhs.mStyles;
161 connectToChild();
162 setSedDocument(this);
163 }
164
165 return *this;
166 }
167
168
169 /*
170 * Creates and returns a deep copy of this SedDocument object.
171 */
172 SedDocument*
clone() const173 SedDocument::clone() const
174 {
175 return new SedDocument(*this);
176 }
177
178
179 /*
180 * Destructor for SedDocument.
181 */
~SedDocument()182 SedDocument::~SedDocument()
183 {
184 }
185
186
187 /*
188 * Returns the value of the "level" attribute of this SedDocument.
189 */
190 unsigned int
getLevel() const191 SedDocument::getLevel() const
192 {
193 return mLevel;
194 }
195
196
197 /*
198 * Returns the value of the "version" attribute of this SedDocument.
199 */
200 unsigned int
getVersion() const201 SedDocument::getVersion() const
202 {
203 return mVersion;
204 }
205
206
207 /*
208 * Predicate returning @c true if this SedDocument's "level" attribute is set.
209 */
210 bool
isSetLevel() const211 SedDocument::isSetLevel() const
212 {
213 return mIsSetLevel;
214 }
215
216
217 /*
218 * Predicate returning @c true if this SedDocument's "version" attribute is
219 * set.
220 */
221 bool
isSetVersion() const222 SedDocument::isSetVersion() const
223 {
224 return mIsSetVersion;
225 }
226
227
228 /*
229 * Sets the value of the "level" attribute of this SedDocument.
230 */
231 int
setLevel(unsigned int level)232 SedDocument::setLevel(unsigned int level)
233 {
234 mLevel = level;
235 mIsSetLevel = true;
236
237 if (mIsSetVersion)
238 {
239 setSedNamespacesAndOwn(new SedNamespaces(level, mVersion));
240 }
241
242 return LIBSEDML_OPERATION_SUCCESS;
243 }
244
245
246 /*
247 * Sets the value of the "version" attribute of this SedDocument.
248 */
249 int
setVersion(unsigned int version)250 SedDocument::setVersion(unsigned int version)
251 {
252 mVersion = version;
253 mIsSetVersion = true;
254
255 if (mIsSetLevel)
256 {
257 setSedNamespacesAndOwn(new SedNamespaces(mLevel, version));
258 }
259
260 return LIBSEDML_OPERATION_SUCCESS;
261 }
262
263
264 /*
265 * Unsets the value of the "level" attribute of this SedDocument.
266 */
267 int
unsetLevel()268 SedDocument::unsetLevel()
269 {
270 mLevel = SEDML_INT_MAX;
271 mIsSetLevel = false;
272
273 if (isSetLevel() == false)
274 {
275 return LIBSEDML_OPERATION_SUCCESS;
276 }
277 else
278 {
279 return LIBSEDML_OPERATION_FAILED;
280 }
281 }
282
283
284 /*
285 * Unsets the value of the "version" attribute of this SedDocument.
286 */
287 int
unsetVersion()288 SedDocument::unsetVersion()
289 {
290 mVersion = SEDML_INT_MAX;
291 mIsSetVersion = false;
292
293 if (isSetVersion() == false)
294 {
295 return LIBSEDML_OPERATION_SUCCESS;
296 }
297 else
298 {
299 return LIBSEDML_OPERATION_FAILED;
300 }
301 }
302
303
304 /*
305 * Returns the SedListOfAlgorithmParameters from this SedDocument.
306 */
307 const SedListOfAlgorithmParameters*
getListOfAlgorithmParameters() const308 SedDocument::getListOfAlgorithmParameters() const
309 {
310 return &mAlgorithmParameters;
311 }
312
313
314 /*
315 * Returns the SedListOfAlgorithmParameters from this SedDocument.
316 */
317 SedListOfAlgorithmParameters*
getListOfAlgorithmParameters()318 SedDocument::getListOfAlgorithmParameters()
319 {
320 return &mAlgorithmParameters;
321 }
322
323
324 /*
325 * Get a SedAlgorithmParameter from the SedDocument.
326 */
327 SedAlgorithmParameter*
getAlgorithmParameter(unsigned int n)328 SedDocument::getAlgorithmParameter(unsigned int n)
329 {
330 return mAlgorithmParameters.get(n);
331 }
332
333
334 /*
335 * Get a SedAlgorithmParameter from the SedDocument.
336 */
337 const SedAlgorithmParameter*
getAlgorithmParameter(unsigned int n) const338 SedDocument::getAlgorithmParameter(unsigned int n) const
339 {
340 return mAlgorithmParameters.get(n);
341 }
342
343
344 /*
345 * Get a SedAlgorithmParameter from the SedDocument.
346 */
347 SedAlgorithmParameter*
getAlgorithmParameter(const string & id)348 SedDocument::getAlgorithmParameter(const string& id)
349 {
350 return mAlgorithmParameters.get(id);
351 }
352
353
354 /*
355 * Get a SedAlgorithmParameter from the SedDocument.
356 */
357 const SedAlgorithmParameter*
getAlgorithmParameter(const string & id) const358 SedDocument::getAlgorithmParameter(const string& id) const
359 {
360 return mAlgorithmParameters.get(id);
361 }
362
363
364 /*
365 * Adds a copy of the given SedAlgorithmParameter to this SedDocument.
366 */
367 int
addAlgorithmParameter(const SedAlgorithmParameter * sap)368 SedDocument::addAlgorithmParameter(const SedAlgorithmParameter* sap)
369 {
370 if (sap == NULL)
371 {
372 return LIBSEDML_OPERATION_FAILED;
373 }
374 else if (sap->hasRequiredAttributes() == false)
375 {
376 return LIBSEDML_INVALID_OBJECT;
377 }
378 else if (getLevel() != sap->getLevel())
379 {
380 return LIBSEDML_LEVEL_MISMATCH;
381 }
382 else if (getVersion() != sap->getVersion())
383 {
384 return LIBSEDML_VERSION_MISMATCH;
385 }
386 else if (matchesRequiredSedNamespacesForAddition(static_cast<const
387 SedBase*>(sap)) == false)
388 {
389 return LIBSEDML_NAMESPACES_MISMATCH;
390 }
391 else if (getLevel() == 1 && getVersion() < 4)
392 {
393 return LIBSEDML_INVALID_OBJECT;
394 }
395 else
396 {
397 return mAlgorithmParameters.append(sap);
398 }
399 }
400
401
402 /*
403 * Get the number of SedAlgorithmParameter objects in this SedDocument.
404 */
405 unsigned int
getNumAlgorithmParameters() const406 SedDocument::getNumAlgorithmParameters() const
407 {
408 return mAlgorithmParameters.size();
409 }
410
411
412 /*
413 * Creates a new SedAlgorithmParameter object, adds it to this SedDocument
414 * object and returns the SedAlgorithmParameter object created.
415 */
416 SedAlgorithmParameter*
createAlgorithmParameter()417 SedDocument::createAlgorithmParameter()
418 {
419 SedAlgorithmParameter* sap = NULL;
420 if (getLevel() == 1 && getVersion() < 4)
421 {
422 return sap;
423 }
424
425 try
426 {
427 sap = new SedAlgorithmParameter(getSedNamespaces());
428 }
429 catch (...)
430 {
431 }
432
433 if (sap != NULL)
434 {
435 mAlgorithmParameters.appendAndOwn(sap);
436 }
437
438 return sap;
439 }
440
441
442 /*
443 * Removes the nth SedAlgorithmParameter from this SedDocument and returns a
444 * pointer to it.
445 */
446 SedAlgorithmParameter*
removeAlgorithmParameter(unsigned int n)447 SedDocument::removeAlgorithmParameter(unsigned int n)
448 {
449 return mAlgorithmParameters.remove(n);
450 }
451
452
453 /*
454 * Removes the SedAlgorithmParameter with the given id from this SedDocument and returns a
455 * pointer to it.
456 */
457 SedAlgorithmParameter*
removeAlgorithmParameter(const string & id)458 SedDocument::removeAlgorithmParameter(const string& id)
459 {
460 return mAlgorithmParameters.remove(id);
461 }
462
463
464 /*
465 * Returns the SedListOfDataDescriptions from this SedDocument.
466 */
467 const SedListOfDataDescriptions*
getListOfDataDescriptions() const468 SedDocument::getListOfDataDescriptions() const
469 {
470 return &mDataDescriptions;
471 }
472
473
474 /*
475 * Returns the SedListOfDataDescriptions from this SedDocument.
476 */
477 SedListOfDataDescriptions*
getListOfDataDescriptions()478 SedDocument::getListOfDataDescriptions()
479 {
480 return &mDataDescriptions;
481 }
482
483
484 /*
485 * Get a SedDataDescription from the SedDocument.
486 */
487 SedDataDescription*
getDataDescription(unsigned int n)488 SedDocument::getDataDescription(unsigned int n)
489 {
490 return mDataDescriptions.get(n);
491 }
492
493
494 /*
495 * Get a SedDataDescription from the SedDocument.
496 */
497 const SedDataDescription*
getDataDescription(unsigned int n) const498 SedDocument::getDataDescription(unsigned int n) const
499 {
500 return mDataDescriptions.get(n);
501 }
502
503
504 /*
505 * Get a SedDataDescription from the SedDocument based on its identifier.
506 */
507 SedDataDescription*
getDataDescription(const std::string & sid)508 SedDocument::getDataDescription(const std::string& sid)
509 {
510 return mDataDescriptions.get(sid);
511 }
512
513
514 /*
515 * Get a SedDataDescription from the SedDocument based on its identifier.
516 */
517 const SedDataDescription*
getDataDescription(const std::string & sid) const518 SedDocument::getDataDescription(const std::string& sid) const
519 {
520 return mDataDescriptions.get(sid);
521 }
522
523
524 /*
525 * Adds a copy of the given SedDataDescription to this SedDocument.
526 */
527 int
addDataDescription(const SedDataDescription * sdd)528 SedDocument::addDataDescription(const SedDataDescription* sdd)
529 {
530 if (sdd == NULL)
531 {
532 return LIBSEDML_OPERATION_FAILED;
533 }
534 else if (sdd->hasRequiredAttributes() == false)
535 {
536 return LIBSEDML_INVALID_OBJECT;
537 }
538 else if (getLevel() != sdd->getLevel())
539 {
540 return LIBSEDML_LEVEL_MISMATCH;
541 }
542 else if (getVersion() != sdd->getVersion())
543 {
544 return LIBSEDML_VERSION_MISMATCH;
545 }
546 else if (matchesRequiredSedNamespacesForAddition(static_cast<const
547 SedBase*>(sdd)) == false)
548 {
549 return LIBSEDML_NAMESPACES_MISMATCH;
550 }
551 else if (sdd->isSetId() && (mDataDescriptions.get(sdd->getId())) != NULL)
552 {
553 return LIBSEDML_DUPLICATE_OBJECT_ID;
554 }
555 else
556 {
557 return mDataDescriptions.append(sdd);
558 }
559 }
560
561
562 /*
563 * Get the number of SedDataDescription objects in this SedDocument.
564 */
565 unsigned int
getNumDataDescriptions() const566 SedDocument::getNumDataDescriptions() const
567 {
568 return mDataDescriptions.size();
569 }
570
571
572 /*
573 * Creates a new SedDataDescription object, adds it to this SedDocument object
574 * and returns the SedDataDescription object created.
575 */
576 SedDataDescription*
createDataDescription()577 SedDocument::createDataDescription()
578 {
579 SedDataDescription* sdd = NULL;
580
581 try
582 {
583 sdd = new SedDataDescription(getSedNamespaces());
584 }
585 catch (...)
586 {
587 }
588
589 if (sdd != NULL)
590 {
591 mDataDescriptions.appendAndOwn(sdd);
592 }
593
594 return sdd;
595 }
596
597
598 /*
599 * Removes the nth SedDataDescription from this SedDocument and returns a
600 * pointer to it.
601 */
602 SedDataDescription*
removeDataDescription(unsigned int n)603 SedDocument::removeDataDescription(unsigned int n)
604 {
605 return mDataDescriptions.remove(n);
606 }
607
608
609 /*
610 * Removes the SedDataDescription from this SedDocument based on its identifier
611 * and returns a pointer to it.
612 */
613 SedDataDescription*
removeDataDescription(const std::string & sid)614 SedDocument::removeDataDescription(const std::string& sid)
615 {
616 return mDataDescriptions.remove(sid);
617 }
618
619
620 /*
621 * Returns the SedListOfModels from this SedDocument.
622 */
623 const SedListOfModels*
getListOfModels() const624 SedDocument::getListOfModels() const
625 {
626 return &mModels;
627 }
628
629
630 /*
631 * Returns the SedListOfModels from this SedDocument.
632 */
633 SedListOfModels*
getListOfModels()634 SedDocument::getListOfModels()
635 {
636 return &mModels;
637 }
638
639
640 /*
641 * Get a SedModel from the SedDocument.
642 */
643 SedModel*
getModel(unsigned int n)644 SedDocument::getModel(unsigned int n)
645 {
646 return mModels.get(n);
647 }
648
649
650 /*
651 * Get a SedModel from the SedDocument.
652 */
653 const SedModel*
getModel(unsigned int n) const654 SedDocument::getModel(unsigned int n) const
655 {
656 return mModels.get(n);
657 }
658
659
660 /*
661 * Get a SedModel from the SedDocument based on its identifier.
662 */
663 SedModel*
getModel(const std::string & sid)664 SedDocument::getModel(const std::string& sid)
665 {
666 return mModels.get(sid);
667 }
668
669
670 /*
671 * Get a SedModel from the SedDocument based on its identifier.
672 */
673 const SedModel*
getModel(const std::string & sid) const674 SedDocument::getModel(const std::string& sid) const
675 {
676 return mModels.get(sid);
677 }
678
679
680 /*
681 * Adds a copy of the given SedModel to this SedDocument.
682 */
683 int
addModel(const SedModel * sm)684 SedDocument::addModel(const SedModel* sm)
685 {
686 if (sm == NULL)
687 {
688 return LIBSEDML_OPERATION_FAILED;
689 }
690 else if (sm->hasRequiredAttributes() == false)
691 {
692 return LIBSEDML_INVALID_OBJECT;
693 }
694 else if (getLevel() != sm->getLevel())
695 {
696 return LIBSEDML_LEVEL_MISMATCH;
697 }
698 else if (getVersion() != sm->getVersion())
699 {
700 return LIBSEDML_VERSION_MISMATCH;
701 }
702 else if (matchesRequiredSedNamespacesForAddition(static_cast<const
703 SedBase*>(sm)) == false)
704 {
705 return LIBSEDML_NAMESPACES_MISMATCH;
706 }
707 else if (sm->isSetId() && (mModels.get(sm->getId())) != NULL)
708 {
709 return LIBSEDML_DUPLICATE_OBJECT_ID;
710 }
711 else
712 {
713 return mModels.append(sm);
714 }
715 }
716
717
718 /*
719 * Get the number of SedModel objects in this SedDocument.
720 */
721 unsigned int
getNumModels() const722 SedDocument::getNumModels() const
723 {
724 return mModels.size();
725 }
726
727
728 /*
729 * Creates a new SedModel object, adds it to this SedDocument object and
730 * returns the SedModel object created.
731 */
732 SedModel*
createModel()733 SedDocument::createModel()
734 {
735 SedModel* sm = NULL;
736
737 try
738 {
739 sm = new SedModel(getSedNamespaces());
740 }
741 catch (...)
742 {
743 }
744
745 if (sm != NULL)
746 {
747 mModels.appendAndOwn(sm);
748 }
749
750 return sm;
751 }
752
753
754 /*
755 * Removes the nth SedModel from this SedDocument and returns a pointer to it.
756 */
757 SedModel*
removeModel(unsigned int n)758 SedDocument::removeModel(unsigned int n)
759 {
760 return mModels.remove(n);
761 }
762
763
764 /*
765 * Removes the SedModel from this SedDocument based on its identifier and
766 * returns a pointer to it.
767 */
768 SedModel*
removeModel(const std::string & sid)769 SedDocument::removeModel(const std::string& sid)
770 {
771 return mModels.remove(sid);
772 }
773
774
775 /*
776 * Returns the SedListOfSimulations from this SedDocument.
777 */
778 const SedListOfSimulations*
getListOfSimulations() const779 SedDocument::getListOfSimulations() const
780 {
781 return &mSimulations;
782 }
783
784
785 /*
786 * Returns the SedListOfSimulations from this SedDocument.
787 */
788 SedListOfSimulations*
getListOfSimulations()789 SedDocument::getListOfSimulations()
790 {
791 return &mSimulations;
792 }
793
794
795 /*
796 * Get a SedSimulation from the SedDocument.
797 */
798 SedSimulation*
getSimulation(unsigned int n)799 SedDocument::getSimulation(unsigned int n)
800 {
801 return mSimulations.get(n);
802 }
803
804
805 /*
806 * Get a SedSimulation from the SedDocument.
807 */
808 const SedSimulation*
getSimulation(unsigned int n) const809 SedDocument::getSimulation(unsigned int n) const
810 {
811 return mSimulations.get(n);
812 }
813
814
815 /*
816 * Get a SedSimulation from the SedDocument based on its identifier.
817 */
818 SedSimulation*
getSimulation(const std::string & sid)819 SedDocument::getSimulation(const std::string& sid)
820 {
821 return mSimulations.get(sid);
822 }
823
824
825 /*
826 * Get a SedSimulation from the SedDocument based on its identifier.
827 */
828 const SedSimulation*
getSimulation(const std::string & sid) const829 SedDocument::getSimulation(const std::string& sid) const
830 {
831 return mSimulations.get(sid);
832 }
833
834
835 /*
836 * Adds a copy of the given SedSimulation to this SedDocument.
837 */
838 int
addSimulation(const SedSimulation * ss)839 SedDocument::addSimulation(const SedSimulation* ss)
840 {
841 if (ss == NULL)
842 {
843 return LIBSEDML_OPERATION_FAILED;
844 }
845 else if (ss->hasRequiredAttributes() == false)
846 {
847 return LIBSEDML_INVALID_OBJECT;
848 }
849 else if (ss->hasRequiredElements() == false)
850 {
851 return LIBSEDML_INVALID_OBJECT;
852 }
853 else if (getLevel() != ss->getLevel())
854 {
855 return LIBSEDML_LEVEL_MISMATCH;
856 }
857 else if (getVersion() != ss->getVersion())
858 {
859 return LIBSEDML_VERSION_MISMATCH;
860 }
861 else if (matchesRequiredSedNamespacesForAddition(static_cast<const
862 SedBase*>(ss)) == false)
863 {
864 return LIBSEDML_NAMESPACES_MISMATCH;
865 }
866 else if (ss->isSetId() && (mSimulations.get(ss->getId())) != NULL)
867 {
868 return LIBSEDML_DUPLICATE_OBJECT_ID;
869 }
870 else
871 {
872 return mSimulations.append(ss);
873 }
874 }
875
876
877 /*
878 * Get the number of SedSimulation objects in this SedDocument.
879 */
880 unsigned int
getNumSimulations() const881 SedDocument::getNumSimulations() const
882 {
883 return mSimulations.size();
884 }
885
886
887 /*
888 * Creates a new SedUniformTimeCourse object, adds it to this SedDocument
889 * object and returns the SedUniformTimeCourse object created.
890 */
891 SedUniformTimeCourse*
createUniformTimeCourse()892 SedDocument::createUniformTimeCourse()
893 {
894 SedUniformTimeCourse* sutc = NULL;
895
896 try
897 {
898 sutc = new SedUniformTimeCourse(getSedNamespaces());
899 }
900 catch (...)
901 {
902 }
903
904 if (sutc != NULL)
905 {
906 mSimulations.appendAndOwn(sutc);
907 }
908
909 return sutc;
910 }
911
912
913 /*
914 * Creates a new SedOneStep object, adds it to this SedDocument object and
915 * returns the SedOneStep object created.
916 */
917 SedOneStep*
createOneStep()918 SedDocument::createOneStep()
919 {
920 SedOneStep* sos = NULL;
921
922 try
923 {
924 sos = new SedOneStep(getSedNamespaces());
925 }
926 catch (...)
927 {
928 }
929
930 if (sos != NULL)
931 {
932 mSimulations.appendAndOwn(sos);
933 }
934
935 return sos;
936 }
937
938
939 /*
940 * Creates a new SedSteadyState object, adds it to this SedDocument object and
941 * returns the SedSteadyState object created.
942 */
943 SedSteadyState*
createSteadyState()944 SedDocument::createSteadyState()
945 {
946 SedSteadyState* sss = NULL;
947
948 try
949 {
950 sss = new SedSteadyState(getSedNamespaces());
951 }
952 catch (...)
953 {
954 }
955
956 if (sss != NULL)
957 {
958 mSimulations.appendAndOwn(sss);
959 }
960
961 return sss;
962 }
963
964
965 /*
966 * Creates a new SedAnalysis object, adds it to this SedDocument object and
967 * returns the SedAnalysis object created.
968 */
969 SedAnalysis*
createAnalysis()970 SedDocument::createAnalysis()
971 {
972 SedAnalysis* sss = NULL;
973
974 try
975 {
976 sss = new SedAnalysis(getSedNamespaces());
977 }
978 catch (...)
979 {
980 }
981
982 if (sss != NULL)
983 {
984 mSimulations.appendAndOwn(sss);
985 }
986
987 return sss;
988 }
989
990
991 /*
992 * Removes the nth SedSimulation from this SedDocument and returns a pointer to
993 * it.
994 */
995 SedSimulation*
removeSimulation(unsigned int n)996 SedDocument::removeSimulation(unsigned int n)
997 {
998 return mSimulations.remove(n);
999 }
1000
1001
1002 /*
1003 * Removes the SedSimulation from this SedDocument based on its identifier and
1004 * returns a pointer to it.
1005 */
1006 SedSimulation*
removeSimulation(const std::string & sid)1007 SedDocument::removeSimulation(const std::string& sid)
1008 {
1009 return mSimulations.remove(sid);
1010 }
1011
1012
1013 /*
1014 * Returns the SedListOfTasks from this SedDocument.
1015 */
1016 const SedListOfTasks*
getListOfTasks() const1017 SedDocument::getListOfTasks() const
1018 {
1019 return &mAbstractTasks;
1020 }
1021
1022
1023 /*
1024 * Returns the SedListOfTasks from this SedDocument.
1025 */
1026 SedListOfTasks*
getListOfTasks()1027 SedDocument::getListOfTasks()
1028 {
1029 return &mAbstractTasks;
1030 }
1031
1032
1033 /*
1034 * Get a SedAbstractTask from the SedDocument.
1035 */
1036 SedAbstractTask*
getTask(unsigned int n)1037 SedDocument::getTask(unsigned int n)
1038 {
1039 return mAbstractTasks.get(n);
1040 }
1041
1042
1043 /*
1044 * Get a SedAbstractTask from the SedDocument.
1045 */
1046 const SedAbstractTask*
getTask(unsigned int n) const1047 SedDocument::getTask(unsigned int n) const
1048 {
1049 return mAbstractTasks.get(n);
1050 }
1051
1052
1053 /*
1054 * Get a SedAbstractTask from the SedDocument based on its identifier.
1055 */
1056 SedAbstractTask*
getTask(const std::string & sid)1057 SedDocument::getTask(const std::string& sid)
1058 {
1059 return mAbstractTasks.get(sid);
1060 }
1061
1062
1063 /*
1064 * Get a SedAbstractTask from the SedDocument based on its identifier.
1065 */
1066 const SedAbstractTask*
getTask(const std::string & sid) const1067 SedDocument::getTask(const std::string& sid) const
1068 {
1069 return mAbstractTasks.get(sid);
1070 }
1071
1072
1073 /*
1074 * Adds a copy of the given SedAbstractTask to this SedDocument.
1075 */
1076 int
addTask(const SedAbstractTask * sat)1077 SedDocument::addTask(const SedAbstractTask* sat)
1078 {
1079 if (sat == NULL)
1080 {
1081 return LIBSEDML_OPERATION_FAILED;
1082 }
1083 else if (sat->hasRequiredAttributes() == false)
1084 {
1085 return LIBSEDML_INVALID_OBJECT;
1086 }
1087 else if (getLevel() != sat->getLevel())
1088 {
1089 return LIBSEDML_LEVEL_MISMATCH;
1090 }
1091 else if (getVersion() != sat->getVersion())
1092 {
1093 return LIBSEDML_VERSION_MISMATCH;
1094 }
1095 else if (matchesRequiredSedNamespacesForAddition(static_cast<const
1096 SedBase*>(sat)) == false)
1097 {
1098 return LIBSEDML_NAMESPACES_MISMATCH;
1099 }
1100 else if (sat->isSetId() && (mAbstractTasks.get(sat->getId())) != NULL)
1101 {
1102 return LIBSEDML_DUPLICATE_OBJECT_ID;
1103 }
1104 else
1105 {
1106 return mAbstractTasks.append(sat);
1107 }
1108 }
1109
1110
1111 /*
1112 * Get the number of SedAbstractTask objects in this SedDocument.
1113 */
1114 unsigned int
getNumTasks() const1115 SedDocument::getNumTasks() const
1116 {
1117 return mAbstractTasks.size();
1118 }
1119
1120
1121 /*
1122 * Creates a new SedTask object, adds it to this SedDocument object and returns
1123 * the SedTask object created.
1124 */
1125 SedTask*
createTask()1126 SedDocument::createTask()
1127 {
1128 SedTask* st = NULL;
1129
1130 try
1131 {
1132 st = new SedTask(getSedNamespaces());
1133 }
1134 catch (...)
1135 {
1136 }
1137
1138 if (st != NULL)
1139 {
1140 mAbstractTasks.appendAndOwn(st);
1141 }
1142
1143 return st;
1144 }
1145
1146
1147 /*
1148 * Creates a new SedRepeatedTask object, adds it to this SedDocument object and
1149 * returns the SedRepeatedTask object created.
1150 */
1151 SedRepeatedTask*
createRepeatedTask()1152 SedDocument::createRepeatedTask()
1153 {
1154 SedRepeatedTask* srt = NULL;
1155
1156 try
1157 {
1158 srt = new SedRepeatedTask(getSedNamespaces());
1159 }
1160 catch (...)
1161 {
1162 }
1163
1164 if (srt != NULL)
1165 {
1166 mAbstractTasks.appendAndOwn(srt);
1167 }
1168
1169 return srt;
1170 }
1171
1172
1173 /*
1174 * Creates a new SedParameterEstimationTask object, adds it to this SedDocument
1175 * object and returns the SedParameterEstimationTask object created.
1176 */
1177 SedParameterEstimationTask*
createParameterEstimationTask()1178 SedDocument::createParameterEstimationTask()
1179 {
1180 SedParameterEstimationTask* spet = NULL;
1181
1182 try
1183 {
1184 spet = new SedParameterEstimationTask(getSedNamespaces());
1185 }
1186 catch (...)
1187 {
1188 }
1189
1190 if (spet != NULL)
1191 {
1192 mAbstractTasks.appendAndOwn(spet);
1193 }
1194
1195 return spet;
1196 }
1197
1198
1199 /*
1200 * Removes the nth SedAbstractTask from this SedDocument and returns a pointer
1201 * to it.
1202 */
1203 SedAbstractTask*
removeTask(unsigned int n)1204 SedDocument::removeTask(unsigned int n)
1205 {
1206 return mAbstractTasks.remove(n);
1207 }
1208
1209
1210 /*
1211 * Removes the SedAbstractTask from this SedDocument based on its identifier
1212 * and returns a pointer to it.
1213 */
1214 SedAbstractTask*
removeTask(const std::string & sid)1215 SedDocument::removeTask(const std::string& sid)
1216 {
1217 return mAbstractTasks.remove(sid);
1218 }
1219
1220
1221 /*
1222 * Returns the SedListOfDataGenerators from this SedDocument.
1223 */
1224 const SedListOfDataGenerators*
getListOfDataGenerators() const1225 SedDocument::getListOfDataGenerators() const
1226 {
1227 return &mDataGenerators;
1228 }
1229
1230
1231 /*
1232 * Returns the SedListOfDataGenerators from this SedDocument.
1233 */
1234 SedListOfDataGenerators*
getListOfDataGenerators()1235 SedDocument::getListOfDataGenerators()
1236 {
1237 return &mDataGenerators;
1238 }
1239
1240
1241 /*
1242 * Get a SedDataGenerator from the SedDocument.
1243 */
1244 SedDataGenerator*
getDataGenerator(unsigned int n)1245 SedDocument::getDataGenerator(unsigned int n)
1246 {
1247 return mDataGenerators.get(n);
1248 }
1249
1250
1251 /*
1252 * Get a SedDataGenerator from the SedDocument.
1253 */
1254 const SedDataGenerator*
getDataGenerator(unsigned int n) const1255 SedDocument::getDataGenerator(unsigned int n) const
1256 {
1257 return mDataGenerators.get(n);
1258 }
1259
1260
1261 /*
1262 * Get a SedDataGenerator from the SedDocument based on its identifier.
1263 */
1264 SedDataGenerator*
getDataGenerator(const std::string & sid)1265 SedDocument::getDataGenerator(const std::string& sid)
1266 {
1267 return mDataGenerators.get(sid);
1268 }
1269
1270
1271 /*
1272 * Get a SedDataGenerator from the SedDocument based on its identifier.
1273 */
1274 const SedDataGenerator*
getDataGenerator(const std::string & sid) const1275 SedDocument::getDataGenerator(const std::string& sid) const
1276 {
1277 return mDataGenerators.get(sid);
1278 }
1279
1280
1281 /*
1282 * Adds a copy of the given SedDataGenerator to this SedDocument.
1283 */
1284 int
addDataGenerator(const SedDataGenerator * sdg)1285 SedDocument::addDataGenerator(const SedDataGenerator* sdg)
1286 {
1287 if (sdg == NULL)
1288 {
1289 return LIBSEDML_OPERATION_FAILED;
1290 }
1291 else if (sdg->hasRequiredAttributes() == false)
1292 {
1293 return LIBSEDML_INVALID_OBJECT;
1294 }
1295 else if (sdg->hasRequiredElements() == false)
1296 {
1297 return LIBSEDML_INVALID_OBJECT;
1298 }
1299 else if (getLevel() != sdg->getLevel())
1300 {
1301 return LIBSEDML_LEVEL_MISMATCH;
1302 }
1303 else if (getVersion() != sdg->getVersion())
1304 {
1305 return LIBSEDML_VERSION_MISMATCH;
1306 }
1307 else if (matchesRequiredSedNamespacesForAddition(static_cast<const
1308 SedBase*>(sdg)) == false)
1309 {
1310 return LIBSEDML_NAMESPACES_MISMATCH;
1311 }
1312 else if (sdg->isSetId() && (mDataGenerators.get(sdg->getId())) != NULL)
1313 {
1314 return LIBSEDML_DUPLICATE_OBJECT_ID;
1315 }
1316 else
1317 {
1318 return mDataGenerators.append(sdg);
1319 }
1320 }
1321
1322
1323 /*
1324 * Get the number of SedDataGenerator objects in this SedDocument.
1325 */
1326 unsigned int
getNumDataGenerators() const1327 SedDocument::getNumDataGenerators() const
1328 {
1329 return mDataGenerators.size();
1330 }
1331
1332
1333 /*
1334 * Creates a new SedDataGenerator object, adds it to this SedDocument object
1335 * and returns the SedDataGenerator object created.
1336 */
1337 SedDataGenerator*
createDataGenerator()1338 SedDocument::createDataGenerator()
1339 {
1340 SedDataGenerator* sdg = NULL;
1341
1342 try
1343 {
1344 sdg = new SedDataGenerator(getSedNamespaces());
1345 }
1346 catch (...)
1347 {
1348 }
1349
1350 if (sdg != NULL)
1351 {
1352 mDataGenerators.appendAndOwn(sdg);
1353 }
1354
1355 return sdg;
1356 }
1357
1358
1359 /*
1360 * Removes the nth SedDataGenerator from this SedDocument and returns a pointer
1361 * to it.
1362 */
1363 SedDataGenerator*
removeDataGenerator(unsigned int n)1364 SedDocument::removeDataGenerator(unsigned int n)
1365 {
1366 return mDataGenerators.remove(n);
1367 }
1368
1369
1370 /*
1371 * Removes the SedDataGenerator from this SedDocument based on its identifier
1372 * and returns a pointer to it.
1373 */
1374 SedDataGenerator*
removeDataGenerator(const std::string & sid)1375 SedDocument::removeDataGenerator(const std::string& sid)
1376 {
1377 return mDataGenerators.remove(sid);
1378 }
1379
1380
1381 /*
1382 * Returns the SedListOfOutputs from this SedDocument.
1383 */
1384 const SedListOfOutputs*
getListOfOutputs() const1385 SedDocument::getListOfOutputs() const
1386 {
1387 return &mOutputs;
1388 }
1389
1390
1391 /*
1392 * Returns the SedListOfOutputs from this SedDocument.
1393 */
1394 SedListOfOutputs*
getListOfOutputs()1395 SedDocument::getListOfOutputs()
1396 {
1397 return &mOutputs;
1398 }
1399
1400
1401 /*
1402 * Get a SedOutput from the SedDocument.
1403 */
1404 SedOutput*
getOutput(unsigned int n)1405 SedDocument::getOutput(unsigned int n)
1406 {
1407 return mOutputs.get(n);
1408 }
1409
1410
1411 /*
1412 * Get a SedOutput from the SedDocument.
1413 */
1414 const SedOutput*
getOutput(unsigned int n) const1415 SedDocument::getOutput(unsigned int n) const
1416 {
1417 return mOutputs.get(n);
1418 }
1419
1420
1421 /*
1422 * Get a SedOutput from the SedDocument based on its identifier.
1423 */
1424 SedOutput*
getOutput(const std::string & sid)1425 SedDocument::getOutput(const std::string& sid)
1426 {
1427 return mOutputs.get(sid);
1428 }
1429
1430
1431 /*
1432 * Get a SedOutput from the SedDocument based on its identifier.
1433 */
1434 const SedOutput*
getOutput(const std::string & sid) const1435 SedDocument::getOutput(const std::string& sid) const
1436 {
1437 return mOutputs.get(sid);
1438 }
1439
1440
1441 /*
1442 * Adds a copy of the given SedOutput to this SedDocument.
1443 */
1444 int
addOutput(const SedOutput * so)1445 SedDocument::addOutput(const SedOutput* so)
1446 {
1447 if (so == NULL)
1448 {
1449 return LIBSEDML_OPERATION_FAILED;
1450 }
1451 else if (so->hasRequiredAttributes() == false)
1452 {
1453 return LIBSEDML_INVALID_OBJECT;
1454 }
1455 else if (getLevel() != so->getLevel())
1456 {
1457 return LIBSEDML_LEVEL_MISMATCH;
1458 }
1459 else if (getVersion() != so->getVersion())
1460 {
1461 return LIBSEDML_VERSION_MISMATCH;
1462 }
1463 else if (matchesRequiredSedNamespacesForAddition(static_cast<const
1464 SedBase*>(so)) == false)
1465 {
1466 return LIBSEDML_NAMESPACES_MISMATCH;
1467 }
1468 else if (so->isSetId() && (mOutputs.get(so->getId())) != NULL)
1469 {
1470 return LIBSEDML_DUPLICATE_OBJECT_ID;
1471 }
1472 else
1473 {
1474 return mOutputs.append(so);
1475 }
1476 }
1477
1478
1479 /*
1480 * Get the number of SedOutput objects in this SedDocument.
1481 */
1482 unsigned int
getNumOutputs() const1483 SedDocument::getNumOutputs() const
1484 {
1485 return mOutputs.size();
1486 }
1487
1488
1489 /*
1490 * Creates a new SedReport object, adds it to this SedDocument object and
1491 * returns the SedReport object created.
1492 */
1493 SedReport*
createReport()1494 SedDocument::createReport()
1495 {
1496 SedReport* sr = NULL;
1497
1498 try
1499 {
1500 sr = new SedReport(getSedNamespaces());
1501 }
1502 catch (...)
1503 {
1504 }
1505
1506 if (sr != NULL)
1507 {
1508 mOutputs.appendAndOwn(sr);
1509 }
1510
1511 return sr;
1512 }
1513
1514
1515 /*
1516 * Creates a new SedPlot2D object, adds it to this SedDocument object and
1517 * returns the SedPlot2D object created.
1518 */
1519 SedPlot2D*
createPlot2D()1520 SedDocument::createPlot2D()
1521 {
1522 SedPlot2D* spd = NULL;
1523
1524 try
1525 {
1526 spd = new SedPlot2D(getSedNamespaces());
1527 }
1528 catch (...)
1529 {
1530 }
1531
1532 if (spd != NULL)
1533 {
1534 mOutputs.appendAndOwn(spd);
1535 }
1536
1537 return spd;
1538 }
1539
1540
1541 /*
1542 * Creates a new SedPlot3D object, adds it to this SedDocument object and
1543 * returns the SedPlot3D object created.
1544 */
1545 SedPlot3D*
createPlot3D()1546 SedDocument::createPlot3D()
1547 {
1548 SedPlot3D* spd = NULL;
1549
1550 try
1551 {
1552 spd = new SedPlot3D(getSedNamespaces());
1553 }
1554 catch (...)
1555 {
1556 }
1557
1558 if (spd != NULL)
1559 {
1560 mOutputs.appendAndOwn(spd);
1561 }
1562
1563 return spd;
1564 }
1565
1566
1567 /*
1568 * Creates a new SedFigure object, adds it to this SedDocument object and
1569 * returns the SedFigure object created.
1570 */
1571 SedFigure*
createFigure()1572 SedDocument::createFigure()
1573 {
1574 SedFigure* sf = NULL;
1575
1576 try
1577 {
1578 sf = new SedFigure(getSedNamespaces());
1579 }
1580 catch (...)
1581 {
1582 }
1583
1584 if (sf != NULL)
1585 {
1586 mOutputs.appendAndOwn(sf);
1587 }
1588
1589 return sf;
1590 }
1591
1592
1593 /*
1594 * Creates a new SedParameterEstimationResultPlot object, adds it to this
1595 * SedDocument object and returns the SedParameterEstimationResultPlot object
1596 * created.
1597 */
1598 SedParameterEstimationResultPlot*
createParameterEstimationResultPlot()1599 SedDocument::createParameterEstimationResultPlot()
1600 {
1601 SedParameterEstimationResultPlot* sperp = NULL;
1602
1603 try
1604 {
1605 sperp = new SedParameterEstimationResultPlot(getSedNamespaces());
1606 }
1607 catch (...)
1608 {
1609 }
1610
1611 if (sperp != NULL)
1612 {
1613 mOutputs.appendAndOwn(sperp);
1614 }
1615
1616 return sperp;
1617 }
1618
1619
1620 /*
1621 * Removes the nth SedOutput from this SedDocument and returns a pointer to it.
1622 */
1623 SedOutput*
removeOutput(unsigned int n)1624 SedDocument::removeOutput(unsigned int n)
1625 {
1626 return mOutputs.remove(n);
1627 }
1628
1629
1630 /*
1631 * Removes the SedOutput from this SedDocument based on its identifier and
1632 * returns a pointer to it.
1633 */
1634 SedOutput*
removeOutput(const std::string & sid)1635 SedDocument::removeOutput(const std::string& sid)
1636 {
1637 return mOutputs.remove(sid);
1638 }
1639
1640
1641 /*
1642 * Returns the SedListOfStyles from this SedDocument.
1643 */
1644 const SedListOfStyles*
getListOfStyles() const1645 SedDocument::getListOfStyles() const
1646 {
1647 return &mStyles;
1648 }
1649
1650
1651 /*
1652 * Returns the SedListOfStyles from this SedDocument.
1653 */
1654 SedListOfStyles*
getListOfStyles()1655 SedDocument::getListOfStyles()
1656 {
1657 return &mStyles;
1658 }
1659
1660
1661 /*
1662 * Get a SedStyle from the SedDocument.
1663 */
1664 SedStyle*
getStyle(unsigned int n)1665 SedDocument::getStyle(unsigned int n)
1666 {
1667 return mStyles.get(n);
1668 }
1669
1670
1671 /*
1672 * Get a SedStyle from the SedDocument.
1673 */
1674 const SedStyle*
getStyle(unsigned int n) const1675 SedDocument::getStyle(unsigned int n) const
1676 {
1677 return mStyles.get(n);
1678 }
1679
1680
1681 /*
1682 * Get a SedStyle from the SedDocument based on its identifier.
1683 */
1684 SedStyle*
getStyle(const std::string & sid)1685 SedDocument::getStyle(const std::string& sid)
1686 {
1687 return mStyles.get(sid);
1688 }
1689
1690
1691 /*
1692 * Get a SedStyle from the SedDocument based on its identifier.
1693 */
1694 const SedStyle*
getStyle(const std::string & sid) const1695 SedDocument::getStyle(const std::string& sid) const
1696 {
1697 return mStyles.get(sid);
1698 }
1699
1700
1701 /*
1702 * Get a SedStyle from the SedDocument based on its identifier.
1703 */
1704 SedStyle
getEffectiveStyle(const std::string & sid) const1705 SedDocument::getEffectiveStyle(const std::string& sid) const
1706 {
1707 const SedStyle* top = mStyles.get(sid);
1708 if (top == NULL)
1709 {
1710 return SedStyle(mLevel, mVersion);
1711 }
1712 if (!top->isSetBaseStyle())
1713 {
1714 return SedStyle(*top);
1715 }
1716 SedStyle base = getEffectiveStyle(top->getBaseStyle());
1717 base.setId(top->getId());
1718 base.setName(top->getName());
1719 base.unsetBaseStyle();
1720
1721 if (top->isSetLineStyle())
1722 {
1723 if (base.isSetLineStyle())
1724 {
1725 const SedLine* topline = top->getLineStyle();
1726 SedLine* baseline = base.getLineStyle();
1727
1728 if (topline->isSetColor())
1729 {
1730 baseline->setColor(topline->getColor());
1731 }
1732
1733 if (topline->isSetType())
1734 {
1735 baseline->setType(topline->getType());
1736 }
1737
1738 if (topline->isSetThickness())
1739 {
1740 baseline->setThickness(topline->getThickness());
1741 }
1742 }
1743 else
1744 {
1745 base.setLineStyle(top->getLineStyle());
1746 }
1747 }
1748
1749 if (top->isSetMarkerStyle())
1750 {
1751 if (base.isSetMarkerStyle())
1752 {
1753 const SedMarker* topmarker = top->getMarkerStyle();
1754 SedMarker* basemarker = base.getMarkerStyle();
1755
1756 if (topmarker->isSetType())
1757 {
1758 basemarker->setType(topmarker->getType());
1759 }
1760
1761 if (topmarker->isSetSize())
1762 {
1763 basemarker->setSize(topmarker->getSize());
1764 }
1765
1766 if (topmarker->isSetFill())
1767 {
1768 basemarker->setFill(topmarker->getFill());
1769 }
1770
1771 if (topmarker->isSetLineColor())
1772 {
1773 basemarker->setLineColor(topmarker->getLineColor());
1774 }
1775
1776 if (topmarker->isSetLineThickness())
1777 {
1778 basemarker->setLineThickness(topmarker->getLineThickness());
1779 }
1780 }
1781 else
1782 {
1783 base.setMarkerStyle(top->getMarkerStyle());
1784 }
1785 }
1786
1787 if (top->isSetFillStyle())
1788 {
1789 if (base.isSetFillStyle())
1790 {
1791 const SedFill* topfill = top->getFillStyle();
1792 SedFill* basefill = base.getFillStyle();
1793
1794 if (topfill->isSetColor())
1795 {
1796 basefill->setColor(topfill->getColor());
1797 }
1798
1799 //if (topfill->isSetSecondColor())
1800 //{
1801 // basefill->setSecondColor(topfill->getSecondColor());
1802 //}
1803 }
1804 else
1805 {
1806 base.setFillStyle(top->getFillStyle());
1807 }
1808 }
1809 return base;
1810 }
1811
1812
1813 /*
1814 * Get a SedStyle from the SedDocument based on the BaseStyle to which it
1815 * refers.
1816 */
1817 const SedStyle*
getStyleByBaseStyle(const std::string & sid) const1818 SedDocument::getStyleByBaseStyle(const std::string& sid) const
1819 {
1820 return mStyles.getByBaseStyle(sid);
1821 }
1822
1823
1824 /*
1825 * Get a SedStyle from the SedDocument based on the BaseStyle to which it
1826 * refers.
1827 */
1828 SedStyle*
getStyleByBaseStyle(const std::string & sid)1829 SedDocument::getStyleByBaseStyle(const std::string& sid)
1830 {
1831 return mStyles.getByBaseStyle(sid);
1832 }
1833
1834
1835 /*
1836 * Adds a copy of the given SedStyle to this SedDocument.
1837 */
1838 int
addStyle(const SedStyle * ss)1839 SedDocument::addStyle(const SedStyle* ss)
1840 {
1841 if (ss == NULL)
1842 {
1843 return LIBSEDML_OPERATION_FAILED;
1844 }
1845 else if (ss->hasRequiredAttributes() == false)
1846 {
1847 return LIBSEDML_INVALID_OBJECT;
1848 }
1849 else if (getLevel() != ss->getLevel())
1850 {
1851 return LIBSEDML_LEVEL_MISMATCH;
1852 }
1853 else if (getVersion() != ss->getVersion())
1854 {
1855 return LIBSEDML_VERSION_MISMATCH;
1856 }
1857 else if (matchesRequiredSedNamespacesForAddition(static_cast<const
1858 SedBase*>(ss)) == false)
1859 {
1860 return LIBSEDML_NAMESPACES_MISMATCH;
1861 }
1862 else if (ss->isSetId() && (mStyles.get(ss->getId())) != NULL)
1863 {
1864 return LIBSEDML_DUPLICATE_OBJECT_ID;
1865 }
1866 else
1867 {
1868 return mStyles.append(ss);
1869 }
1870 }
1871
1872
1873 /*
1874 * Get the number of SedStyle objects in this SedDocument.
1875 */
1876 unsigned int
getNumStyles() const1877 SedDocument::getNumStyles() const
1878 {
1879 return mStyles.size();
1880 }
1881
1882
1883 /*
1884 * Creates a new SedStyle object, adds it to this SedDocument object and
1885 * returns the SedStyle object created.
1886 */
1887 SedStyle*
createStyle()1888 SedDocument::createStyle()
1889 {
1890 SedStyle* ss = NULL;
1891
1892 try
1893 {
1894 ss = new SedStyle(getSedNamespaces());
1895 }
1896 catch (...)
1897 {
1898 }
1899
1900 if (ss != NULL)
1901 {
1902 mStyles.appendAndOwn(ss);
1903 }
1904
1905 return ss;
1906 }
1907
1908
1909 /*
1910 * Removes the nth SedStyle from this SedDocument and returns a pointer to it.
1911 */
1912 SedStyle*
removeStyle(unsigned int n)1913 SedDocument::removeStyle(unsigned int n)
1914 {
1915 return mStyles.remove(n);
1916 }
1917
1918
1919 /*
1920 * Removes the SedStyle from this SedDocument based on its identifier and
1921 * returns a pointer to it.
1922 */
1923 SedStyle*
removeStyle(const std::string & sid)1924 SedDocument::removeStyle(const std::string& sid)
1925 {
1926 return mStyles.remove(sid);
1927 }
1928
1929
1930 /*
1931 * Returns the XML element name of this SedDocument object.
1932 */
1933 const std::string&
getElementName() const1934 SedDocument::getElementName() const
1935 {
1936 static const string name = "sedML";
1937 return name;
1938 }
1939
1940
1941 /*
1942 * Returns the libSEDML type code for this SedDocument object.
1943 */
1944 int
getTypeCode() const1945 SedDocument::getTypeCode() const
1946 {
1947 return SEDML_DOCUMENT;
1948 }
1949
1950
1951 /*
1952 * Predicate returning @c true if all the required attributes for this
1953 * SedDocument object have been set.
1954 */
1955 bool
hasRequiredAttributes() const1956 SedDocument::hasRequiredAttributes() const
1957 {
1958 bool allPresent = true;
1959
1960 if (isSetLevel() == false)
1961 {
1962 allPresent = false;
1963 }
1964
1965 if (isSetVersion() == false)
1966 {
1967 allPresent = false;
1968 }
1969
1970 return allPresent;
1971 }
1972
1973
1974
1975 /** @cond doxygenLibSEDMLInternal */
1976
1977 /*
1978 * Write any contained elements
1979 */
1980 void
writeElements(LIBSBML_CPP_NAMESPACE_QUALIFIER XMLOutputStream & stream) const1981 SedDocument::writeElements(LIBSBML_CPP_NAMESPACE_QUALIFIER XMLOutputStream&
1982 stream) const
1983 {
1984 SedBase::writeElements(stream);
1985
1986 if (getNumAlgorithmParameters() > 0 && (getLevel() > 1 || getVersion() >= 4))
1987 {
1988 mAlgorithmParameters.write(stream);
1989 }
1990
1991 if (getNumDataDescriptions() > 0)
1992 {
1993 mDataDescriptions.write(stream);
1994 }
1995
1996 if (getNumModels() > 0)
1997 {
1998 mModels.write(stream);
1999 }
2000
2001 if (getNumSimulations() > 0)
2002 {
2003 mSimulations.write(stream);
2004 }
2005
2006 if (getNumTasks() > 0)
2007 {
2008 mAbstractTasks.write(stream);
2009 }
2010
2011 if (getNumDataGenerators() > 0)
2012 {
2013 mDataGenerators.write(stream);
2014 }
2015
2016 if (getNumOutputs() > 0)
2017 {
2018 mOutputs.write(stream);
2019 }
2020
2021 if (getNumStyles() > 0)
2022 {
2023 mStyles.write(stream);
2024 }
2025 }
2026
2027 /** @endcond */
2028
2029
2030
2031 /** @cond doxygenLibSEDMLInternal */
2032
2033 /*
2034 * Accepts the given SedVisitor
2035 */
2036 bool
accept(SedVisitor & v) const2037 SedDocument::accept(SedVisitor& v) const
2038 {
2039 return false;
2040 }
2041
2042 /** @endcond */
2043
2044
2045
2046 /** @cond doxygenLibSEDMLInternal */
2047
2048 /*
2049 * Sets the parent SedDocument
2050 */
2051 void
setSedDocument(SedDocument * d)2052 SedDocument::setSedDocument(SedDocument* d)
2053 {
2054 SedBase::setSedDocument(d);
2055
2056 mAlgorithmParameters.setSedDocument(d);
2057
2058 mDataDescriptions.setSedDocument(d);
2059
2060 mModels.setSedDocument(d);
2061
2062 mSimulations.setSedDocument(d);
2063
2064 mAbstractTasks.setSedDocument(d);
2065
2066 mDataGenerators.setSedDocument(d);
2067
2068 mOutputs.setSedDocument(d);
2069
2070 mStyles.setSedDocument(d);
2071 }
2072
2073 /** @endcond */
2074
2075
2076
2077 /** @cond doxygenLibSEDMLInternal */
2078
2079 /*
2080 * Connects to child elements
2081 */
2082 void
connectToChild()2083 SedDocument::connectToChild()
2084 {
2085 SedBase::connectToChild();
2086
2087 mAlgorithmParameters.connectToParent(this);
2088
2089 mDataDescriptions.connectToParent(this);
2090
2091 mModels.connectToParent(this);
2092
2093 mSimulations.connectToParent(this);
2094
2095 mAbstractTasks.connectToParent(this);
2096
2097 mDataGenerators.connectToParent(this);
2098
2099 mOutputs.connectToParent(this);
2100
2101 mStyles.connectToParent(this);
2102 }
2103
2104 /** @endcond */
2105
2106
2107
2108 /** @cond doxygenLibSEDMLInternal */
2109
2110 /*
2111 * Gets the value of the "attributeName" attribute of this SedDocument.
2112 */
2113 int
getAttribute(const std::string & attributeName,bool & value) const2114 SedDocument::getAttribute(const std::string& attributeName, bool& value) const
2115 {
2116 int return_value = SedBase::getAttribute(attributeName, value);
2117
2118 return return_value;
2119 }
2120
2121 /** @endcond */
2122
2123
2124
2125 /** @cond doxygenLibSEDMLInternal */
2126
2127 /*
2128 * Gets the value of the "attributeName" attribute of this SedDocument.
2129 */
2130 int
getAttribute(const std::string & attributeName,int & value) const2131 SedDocument::getAttribute(const std::string& attributeName, int& value) const
2132 {
2133 int return_value = SedBase::getAttribute(attributeName, value);
2134
2135 return return_value;
2136 }
2137
2138 /** @endcond */
2139
2140
2141
2142 /** @cond doxygenLibSEDMLInternal */
2143
2144 /*
2145 * Gets the value of the "attributeName" attribute of this SedDocument.
2146 */
2147 int
getAttribute(const std::string & attributeName,double & value) const2148 SedDocument::getAttribute(const std::string& attributeName,
2149 double& value) const
2150 {
2151 int return_value = SedBase::getAttribute(attributeName, value);
2152
2153 return return_value;
2154 }
2155
2156 /** @endcond */
2157
2158
2159
2160 /** @cond doxygenLibSEDMLInternal */
2161
2162 /*
2163 * Gets the value of the "attributeName" attribute of this SedDocument.
2164 */
2165 int
getAttribute(const std::string & attributeName,unsigned int & value) const2166 SedDocument::getAttribute(const std::string& attributeName,
2167 unsigned int& value) const
2168 {
2169 int return_value = SedBase::getAttribute(attributeName, value);
2170
2171 if (return_value == LIBSEDML_OPERATION_SUCCESS)
2172 {
2173 return return_value;
2174 }
2175
2176 if (attributeName == "level")
2177 {
2178 value = getLevel();
2179 return_value = LIBSEDML_OPERATION_SUCCESS;
2180 }
2181 else if (attributeName == "version")
2182 {
2183 value = getVersion();
2184 return_value = LIBSEDML_OPERATION_SUCCESS;
2185 }
2186
2187 return return_value;
2188 }
2189
2190 /** @endcond */
2191
2192
2193
2194 /** @cond doxygenLibSEDMLInternal */
2195
2196 /*
2197 * Gets the value of the "attributeName" attribute of this SedDocument.
2198 */
2199 int
getAttribute(const std::string & attributeName,std::string & value) const2200 SedDocument::getAttribute(const std::string& attributeName,
2201 std::string& value) const
2202 {
2203 int return_value = SedBase::getAttribute(attributeName, value);
2204
2205 return return_value;
2206 }
2207
2208 /** @endcond */
2209
2210
2211
2212 /** @cond doxygenLibSEDMLInternal */
2213
2214 /*
2215 * Predicate returning @c true if this SedDocument's attribute "attributeName"
2216 * is set.
2217 */
2218 bool
isSetAttribute(const std::string & attributeName) const2219 SedDocument::isSetAttribute(const std::string& attributeName) const
2220 {
2221 bool value = SedBase::isSetAttribute(attributeName);
2222
2223 if (attributeName == "level")
2224 {
2225 value = isSetLevel();
2226 }
2227 else if (attributeName == "version")
2228 {
2229 value = isSetVersion();
2230 }
2231
2232 return value;
2233 }
2234
2235 /** @endcond */
2236
2237
2238
2239 /** @cond doxygenLibSEDMLInternal */
2240
2241 /*
2242 * Sets the value of the "attributeName" attribute of this SedDocument.
2243 */
2244 int
setAttribute(const std::string & attributeName,bool value)2245 SedDocument::setAttribute(const std::string& attributeName, bool value)
2246 {
2247 int return_value = SedBase::setAttribute(attributeName, value);
2248
2249 return return_value;
2250 }
2251
2252 /** @endcond */
2253
2254
2255
2256 /** @cond doxygenLibSEDMLInternal */
2257
2258 /*
2259 * Sets the value of the "attributeName" attribute of this SedDocument.
2260 */
2261 int
setAttribute(const std::string & attributeName,int value)2262 SedDocument::setAttribute(const std::string& attributeName, int value)
2263 {
2264 int return_value = SedBase::setAttribute(attributeName, value);
2265
2266 return return_value;
2267 }
2268
2269 /** @endcond */
2270
2271
2272
2273 /** @cond doxygenLibSEDMLInternal */
2274
2275 /*
2276 * Sets the value of the "attributeName" attribute of this SedDocument.
2277 */
2278 int
setAttribute(const std::string & attributeName,double value)2279 SedDocument::setAttribute(const std::string& attributeName, double value)
2280 {
2281 int return_value = SedBase::setAttribute(attributeName, value);
2282
2283 return return_value;
2284 }
2285
2286 /** @endcond */
2287
2288
2289
2290 /** @cond doxygenLibSEDMLInternal */
2291
2292 /*
2293 * Sets the value of the "attributeName" attribute of this SedDocument.
2294 */
2295 int
setAttribute(const std::string & attributeName,unsigned int value)2296 SedDocument::setAttribute(const std::string& attributeName,
2297 unsigned int value)
2298 {
2299 int return_value = SedBase::setAttribute(attributeName, value);
2300
2301 if (attributeName == "level")
2302 {
2303 return_value = setLevel(value);
2304 }
2305 else if (attributeName == "version")
2306 {
2307 return_value = setVersion(value);
2308 }
2309
2310 return return_value;
2311 }
2312
2313 /** @endcond */
2314
2315
2316
2317 /** @cond doxygenLibSEDMLInternal */
2318
2319 /*
2320 * Sets the value of the "attributeName" attribute of this SedDocument.
2321 */
2322 int
setAttribute(const std::string & attributeName,const std::string & value)2323 SedDocument::setAttribute(const std::string& attributeName,
2324 const std::string& value)
2325 {
2326 int return_value = SedBase::setAttribute(attributeName, value);
2327
2328 return return_value;
2329 }
2330
2331 /** @endcond */
2332
2333
2334
2335 /** @cond doxygenLibSEDMLInternal */
2336
2337 /*
2338 * Unsets the value of the "attributeName" attribute of this SedDocument.
2339 */
2340 int
unsetAttribute(const std::string & attributeName)2341 SedDocument::unsetAttribute(const std::string& attributeName)
2342 {
2343 int value = SedBase::unsetAttribute(attributeName);
2344
2345 if (attributeName == "level")
2346 {
2347 value = unsetLevel();
2348 }
2349 else if (attributeName == "version")
2350 {
2351 value = unsetVersion();
2352 }
2353
2354 return value;
2355 }
2356
2357 /** @endcond */
2358
2359
2360
2361 /** @cond doxygenLibSEDMLInternal */
2362
2363 /*
2364 * Creates and returns an new "elementName" object in this SedDocument.
2365 */
2366 SedBase*
createChildObject(const std::string & elementName)2367 SedDocument::createChildObject(const std::string& elementName)
2368 {
2369 SedBase* obj = NULL;
2370
2371 if (elementName == "algorithmParameter")
2372 {
2373 return createAlgorithmParameter();
2374 }
2375
2376 if (elementName == "dataDescription")
2377 {
2378 return createDataDescription();
2379 }
2380 else if (elementName == "model")
2381 {
2382 return createModel();
2383 }
2384 else if (elementName == "uniformTimeCourse")
2385 {
2386 return createUniformTimeCourse();
2387 }
2388 else if (elementName == "oneStep")
2389 {
2390 return createOneStep();
2391 }
2392 else if (elementName == "steadyState")
2393 {
2394 return createSteadyState();
2395 }
2396 else if (elementName == "analysis")
2397 {
2398 return createAnalysis();
2399 }
2400 else if (elementName == "task")
2401 {
2402 return createTask();
2403 }
2404 else if (elementName == "repeatedTask")
2405 {
2406 return createRepeatedTask();
2407 }
2408 else if (elementName == "parameterEstimationTask")
2409 {
2410 return createParameterEstimationTask();
2411 }
2412 else if (elementName == "dataGenerator")
2413 {
2414 return createDataGenerator();
2415 }
2416 else if (elementName == "report")
2417 {
2418 return createReport();
2419 }
2420 else if (elementName == "plot2D")
2421 {
2422 return createPlot2D();
2423 }
2424 else if (elementName == "plot3D")
2425 {
2426 return createPlot3D();
2427 }
2428 else if (elementName == "figure")
2429 {
2430 return createFigure();
2431 }
2432 else if (elementName == "parameterEstimationResultPlot")
2433 {
2434 return createParameterEstimationResultPlot();
2435 }
2436 else if (elementName == "style")
2437 {
2438 return createStyle();
2439 }
2440
2441 return obj;
2442 }
2443
2444 /** @endcond */
2445
2446
2447
2448 /** @cond doxygenLibSEDMLInternal */
2449
2450 /*
2451 * Adds a new "elementName" object to this SedDocument.
2452 */
2453 int
addChildObject(const std::string & elementName,const SedBase * element)2454 SedDocument::addChildObject(const std::string& elementName,
2455 const SedBase* element)
2456 {
2457 if (elementName == "algorithmParameter" && element->getTypeCode() ==
2458 SEDML_SIMULATION_ALGORITHM_PARAMETER)
2459 {
2460 return addAlgorithmParameter((const SedAlgorithmParameter*)(element));
2461 }
2462 else if (elementName == "dataDescription" && element->getTypeCode() ==
2463 SEDML_DATA_DESCRIPTION)
2464 {
2465 return addDataDescription((const SedDataDescription*)(element));
2466 }
2467 else if (elementName == "model" && element->getTypeCode() == SEDML_MODEL)
2468 {
2469 return addModel((const SedModel*)(element));
2470 }
2471 else if (elementName == "uniformTimeCourse" && element->getTypeCode() ==
2472 SEDML_SIMULATION_UNIFORMTIMECOURSE)
2473 {
2474 return addSimulation((const SedSimulation*)(element));
2475 }
2476 else if (elementName == "oneStep" && element->getTypeCode() ==
2477 SEDML_SIMULATION_ONESTEP)
2478 {
2479 return addSimulation((const SedSimulation*)(element));
2480 }
2481 else if (elementName == "steadyState" && element->getTypeCode() ==
2482 SEDML_SIMULATION_STEADYSTATE)
2483 {
2484 return addSimulation((const SedSimulation*)(element));
2485 }
2486 else if (elementName == "analysis" && element->getTypeCode() ==
2487 SEDML_SIMULATION_ANALYSIS)
2488 {
2489 return addSimulation((const SedSimulation*)(element));
2490 }
2491 else if (elementName == "task" && element->getTypeCode() == SEDML_TASK)
2492 {
2493 return addTask((const SedAbstractTask*)(element));
2494 }
2495 else if (elementName == "repeatedTask" && element->getTypeCode() ==
2496 SEDML_TASK_REPEATEDTASK)
2497 {
2498 return addTask((const SedAbstractTask*)(element));
2499 }
2500 else if (elementName == "parameterEstimationTask" && element->getTypeCode()
2501 == SEDML_TASK_PARAMETER_ESTIMATION)
2502 {
2503 return addTask((const SedAbstractTask*)(element));
2504 }
2505 else if (elementName == "dataGenerator" && element->getTypeCode() ==
2506 SEDML_DATAGENERATOR)
2507 {
2508 return addDataGenerator((const SedDataGenerator*)(element));
2509 }
2510 else if (elementName == "report" && element->getTypeCode() ==
2511 SEDML_OUTPUT_REPORT)
2512 {
2513 return addOutput((const SedOutput*)(element));
2514 }
2515 else if (elementName == "plot2D" && element->getTypeCode() ==
2516 SEDML_OUTPUT_PLOT2D)
2517 {
2518 return addOutput((const SedOutput*)(element));
2519 }
2520 else if (elementName == "plot3D" && element->getTypeCode() ==
2521 SEDML_OUTPUT_PLOT3D)
2522 {
2523 return addOutput((const SedOutput*)(element));
2524 }
2525 else if (elementName == "figure" && element->getTypeCode() == SEDML_FIGURE)
2526 {
2527 return addOutput((const SedOutput*)(element));
2528 }
2529 else if (elementName == "parameterEstimationResultPlot" &&
2530 element->getTypeCode() == SEDML_PARAMETERESTIMATIONRESULTPLOT)
2531 {
2532 return addOutput((const SedOutput*)(element));
2533 }
2534 else if (elementName == "style" && element->getTypeCode() == SEDML_STYLE)
2535 {
2536 return addStyle((const SedStyle*)(element));
2537 }
2538
2539 return LIBSBML_OPERATION_FAILED;
2540 }
2541
2542 /** @endcond */
2543
2544
2545
2546 /** @cond doxygenLibSEDMLInternal */
2547
2548 /*
2549 * Removes and returns the new "elementName" object with the given id in this
2550 * SedDocument.
2551 */
2552 SedBase*
removeChildObject(const std::string & elementName,const std::string & id)2553 SedDocument::removeChildObject(const std::string& elementName,
2554 const std::string& id)
2555 {
2556 if (elementName == "algorithmParameter")
2557 {
2558 return removeAlgorithmParameter(id);
2559 }
2560 if (elementName == "dataDescription")
2561 {
2562 return removeDataDescription(id);
2563 }
2564 else if (elementName == "model")
2565 {
2566 return removeModel(id);
2567 }
2568 else if (elementName == "uniformTimeCourse")
2569 {
2570 return removeSimulation(id);
2571 }
2572 else if (elementName == "oneStep")
2573 {
2574 return removeSimulation(id);
2575 }
2576 else if (elementName == "steadyState")
2577 {
2578 return removeSimulation(id);
2579 }
2580 else if (elementName == "analysis")
2581 {
2582 return removeSimulation(id);
2583 }
2584 else if (elementName == "task")
2585 {
2586 return removeTask(id);
2587 }
2588 else if (elementName == "repeatedTask")
2589 {
2590 return removeTask(id);
2591 }
2592 else if (elementName == "parameterEstimationTask")
2593 {
2594 return removeTask(id);
2595 }
2596 else if (elementName == "dataGenerator")
2597 {
2598 return removeDataGenerator(id);
2599 }
2600 else if (elementName == "report")
2601 {
2602 return removeOutput(id);
2603 }
2604 else if (elementName == "plot2D")
2605 {
2606 return removeOutput(id);
2607 }
2608 else if (elementName == "plot3D")
2609 {
2610 return removeOutput(id);
2611 }
2612 else if (elementName == "figure")
2613 {
2614 return removeOutput(id);
2615 }
2616 else if (elementName == "parameterEstimationResultPlot")
2617 {
2618 return removeOutput(id);
2619 }
2620 else if (elementName == "style")
2621 {
2622 return removeStyle(id);
2623 }
2624
2625 return NULL;
2626 }
2627
2628 /** @endcond */
2629
2630
2631
2632 /** @cond doxygenLibSEDMLInternal */
2633
2634 /*
2635 * Returns the number of "elementName" in this SedDocument.
2636 */
2637 unsigned int
getNumObjects(const std::string & elementName)2638 SedDocument::getNumObjects(const std::string& elementName)
2639 {
2640 unsigned int n = 0;
2641
2642 if (elementName == "algorithmParameter")
2643 {
2644 return getNumAlgorithmParameters();
2645 }
2646 else if (elementName == "dataDescription")
2647 {
2648 return getNumDataDescriptions();
2649 }
2650 else if (elementName == "model")
2651 {
2652 return getNumModels();
2653 }
2654 else if (elementName == "simulation")
2655 {
2656 return getNumSimulations();
2657 }
2658 else if (elementName == "task")
2659 {
2660 return getNumTasks();
2661 }
2662 else if (elementName == "dataGenerator")
2663 {
2664 return getNumDataGenerators();
2665 }
2666 else if (elementName == "output")
2667 {
2668 return getNumOutputs();
2669 }
2670 else if (elementName == "style")
2671 {
2672 return getNumStyles();
2673 }
2674
2675 return n;
2676 }
2677
2678 /** @endcond */
2679
2680
2681
2682 /** @cond doxygenLibSEDMLInternal */
2683
2684 /*
2685 * Returns the nth object of "objectName" in this SedDocument.
2686 */
2687 SedBase*
getObject(const std::string & elementName,unsigned int index)2688 SedDocument::getObject(const std::string& elementName, unsigned int index)
2689 {
2690 SedBase* obj = NULL;
2691
2692 if (elementName == "algorithmParameter")
2693 {
2694 return getAlgorithmParameter(index);
2695 }
2696 else if (elementName == "dataDescription")
2697 {
2698 return getDataDescription(index);
2699 }
2700 else if (elementName == "model")
2701 {
2702 return getModel(index);
2703 }
2704 else if (elementName == "simulation")
2705 {
2706 return getSimulation(index);
2707 }
2708 else if (elementName == "task")
2709 {
2710 return getTask(index);
2711 }
2712 else if (elementName == "dataGenerator")
2713 {
2714 return getDataGenerator(index);
2715 }
2716 else if (elementName == "output")
2717 {
2718 return getOutput(index);
2719 }
2720 else if (elementName == "style")
2721 {
2722 return getStyle(index);
2723 }
2724
2725 return obj;
2726 }
2727
2728 /** @endcond */
2729
2730
2731 /*
2732 * Returns the first child element that has the given @p id in the model-wide
2733 * SId namespace, or @c NULL if no such object is found.
2734 */
2735 SedBase*
getElementBySId(const std::string & id)2736 SedDocument::getElementBySId(const std::string& id)
2737 {
2738 if (id.empty())
2739 {
2740 return NULL;
2741 }
2742
2743 SedBase* obj = NULL;
2744
2745 obj = mAlgorithmParameters.getElementBySId(id);
2746
2747 if (obj != NULL)
2748 {
2749 return obj;
2750 }
2751
2752 obj = mDataDescriptions.getElementBySId(id);
2753
2754 if (obj != NULL)
2755 {
2756 return obj;
2757 }
2758
2759 obj = mModels.getElementBySId(id);
2760
2761 if (obj != NULL)
2762 {
2763 return obj;
2764 }
2765
2766 obj = mSimulations.getElementBySId(id);
2767
2768 if (obj != NULL)
2769 {
2770 return obj;
2771 }
2772
2773 obj = mAbstractTasks.getElementBySId(id);
2774
2775 if (obj != NULL)
2776 {
2777 return obj;
2778 }
2779
2780 obj = mDataGenerators.getElementBySId(id);
2781
2782 if (obj != NULL)
2783 {
2784 return obj;
2785 }
2786
2787 obj = mOutputs.getElementBySId(id);
2788
2789 if (obj != NULL)
2790 {
2791 return obj;
2792 }
2793
2794 obj = mStyles.getElementBySId(id);
2795
2796 if (obj != NULL)
2797 {
2798 return obj;
2799 }
2800
2801 return obj;
2802 }
2803
2804
2805 /*
2806 * Returns a List of all child SedBase objects, including those nested to an
2807 * arbitrary depth.
2808 */
2809 List*
getAllElements(SedElementFilter * filter)2810 SedDocument::getAllElements(SedElementFilter* filter)
2811 {
2812 List* ret = new List();
2813 List* sublist = NULL;
2814
2815 SED_ADD_FILTERED_LIST(ret, sublist, mAlgorithmParameters, filter);
2816 SED_ADD_FILTERED_LIST(ret, sublist, mDataDescriptions, filter);
2817 SED_ADD_FILTERED_LIST(ret, sublist, mModels, filter);
2818 SED_ADD_FILTERED_LIST(ret, sublist, mSimulations, filter);
2819 SED_ADD_FILTERED_LIST(ret, sublist, mAbstractTasks, filter);
2820 SED_ADD_FILTERED_LIST(ret, sublist, mDataGenerators, filter);
2821 SED_ADD_FILTERED_LIST(ret, sublist, mOutputs, filter);
2822 SED_ADD_FILTERED_LIST(ret, sublist, mStyles, filter);
2823
2824 return ret;
2825 }
2826
2827
2828 /*
2829 * Returns the value of the "Namespaces" element of this SedDocument.
2830 */
2831 const LIBSBML_CPP_NAMESPACE_QUALIFIER XMLNamespaces*
getNamespaces() const2832 SedDocument::getNamespaces() const
2833 {
2834 return mSedNamespaces->getNamespaces();
2835 }
2836
2837
2838 /*
2839 * Returns the value of the "Namespaces" element of this SedDocument.
2840 */
2841 LIBSBML_CPP_NAMESPACE_QUALIFIER XMLNamespaces*
getNamespaces()2842 SedDocument::getNamespaces()
2843 {
2844 return mSedNamespaces->getNamespaces();
2845 }
2846
2847
2848 /*
2849 * Returns the value of the "SedErrorLog" element of this SedDocument.
2850 */
2851 const SedErrorLog*
getErrorLog() const2852 SedDocument::getErrorLog() const
2853 {
2854 return &mErrorLog;
2855 }
2856
2857
2858 /*
2859 * Returns the value of the "SedErrorLog" element of this SedDocument.
2860 */
2861 SedErrorLog*
getErrorLog()2862 SedDocument::getErrorLog()
2863 {
2864 return &mErrorLog;
2865 }
2866
2867
2868 /*
2869 * Get a SedError from the SedDocument.
2870 */
2871 SedError*
getError(unsigned int n)2872 SedDocument::getError(unsigned int n)
2873 {
2874 return const_cast<SedError*>(mErrorLog.getError(n));
2875 }
2876
2877
2878 /*
2879 * Get a SedError from the SedDocument.
2880 */
2881 const SedError*
getError(unsigned int n) const2882 SedDocument::getError(unsigned int n) const
2883 {
2884 return mErrorLog.getError(n);
2885 }
2886
2887
2888 /*
2889 * Get the number of SedError objects in this SedDocument.
2890 */
2891 unsigned int
getNumErrors() const2892 SedDocument::getNumErrors() const
2893 {
2894 return mErrorLog.getNumErrors();
2895 }
2896
2897
2898 /*
2899 * Get the number of SedError objects in this SedDocument with the given
2900 * severity.
2901 */
2902 unsigned int
getNumErrors(unsigned int severity) const2903 SedDocument::getNumErrors(unsigned int severity) const
2904 {
2905 return getErrorLog()->getNumFailsWithSeverity(severity);
2906 }
2907
sortOrderedObjects()2908 void SedDocument::sortOrderedObjects()
2909 {
2910 for (unsigned int o = 0; o < mOutputs.size(); o++)
2911 {
2912 SedOutput* output = mOutputs.get(o);
2913 int type = output->getTypeCode();
2914 if (type == SEDML_OUTPUT_PLOT2D)
2915 {
2916 SedPlot2D* sp2d = static_cast<SedPlot2D*>(output);
2917 sp2d->getListOfCurves()->sort();
2918 }
2919 else if (type == SEDML_OUTPUT_PLOT3D)
2920 {
2921 SedPlot3D* sp3d = static_cast<SedPlot3D*>(output);
2922 sp3d->getListOfSurfaces()->sort();
2923 }
2924 }
2925 for (unsigned int t = 0; t < mAbstractTasks.size(); t++)
2926 {
2927 SedAbstractTask* task = mAbstractTasks.get(t);
2928 int type = task->getTypeCode();
2929 if (type == SEDML_TASK_REPEATEDTASK)
2930 {
2931 SedRepeatedTask* rtask = static_cast<SedRepeatedTask*>(task);
2932 rtask->getListOfSubTasks()->sort();
2933 }
2934 }
2935 }
2936
2937
2938
2939 /** @cond doxygenLibSEDMLInternal */
2940
2941 /*
2942 * Creates a new object from the next XMLToken on the XMLInputStream
2943 */
2944 SedBase*
createObject(LIBSBML_CPP_NAMESPACE_QUALIFIER XMLInputStream & stream)2945 SedDocument::createObject(LIBSBML_CPP_NAMESPACE_QUALIFIER XMLInputStream&
2946 stream)
2947 {
2948 SedBase* obj = NULL;
2949
2950 const std::string& name = stream.peek().getName();
2951
2952 if (name == "listOfAlgorithmParameters")
2953 {
2954 if (getErrorLog() && mAlgorithmParameters.size() != 0)
2955 {
2956 getErrorLog()->logError(SedmlAlgorithmAllowedElements, getLevel(),
2957 getVersion(), "", getLine(), getColumn());
2958 }
2959
2960 obj = &mAlgorithmParameters;
2961 }
2962 else if (name == "listOfDataDescriptions")
2963 {
2964 if (getErrorLog() && mDataDescriptions.size() != 0)
2965 {
2966 getErrorLog()->logError(SedmlDocumentAllowedElements, getLevel(),
2967 getVersion(), "", getLine(), getColumn());
2968 }
2969
2970 obj = &mDataDescriptions;
2971 }
2972 else if (name == "listOfModels")
2973 {
2974 if (getErrorLog() && mModels.size() != 0)
2975 {
2976 getErrorLog()->logError(SedmlDocumentAllowedElements, getLevel(),
2977 getVersion(), "", getLine(), getColumn());
2978 }
2979
2980 obj = &mModels;
2981 }
2982 else if (name == "listOfSimulations")
2983 {
2984 if (getErrorLog() && mSimulations.size() != 0)
2985 {
2986 getErrorLog()->logError(SedmlDocumentAllowedElements, getLevel(),
2987 getVersion(), "", getLine(), getColumn());
2988 }
2989
2990 obj = &mSimulations;
2991 }
2992 else if (name == "listOfTasks")
2993 {
2994 if (getErrorLog() && mAbstractTasks.size() != 0)
2995 {
2996 getErrorLog()->logError(SedmlDocumentAllowedElements, getLevel(),
2997 getVersion(), "", getLine(), getColumn());
2998 }
2999
3000 obj = &mAbstractTasks;
3001 }
3002 else if (name == "listOfDataGenerators")
3003 {
3004 if (getErrorLog() && mDataGenerators.size() != 0)
3005 {
3006 getErrorLog()->logError(SedmlDocumentAllowedElements, getLevel(),
3007 getVersion(), "", getLine(), getColumn());
3008 }
3009
3010 obj = &mDataGenerators;
3011 }
3012 else if (name == "listOfOutputs")
3013 {
3014 if (getErrorLog() && mOutputs.size() != 0)
3015 {
3016 getErrorLog()->logError(SedmlDocumentAllowedElements, getLevel(),
3017 getVersion(), "", getLine(), getColumn());
3018 }
3019
3020 obj = &mOutputs;
3021 }
3022 else if (name == "listOfStyles")
3023 {
3024 if (getErrorLog() && mStyles.size() != 0)
3025 {
3026 getErrorLog()->logError(SedmlDocumentAllowedElements, getLevel(),
3027 getVersion(), "", getLine(), getColumn());
3028 }
3029
3030 obj = &mStyles;
3031 }
3032
3033 connectToChild();
3034
3035 return obj;
3036 }
3037
3038 /** @endcond */
3039
3040
3041
3042 /** @cond doxygenLibSEDMLInternal */
3043
3044 /*
3045 * Adds the expected attributes for this element
3046 */
3047 void
addExpectedAttributes(LIBSBML_CPP_NAMESPACE_QUALIFIER ExpectedAttributes & attributes)3048 SedDocument::addExpectedAttributes(LIBSBML_CPP_NAMESPACE_QUALIFIER
3049 ExpectedAttributes& attributes)
3050 {
3051 SedBase::addExpectedAttributes(attributes);
3052
3053 attributes.add("level");
3054
3055 attributes.add("version");
3056 }
3057
3058 /** @endcond */
3059
3060
3061
3062 /** @cond doxygenLibSEDMLInternal */
3063
3064 /*
3065 * Reads the expected attributes into the member data variables
3066 */
3067 void
readAttributes(const LIBSBML_CPP_NAMESPACE_QUALIFIER XMLAttributes & attributes,const LIBSBML_CPP_NAMESPACE_QUALIFIER ExpectedAttributes & expectedAttributes)3068 SedDocument::readAttributes(
3069 const LIBSBML_CPP_NAMESPACE_QUALIFIER
3070 XMLAttributes& attributes,
3071 const LIBSBML_CPP_NAMESPACE_QUALIFIER
3072 ExpectedAttributes& expectedAttributes)
3073 {
3074 unsigned int level = getLevel();
3075 unsigned int version = getVersion();
3076 unsigned int numErrs;
3077 bool assigned = false;
3078 SedErrorLog* log = getErrorLog();
3079
3080 SedBase::readAttributes(attributes, expectedAttributes);
3081
3082 if (log)
3083 {
3084 numErrs = log->getNumErrors();
3085
3086 for (int n = numErrs-1; n >= 0; n--)
3087 {
3088 if (log->getError(n)->getErrorId() == SedUnknownCoreAttribute)
3089 {
3090 const std::string details = log->getError(n)->getMessage();
3091 log->remove(SedUnknownCoreAttribute);
3092 log->logError(SedmlDocumentAllowedAttributes, level, version, details,
3093 getLine(), getColumn());
3094 }
3095 }
3096 }
3097
3098 //
3099 // level uint (use = "required" )
3100 //
3101
3102 numErrs = log ? log->getNumErrors() : 0;
3103 mIsSetLevel = attributes.readInto("level", mLevel);
3104
3105 if ( mIsSetLevel == false && log)
3106 {
3107 if (log && log->getNumErrors() == numErrs + 1 &&
3108 log->contains(XMLAttributeTypeMismatch))
3109 {
3110 log->remove(XMLAttributeTypeMismatch);
3111 std::string message = "Sedml attribute 'level' from the <SedDocument> "
3112 "element must be an integer.";
3113 log->logError(SedmlDocumentLevelMustBeNonNegativeInteger, level, version,
3114 message, getLine(), getColumn());
3115 }
3116 else
3117 {
3118 std::string message = "Sedml attribute 'level' is missing from the "
3119 "<SedDocument> element.";
3120 log->logError(SedmlDocumentAllowedAttributes, level, version, message,
3121 getLine(), getColumn());
3122 }
3123 }
3124
3125 //
3126 // version uint (use = "required" )
3127 //
3128
3129 numErrs = log ? log->getNumErrors() : 0;
3130 mIsSetVersion = attributes.readInto("version", mVersion);
3131
3132 if ( mIsSetVersion == false && log)
3133 {
3134 if (log && log->getNumErrors() == numErrs + 1 &&
3135 log->contains(XMLAttributeTypeMismatch))
3136 {
3137 log->remove(XMLAttributeTypeMismatch);
3138 std::string message = "Sedml attribute 'version' from the <SedDocument> "
3139 "element must be an integer.";
3140 log->logError(SedmlDocumentVersionMustBeNonNegativeInteger, level,
3141 version, message, getLine(), getColumn());
3142 }
3143 else
3144 {
3145 std::string message = "Sedml attribute 'version' is missing from the "
3146 "<SedDocument> element.";
3147 log->logError(SedmlDocumentAllowedAttributes, level, version, message,
3148 getLine(), getColumn());
3149 }
3150 }
3151 }
3152
3153 /** @endcond */
3154
3155
3156
3157 /** @cond doxygenLibSEDMLInternal */
3158
3159 /*
3160 * Writes the attributes to the stream
3161 */
3162 void
writeAttributes(LIBSBML_CPP_NAMESPACE_QUALIFIER XMLOutputStream & stream) const3163 SedDocument::writeAttributes(LIBSBML_CPP_NAMESPACE_QUALIFIER XMLOutputStream&
3164 stream) const
3165 {
3166 SedBase::writeAttributes(stream);
3167
3168 if (isSetLevel() == true)
3169 {
3170 stream.writeAttribute("level", getPrefix(), mLevel);
3171 }
3172
3173 if (isSetVersion() == true)
3174 {
3175 stream.writeAttribute("version", getPrefix(), mVersion);
3176 }
3177 }
3178
3179 /** @endcond */
3180
3181
3182
3183 /** @cond doxygenLibSEDMLInternal */
3184
3185 /*
3186 * Writes the namespace for the Sedml package
3187 */
3188 void
writeXMLNS(LIBSBML_CPP_NAMESPACE_QUALIFIER XMLOutputStream & stream) const3189 SedDocument::writeXMLNS(LIBSBML_CPP_NAMESPACE_QUALIFIER XMLOutputStream&
3190 stream) const
3191 {
3192 // need to check that we have indeed a namespace set!
3193 LIBSBML_CPP_NAMESPACE_QUALIFIER XMLNamespaces * thisNs =
3194 const_cast<LIBSBML_CPP_NAMESPACE_QUALIFIER XMLNamespaces *>(getNamespaces());
3195
3196 // the SED-ML namespace is missing - add it
3197 if (thisNs == NULL)
3198 {
3199 XMLNamespaces xmlns;
3200
3201 if (getVersion() == 1)
3202 xmlns.add(SEDML_XMLNS_L1V1);
3203 else if (getVersion() == 2)
3204 xmlns.add(SEDML_XMLNS_L1V2);
3205 else if (getVersion() == 3)
3206 xmlns.add(SEDML_XMLNS_L1V3);
3207 else
3208 xmlns.add(SEDML_XMLNS_L1V4);
3209
3210 mSedNamespaces->setNamespaces(&xmlns);
3211 thisNs = const_cast<LIBSBML_CPP_NAMESPACE_QUALIFIER XMLNamespaces *>(getNamespaces());
3212 }
3213 else if (thisNs->getLength() == 0)
3214 {
3215 if (getVersion() == 1)
3216 thisNs->add(SEDML_XMLNS_L1V1);
3217 else if (getVersion() == 2)
3218 thisNs->add(SEDML_XMLNS_L1V2);
3219 else if (getVersion() == 3)
3220 thisNs->add(SEDML_XMLNS_L1V3);
3221 else
3222 thisNs->add(SEDML_XMLNS_L1V4);
3223 }
3224 else
3225 {
3226 // check that there is an SED-ML namespace
3227 std::string sedmlURI = SedNamespaces::getSedNamespaceURI(getLevel(), getVersion());
3228 std::string sedmlPrefix = thisNs->getPrefix(sedmlURI);
3229
3230 if (thisNs->hasNS(sedmlURI, sedmlPrefix) == false)
3231 {
3232 // the SED-ML ns is not present
3233 std::string other = thisNs->getURI(sedmlPrefix);
3234
3235 if (other.empty() == false)
3236 {
3237 // there is another ns with the prefix that the SED-ML ns expects to have
3238 //remove the this ns, add the sbml ns and
3239 //add the new ns with a new prefix
3240 thisNs->remove(sedmlPrefix);
3241 thisNs->add(sedmlURI, sedmlPrefix);
3242 thisNs->add(other, "addedPrefix");
3243 }
3244 else
3245 {
3246 thisNs->add(sedmlURI, sedmlPrefix);
3247 }
3248 }
3249 }
3250
3251 XMLNamespaces * xmlns = thisNs->clone();
3252
3253 if (xmlns != NULL)
3254 {
3255 stream << *(xmlns);
3256 delete xmlns;
3257 }
3258
3259 }
3260
3261 /** @endcond */
3262
3263
3264
3265
3266 #endif /* __cplusplus */
3267
3268
3269 /*
3270 * Creates a new SedDocument_t using the given SED-ML Level and @ p version
3271 * values.
3272 */
3273 LIBSEDML_EXTERN
3274 SedDocument_t *
SedDocument_create(unsigned int level,unsigned int version)3275 SedDocument_create(unsigned int level, unsigned int version)
3276 {
3277 return new SedDocument(level, version);
3278 }
3279
3280
3281 /*
3282 * Creates and returns a deep copy of this SedDocument_t object.
3283 */
3284 LIBSEDML_EXTERN
3285 SedDocument_t*
SedDocument_clone(const SedDocument_t * sd)3286 SedDocument_clone(const SedDocument_t* sd)
3287 {
3288 if (sd != NULL)
3289 {
3290 return static_cast<SedDocument_t*>(sd->clone());
3291 }
3292 else
3293 {
3294 return NULL;
3295 }
3296 }
3297
3298
3299 /*
3300 * Frees this SedDocument_t object.
3301 */
3302 LIBSEDML_EXTERN
3303 void
SedDocument_free(SedDocument_t * sd)3304 SedDocument_free(SedDocument_t* sd)
3305 {
3306 if (sd != NULL)
3307 {
3308 delete sd;
3309 }
3310 }
3311
3312
3313 /*
3314 * Returns the value of the "level" attribute of this SedDocument_t.
3315 */
3316 LIBSEDML_EXTERN
3317 unsigned int
SedDocument_getLevel(const SedDocument_t * sd)3318 SedDocument_getLevel(const SedDocument_t * sd)
3319 {
3320 return (sd != NULL) ? sd->getLevel() : SEDML_INT_MAX;
3321 }
3322
3323
3324 /*
3325 * Returns the value of the "version" attribute of this SedDocument_t.
3326 */
3327 LIBSEDML_EXTERN
3328 unsigned int
SedDocument_getVersion(const SedDocument_t * sd)3329 SedDocument_getVersion(const SedDocument_t * sd)
3330 {
3331 return (sd != NULL) ? sd->getVersion() : SEDML_INT_MAX;
3332 }
3333
3334
3335 /*
3336 * Predicate returning @c 1 (true) if this SedDocument_t's "level" attribute is
3337 * set.
3338 */
3339 LIBSEDML_EXTERN
3340 int
SedDocument_isSetLevel(const SedDocument_t * sd)3341 SedDocument_isSetLevel(const SedDocument_t * sd)
3342 {
3343 return (sd != NULL) ? static_cast<int>(sd->isSetLevel()) : 0;
3344 }
3345
3346
3347 /*
3348 * Predicate returning @c 1 (true) if this SedDocument_t's "version" attribute
3349 * is set.
3350 */
3351 LIBSEDML_EXTERN
3352 int
SedDocument_isSetVersion(const SedDocument_t * sd)3353 SedDocument_isSetVersion(const SedDocument_t * sd)
3354 {
3355 return (sd != NULL) ? static_cast<int>(sd->isSetVersion()) : 0;
3356 }
3357
3358
3359 /*
3360 * Sets the value of the "level" attribute of this SedDocument_t.
3361 */
3362 LIBSEDML_EXTERN
3363 int
SedDocument_setLevel(SedDocument_t * sd,unsigned int level)3364 SedDocument_setLevel(SedDocument_t * sd, unsigned int level)
3365 {
3366 return (sd != NULL) ? sd->setLevel(level) : LIBSEDML_INVALID_OBJECT;
3367 }
3368
3369
3370 /*
3371 * Sets the value of the "version" attribute of this SedDocument_t.
3372 */
3373 LIBSEDML_EXTERN
3374 int
SedDocument_setVersion(SedDocument_t * sd,unsigned int version)3375 SedDocument_setVersion(SedDocument_t * sd, unsigned int version)
3376 {
3377 return (sd != NULL) ? sd->setVersion(version) : LIBSEDML_INVALID_OBJECT;
3378 }
3379
3380
3381 /*
3382 * Unsets the value of the "level" attribute of this SedDocument_t.
3383 */
3384 LIBSEDML_EXTERN
3385 int
SedDocument_unsetLevel(SedDocument_t * sd)3386 SedDocument_unsetLevel(SedDocument_t * sd)
3387 {
3388 return (sd != NULL) ? sd->unsetLevel() : LIBSEDML_INVALID_OBJECT;
3389 }
3390
3391
3392 /*
3393 * Unsets the value of the "version" attribute of this SedDocument_t.
3394 */
3395 LIBSEDML_EXTERN
3396 int
SedDocument_unsetVersion(SedDocument_t * sd)3397 SedDocument_unsetVersion(SedDocument_t * sd)
3398 {
3399 return (sd != NULL) ? sd->unsetVersion() : LIBSEDML_INVALID_OBJECT;
3400 }
3401
3402
3403 /*
3404 * Returns a ListOf_t * containing SedDataDescription_t objects from this
3405 * SedDocument_t.
3406 */
3407 LIBSEDML_EXTERN
3408 SedListOf_t*
SedDocument_getListOfDataDescriptions(SedDocument_t * sd)3409 SedDocument_getListOfDataDescriptions(SedDocument_t* sd)
3410 {
3411 return (sd != NULL) ? sd->getListOfDataDescriptions() : NULL;
3412 }
3413
3414
3415 /*
3416 * Get a SedDataDescription_t from the SedDocument_t.
3417 */
3418 LIBSEDML_EXTERN
3419 SedDataDescription_t*
SedDocument_getDataDescription(SedDocument_t * sd,unsigned int n)3420 SedDocument_getDataDescription(SedDocument_t* sd, unsigned int n)
3421 {
3422 return (sd != NULL) ? sd->getDataDescription(n) : NULL;
3423 }
3424
3425
3426 /*
3427 * Get a SedDataDescription_t from the SedDocument_t based on its identifier.
3428 */
3429 LIBSEDML_EXTERN
3430 SedDataDescription_t*
SedDocument_getDataDescriptionById(SedDocument_t * sd,const char * sid)3431 SedDocument_getDataDescriptionById(SedDocument_t* sd, const char *sid)
3432 {
3433 return (sd != NULL && sid != NULL) ? sd->getDataDescription(sid) : NULL;
3434 }
3435
3436
3437 /*
3438 * Adds a copy of the given SedDataDescription_t to this SedDocument_t.
3439 */
3440 LIBSEDML_EXTERN
3441 int
SedDocument_addDataDescription(SedDocument_t * sd,const SedDataDescription_t * sdd)3442 SedDocument_addDataDescription(SedDocument_t* sd,
3443 const SedDataDescription_t* sdd)
3444 {
3445 return (sd != NULL) ? sd->addDataDescription(sdd) : LIBSEDML_INVALID_OBJECT;
3446 }
3447
3448
3449 /*
3450 * Get the number of SedDataDescription_t objects in this SedDocument_t.
3451 */
3452 LIBSEDML_EXTERN
3453 unsigned int
SedDocument_getNumDataDescriptions(SedDocument_t * sd)3454 SedDocument_getNumDataDescriptions(SedDocument_t* sd)
3455 {
3456 return (sd != NULL) ? sd->getNumDataDescriptions() : SEDML_INT_MAX;
3457 }
3458
3459
3460 /*
3461 * Creates a new SedDataDescription_t object, adds it to this SedDocument_t
3462 * object and returns the SedDataDescription_t object created.
3463 */
3464 LIBSEDML_EXTERN
3465 SedDataDescription_t*
SedDocument_createDataDescription(SedDocument_t * sd)3466 SedDocument_createDataDescription(SedDocument_t* sd)
3467 {
3468 return (sd != NULL) ? sd->createDataDescription() : NULL;
3469 }
3470
3471
3472 /*
3473 * Removes the nth SedDataDescription_t from this SedDocument_t and returns a
3474 * pointer to it.
3475 */
3476 LIBSEDML_EXTERN
3477 SedDataDescription_t*
SedDocument_removeDataDescription(SedDocument_t * sd,unsigned int n)3478 SedDocument_removeDataDescription(SedDocument_t* sd, unsigned int n)
3479 {
3480 return (sd != NULL) ? sd->removeDataDescription(n) : NULL;
3481 }
3482
3483
3484 /*
3485 * Removes the SedDataDescription_t from this SedDocument_t based on its
3486 * identifier and returns a pointer to it.
3487 */
3488 LIBSEDML_EXTERN
3489 SedDataDescription_t*
SedDocument_removeDataDescriptionById(SedDocument_t * sd,const char * sid)3490 SedDocument_removeDataDescriptionById(SedDocument_t* sd, const char* sid)
3491 {
3492 return (sd != NULL && sid != NULL) ? sd->removeDataDescription(sid) : NULL;
3493 }
3494
3495
3496 /*
3497 * Returns a ListOf_t * containing SedModel_t objects from this SedDocument_t.
3498 */
3499 LIBSEDML_EXTERN
3500 SedListOf_t*
SedDocument_getListOfModels(SedDocument_t * sd)3501 SedDocument_getListOfModels(SedDocument_t* sd)
3502 {
3503 return (sd != NULL) ? sd->getListOfModels() : NULL;
3504 }
3505
3506
3507 /*
3508 * Get a SedModel_t from the SedDocument_t.
3509 */
3510 LIBSEDML_EXTERN
3511 SedModel_t*
SedDocument_getModel(SedDocument_t * sd,unsigned int n)3512 SedDocument_getModel(SedDocument_t* sd, unsigned int n)
3513 {
3514 return (sd != NULL) ? sd->getModel(n) : NULL;
3515 }
3516
3517
3518 /*
3519 * Get a SedModel_t from the SedDocument_t based on its identifier.
3520 */
3521 LIBSEDML_EXTERN
3522 SedModel_t*
SedDocument_getModelById(SedDocument_t * sd,const char * sid)3523 SedDocument_getModelById(SedDocument_t* sd, const char *sid)
3524 {
3525 return (sd != NULL && sid != NULL) ? sd->getModel(sid) : NULL;
3526 }
3527
3528
3529 /*
3530 * Adds a copy of the given SedModel_t to this SedDocument_t.
3531 */
3532 LIBSEDML_EXTERN
3533 int
SedDocument_addModel(SedDocument_t * sd,const SedModel_t * sm)3534 SedDocument_addModel(SedDocument_t* sd, const SedModel_t* sm)
3535 {
3536 return (sd != NULL) ? sd->addModel(sm) : LIBSEDML_INVALID_OBJECT;
3537 }
3538
3539
3540 /*
3541 * Get the number of SedModel_t objects in this SedDocument_t.
3542 */
3543 LIBSEDML_EXTERN
3544 unsigned int
SedDocument_getNumModels(SedDocument_t * sd)3545 SedDocument_getNumModels(SedDocument_t* sd)
3546 {
3547 return (sd != NULL) ? sd->getNumModels() : SEDML_INT_MAX;
3548 }
3549
3550
3551 /*
3552 * Creates a new SedModel_t object, adds it to this SedDocument_t object and
3553 * returns the SedModel_t object created.
3554 */
3555 LIBSEDML_EXTERN
3556 SedModel_t*
SedDocument_createModel(SedDocument_t * sd)3557 SedDocument_createModel(SedDocument_t* sd)
3558 {
3559 return (sd != NULL) ? sd->createModel() : NULL;
3560 }
3561
3562
3563 /*
3564 * Removes the nth SedModel_t from this SedDocument_t and returns a pointer to
3565 * it.
3566 */
3567 LIBSEDML_EXTERN
3568 SedModel_t*
SedDocument_removeModel(SedDocument_t * sd,unsigned int n)3569 SedDocument_removeModel(SedDocument_t* sd, unsigned int n)
3570 {
3571 return (sd != NULL) ? sd->removeModel(n) : NULL;
3572 }
3573
3574
3575 /*
3576 * Removes the SedModel_t from this SedDocument_t based on its identifier and
3577 * returns a pointer to it.
3578 */
3579 LIBSEDML_EXTERN
3580 SedModel_t*
SedDocument_removeModelById(SedDocument_t * sd,const char * sid)3581 SedDocument_removeModelById(SedDocument_t* sd, const char* sid)
3582 {
3583 return (sd != NULL && sid != NULL) ? sd->removeModel(sid) : NULL;
3584 }
3585
3586
3587 /*
3588 * Returns a ListOf_t * containing SedSimulation_t objects from this
3589 * SedDocument_t.
3590 */
3591 LIBSEDML_EXTERN
3592 SedListOf_t*
SedDocument_getListOfSimulations(SedDocument_t * sd)3593 SedDocument_getListOfSimulations(SedDocument_t* sd)
3594 {
3595 return (sd != NULL) ? sd->getListOfSimulations() : NULL;
3596 }
3597
3598
3599 /*
3600 * Get a SedSimulation_t from the SedDocument_t.
3601 */
3602 LIBSEDML_EXTERN
3603 SedSimulation_t*
SedDocument_getSimulation(SedDocument_t * sd,unsigned int n)3604 SedDocument_getSimulation(SedDocument_t* sd, unsigned int n)
3605 {
3606 return (sd != NULL) ? sd->getSimulation(n) : NULL;
3607 }
3608
3609
3610 /*
3611 * Get a SedSimulation_t from the SedDocument_t based on its identifier.
3612 */
3613 LIBSEDML_EXTERN
3614 SedSimulation_t*
SedDocument_getSimulationById(SedDocument_t * sd,const char * sid)3615 SedDocument_getSimulationById(SedDocument_t* sd, const char *sid)
3616 {
3617 return (sd != NULL && sid != NULL) ? sd->getSimulation(sid) : NULL;
3618 }
3619
3620
3621 /*
3622 * Adds a copy of the given SedSimulation_t to this SedDocument_t.
3623 */
3624 LIBSEDML_EXTERN
3625 int
SedDocument_addSimulation(SedDocument_t * sd,const SedSimulation_t * ss)3626 SedDocument_addSimulation(SedDocument_t* sd, const SedSimulation_t* ss)
3627 {
3628 return (sd != NULL) ? sd->addSimulation(ss) : LIBSEDML_INVALID_OBJECT;
3629 }
3630
3631
3632 /*
3633 * Get the number of SedSimulation_t objects in this SedDocument_t.
3634 */
3635 LIBSEDML_EXTERN
3636 unsigned int
SedDocument_getNumSimulations(SedDocument_t * sd)3637 SedDocument_getNumSimulations(SedDocument_t* sd)
3638 {
3639 return (sd != NULL) ? sd->getNumSimulations() : SEDML_INT_MAX;
3640 }
3641
3642
3643 /*
3644 * Creates a new SedUniformTimeCourse_t object, adds it to this SedDocument_t
3645 * object and returns the SedUniformTimeCourse_t object created.
3646 */
3647 LIBSEDML_EXTERN
3648 SedUniformTimeCourse_t*
SedDocument_createUniformTimeCourse(SedDocument_t * sd)3649 SedDocument_createUniformTimeCourse(SedDocument_t* sd)
3650 {
3651 return (sd != NULL) ? sd->createUniformTimeCourse() : NULL;
3652 }
3653
3654
3655 /*
3656 * Creates a new SedOneStep_t object, adds it to this SedDocument_t object and
3657 * returns the SedOneStep_t object created.
3658 */
3659 LIBSEDML_EXTERN
3660 SedOneStep_t*
SedDocument_createOneStep(SedDocument_t * sd)3661 SedDocument_createOneStep(SedDocument_t* sd)
3662 {
3663 return (sd != NULL) ? sd->createOneStep() : NULL;
3664 }
3665
3666
3667 /*
3668 * Creates a new SedSteadyState_t object, adds it to this SedDocument_t object
3669 * and returns the SedSteadyState_t object created.
3670 */
3671 LIBSEDML_EXTERN
3672 SedSteadyState_t*
SedDocument_createSteadyState(SedDocument_t * sd)3673 SedDocument_createSteadyState(SedDocument_t* sd)
3674 {
3675 return (sd != NULL) ? sd->createSteadyState() : NULL;
3676 }
3677
3678
3679 /*
3680 * Creates a new SedAnalysis_t object, adds it to this SedDocument_t object
3681 * and returns the SedAnalysis_t object created.
3682 */
3683 LIBSEDML_EXTERN
3684 SedAnalysis_t*
SedDocument_createAnalysis(SedDocument_t * sd)3685 SedDocument_createAnalysis(SedDocument_t* sd)
3686 {
3687 return (sd != NULL) ? sd->createAnalysis() : NULL;
3688 }
3689
3690
3691 /*
3692 * Removes the nth SedSimulation_t from this SedDocument_t and returns a
3693 * pointer to it.
3694 */
3695 LIBSEDML_EXTERN
3696 SedSimulation_t*
SedDocument_removeSimulation(SedDocument_t * sd,unsigned int n)3697 SedDocument_removeSimulation(SedDocument_t* sd, unsigned int n)
3698 {
3699 return (sd != NULL) ? sd->removeSimulation(n) : NULL;
3700 }
3701
3702
3703 /*
3704 * Removes the SedSimulation_t from this SedDocument_t based on its identifier
3705 * and returns a pointer to it.
3706 */
3707 LIBSEDML_EXTERN
3708 SedSimulation_t*
SedDocument_removeSimulationById(SedDocument_t * sd,const char * sid)3709 SedDocument_removeSimulationById(SedDocument_t* sd, const char* sid)
3710 {
3711 return (sd != NULL && sid != NULL) ? sd->removeSimulation(sid) : NULL;
3712 }
3713
3714
3715 /*
3716 * Returns a ListOf_t * containing SedAbstractTask_t objects from this
3717 * SedDocument_t.
3718 */
3719 LIBSEDML_EXTERN
3720 SedListOf_t*
SedDocument_getListOfTasks(SedDocument_t * sd)3721 SedDocument_getListOfTasks(SedDocument_t* sd)
3722 {
3723 return (sd != NULL) ? sd->getListOfTasks() : NULL;
3724 }
3725
3726
3727 /*
3728 * Get a SedAbstractTask_t from the SedDocument_t.
3729 */
3730 LIBSEDML_EXTERN
3731 SedAbstractTask_t*
SedDocument_getTask(SedDocument_t * sd,unsigned int n)3732 SedDocument_getTask(SedDocument_t* sd, unsigned int n)
3733 {
3734 return (sd != NULL) ? sd->getTask(n) : NULL;
3735 }
3736
3737
3738 /*
3739 * Get a SedAbstractTask_t from the SedDocument_t based on its identifier.
3740 */
3741 LIBSEDML_EXTERN
3742 SedAbstractTask_t*
SedDocument_getTaskById(SedDocument_t * sd,const char * sid)3743 SedDocument_getTaskById(SedDocument_t* sd, const char *sid)
3744 {
3745 return (sd != NULL && sid != NULL) ? sd->getTask(sid) : NULL;
3746 }
3747
3748
3749 /*
3750 * Adds a copy of the given SedAbstractTask_t to this SedDocument_t.
3751 */
3752 LIBSEDML_EXTERN
3753 int
SedDocument_addTask(SedDocument_t * sd,const SedAbstractTask_t * sat)3754 SedDocument_addTask(SedDocument_t* sd, const SedAbstractTask_t* sat)
3755 {
3756 return (sd != NULL) ? sd->addTask(sat) : LIBSEDML_INVALID_OBJECT;
3757 }
3758
3759
3760 /*
3761 * Get the number of SedAbstractTask_t objects in this SedDocument_t.
3762 */
3763 LIBSEDML_EXTERN
3764 unsigned int
SedDocument_getNumTasks(SedDocument_t * sd)3765 SedDocument_getNumTasks(SedDocument_t* sd)
3766 {
3767 return (sd != NULL) ? sd->getNumTasks() : SEDML_INT_MAX;
3768 }
3769
3770
3771 /*
3772 * Creates a new SedTask_t object, adds it to this SedDocument_t object and
3773 * returns the SedTask_t object created.
3774 */
3775 LIBSEDML_EXTERN
3776 SedTask_t*
SedDocument_createTask(SedDocument_t * sd)3777 SedDocument_createTask(SedDocument_t* sd)
3778 {
3779 return (sd != NULL) ? sd->createTask() : NULL;
3780 }
3781
3782
3783 /*
3784 * Creates a new SedRepeatedTask_t object, adds it to this SedDocument_t object
3785 * and returns the SedRepeatedTask_t object created.
3786 */
3787 LIBSEDML_EXTERN
3788 SedRepeatedTask_t*
SedDocument_createRepeatedTask(SedDocument_t * sd)3789 SedDocument_createRepeatedTask(SedDocument_t* sd)
3790 {
3791 return (sd != NULL) ? sd->createRepeatedTask() : NULL;
3792 }
3793
3794
3795 /*
3796 * Creates a new SedParameterEstimationTask_t object, adds it to this
3797 * SedDocument_t object and returns the SedParameterEstimationTask_t object
3798 * created.
3799 */
3800 LIBSEDML_EXTERN
3801 SedParameterEstimationTask_t*
SedDocument_createParameterEstimationTask(SedDocument_t * sd)3802 SedDocument_createParameterEstimationTask(SedDocument_t* sd)
3803 {
3804 return (sd != NULL) ? sd->createParameterEstimationTask() : NULL;
3805 }
3806
3807
3808 /*
3809 * Removes the nth SedAbstractTask_t from this SedDocument_t and returns a
3810 * pointer to it.
3811 */
3812 LIBSEDML_EXTERN
3813 SedAbstractTask_t*
SedDocument_removeTask(SedDocument_t * sd,unsigned int n)3814 SedDocument_removeTask(SedDocument_t* sd, unsigned int n)
3815 {
3816 return (sd != NULL) ? sd->removeTask(n) : NULL;
3817 }
3818
3819
3820 /*
3821 * Removes the SedAbstractTask_t from this SedDocument_t based on its
3822 * identifier and returns a pointer to it.
3823 */
3824 LIBSEDML_EXTERN
3825 SedAbstractTask_t*
SedDocument_removeTaskById(SedDocument_t * sd,const char * sid)3826 SedDocument_removeTaskById(SedDocument_t* sd, const char* sid)
3827 {
3828 return (sd != NULL && sid != NULL) ? sd->removeTask(sid) : NULL;
3829 }
3830
3831
3832 /*
3833 * Returns a ListOf_t * containing SedDataGenerator_t objects from this
3834 * SedDocument_t.
3835 */
3836 LIBSEDML_EXTERN
3837 SedListOf_t*
SedDocument_getListOfDataGenerators(SedDocument_t * sd)3838 SedDocument_getListOfDataGenerators(SedDocument_t* sd)
3839 {
3840 return (sd != NULL) ? sd->getListOfDataGenerators() : NULL;
3841 }
3842
3843
3844 /*
3845 * Get a SedDataGenerator_t from the SedDocument_t.
3846 */
3847 LIBSEDML_EXTERN
3848 SedDataGenerator_t*
SedDocument_getDataGenerator(SedDocument_t * sd,unsigned int n)3849 SedDocument_getDataGenerator(SedDocument_t* sd, unsigned int n)
3850 {
3851 return (sd != NULL) ? sd->getDataGenerator(n) : NULL;
3852 }
3853
3854
3855 /*
3856 * Get a SedDataGenerator_t from the SedDocument_t based on its identifier.
3857 */
3858 LIBSEDML_EXTERN
3859 SedDataGenerator_t*
SedDocument_getDataGeneratorById(SedDocument_t * sd,const char * sid)3860 SedDocument_getDataGeneratorById(SedDocument_t* sd, const char *sid)
3861 {
3862 return (sd != NULL && sid != NULL) ? sd->getDataGenerator(sid) : NULL;
3863 }
3864
3865
3866 /*
3867 * Adds a copy of the given SedDataGenerator_t to this SedDocument_t.
3868 */
3869 LIBSEDML_EXTERN
3870 int
SedDocument_addDataGenerator(SedDocument_t * sd,const SedDataGenerator_t * sdg)3871 SedDocument_addDataGenerator(SedDocument_t* sd, const SedDataGenerator_t* sdg)
3872 {
3873 return (sd != NULL) ? sd->addDataGenerator(sdg) : LIBSEDML_INVALID_OBJECT;
3874 }
3875
3876
3877 /*
3878 * Get the number of SedDataGenerator_t objects in this SedDocument_t.
3879 */
3880 LIBSEDML_EXTERN
3881 unsigned int
SedDocument_getNumDataGenerators(SedDocument_t * sd)3882 SedDocument_getNumDataGenerators(SedDocument_t* sd)
3883 {
3884 return (sd != NULL) ? sd->getNumDataGenerators() : SEDML_INT_MAX;
3885 }
3886
3887
3888 /*
3889 * Creates a new SedDataGenerator_t object, adds it to this SedDocument_t
3890 * object and returns the SedDataGenerator_t object created.
3891 */
3892 LIBSEDML_EXTERN
3893 SedDataGenerator_t*
SedDocument_createDataGenerator(SedDocument_t * sd)3894 SedDocument_createDataGenerator(SedDocument_t* sd)
3895 {
3896 return (sd != NULL) ? sd->createDataGenerator() : NULL;
3897 }
3898
3899
3900 /*
3901 * Removes the nth SedDataGenerator_t from this SedDocument_t and returns a
3902 * pointer to it.
3903 */
3904 LIBSEDML_EXTERN
3905 SedDataGenerator_t*
SedDocument_removeDataGenerator(SedDocument_t * sd,unsigned int n)3906 SedDocument_removeDataGenerator(SedDocument_t* sd, unsigned int n)
3907 {
3908 return (sd != NULL) ? sd->removeDataGenerator(n) : NULL;
3909 }
3910
3911
3912 /*
3913 * Removes the SedDataGenerator_t from this SedDocument_t based on its
3914 * identifier and returns a pointer to it.
3915 */
3916 LIBSEDML_EXTERN
3917 SedDataGenerator_t*
SedDocument_removeDataGeneratorById(SedDocument_t * sd,const char * sid)3918 SedDocument_removeDataGeneratorById(SedDocument_t* sd, const char* sid)
3919 {
3920 return (sd != NULL && sid != NULL) ? sd->removeDataGenerator(sid) : NULL;
3921 }
3922
3923
3924 /*
3925 * Returns a ListOf_t * containing SedOutput_t objects from this SedDocument_t.
3926 */
3927 LIBSEDML_EXTERN
3928 SedListOf_t*
SedDocument_getListOfOutputs(SedDocument_t * sd)3929 SedDocument_getListOfOutputs(SedDocument_t* sd)
3930 {
3931 return (sd != NULL) ? sd->getListOfOutputs() : NULL;
3932 }
3933
3934
3935 /*
3936 * Get a SedOutput_t from the SedDocument_t.
3937 */
3938 LIBSEDML_EXTERN
3939 SedOutput_t*
SedDocument_getOutput(SedDocument_t * sd,unsigned int n)3940 SedDocument_getOutput(SedDocument_t* sd, unsigned int n)
3941 {
3942 return (sd != NULL) ? sd->getOutput(n) : NULL;
3943 }
3944
3945
3946 /*
3947 * Get a SedOutput_t from the SedDocument_t based on its identifier.
3948 */
3949 LIBSEDML_EXTERN
3950 SedOutput_t*
SedDocument_getOutputById(SedDocument_t * sd,const char * sid)3951 SedDocument_getOutputById(SedDocument_t* sd, const char *sid)
3952 {
3953 return (sd != NULL && sid != NULL) ? sd->getOutput(sid) : NULL;
3954 }
3955
3956
3957 /*
3958 * Adds a copy of the given SedOutput_t to this SedDocument_t.
3959 */
3960 LIBSEDML_EXTERN
3961 int
SedDocument_addOutput(SedDocument_t * sd,const SedOutput_t * so)3962 SedDocument_addOutput(SedDocument_t* sd, const SedOutput_t* so)
3963 {
3964 return (sd != NULL) ? sd->addOutput(so) : LIBSEDML_INVALID_OBJECT;
3965 }
3966
3967
3968 /*
3969 * Get the number of SedOutput_t objects in this SedDocument_t.
3970 */
3971 LIBSEDML_EXTERN
3972 unsigned int
SedDocument_getNumOutputs(SedDocument_t * sd)3973 SedDocument_getNumOutputs(SedDocument_t* sd)
3974 {
3975 return (sd != NULL) ? sd->getNumOutputs() : SEDML_INT_MAX;
3976 }
3977
3978
3979 /*
3980 * Creates a new SedReport_t object, adds it to this SedDocument_t object and
3981 * returns the SedReport_t object created.
3982 */
3983 LIBSEDML_EXTERN
3984 SedReport_t*
SedDocument_createReport(SedDocument_t * sd)3985 SedDocument_createReport(SedDocument_t* sd)
3986 {
3987 return (sd != NULL) ? sd->createReport() : NULL;
3988 }
3989
3990
3991 /*
3992 * Creates a new SedPlot2D_t object, adds it to this SedDocument_t object and
3993 * returns the SedPlot2D_t object created.
3994 */
3995 LIBSEDML_EXTERN
3996 SedPlot2D_t*
SedDocument_createPlot2D(SedDocument_t * sd)3997 SedDocument_createPlot2D(SedDocument_t* sd)
3998 {
3999 return (sd != NULL) ? sd->createPlot2D() : NULL;
4000 }
4001
4002
4003 /*
4004 * Creates a new SedPlot3D_t object, adds it to this SedDocument_t object and
4005 * returns the SedPlot3D_t object created.
4006 */
4007 LIBSEDML_EXTERN
4008 SedPlot3D_t*
SedDocument_createPlot3D(SedDocument_t * sd)4009 SedDocument_createPlot3D(SedDocument_t* sd)
4010 {
4011 return (sd != NULL) ? sd->createPlot3D() : NULL;
4012 }
4013
4014
4015 /*
4016 * Creates a new SedFigure_t object, adds it to this SedDocument_t object and
4017 * returns the SedFigure_t object created.
4018 */
4019 LIBSEDML_EXTERN
4020 SedFigure_t*
SedDocument_createFigure(SedDocument_t * sd)4021 SedDocument_createFigure(SedDocument_t* sd)
4022 {
4023 return (sd != NULL) ? sd->createFigure() : NULL;
4024 }
4025
4026
4027 /*
4028 * Creates a new SedParameterEstimationResultPlot_t object, adds it to this
4029 * SedDocument_t object and returns the SedParameterEstimationResultPlot_t
4030 * object created.
4031 */
4032 LIBSEDML_EXTERN
4033 SedParameterEstimationResultPlot_t*
SedDocument_createParameterEstimationResultPlot(SedDocument_t * sd)4034 SedDocument_createParameterEstimationResultPlot(SedDocument_t* sd)
4035 {
4036 return (sd != NULL) ? sd->createParameterEstimationResultPlot() : NULL;
4037 }
4038
4039
4040 /*
4041 * Removes the nth SedOutput_t from this SedDocument_t and returns a pointer to
4042 * it.
4043 */
4044 LIBSEDML_EXTERN
4045 SedOutput_t*
SedDocument_removeOutput(SedDocument_t * sd,unsigned int n)4046 SedDocument_removeOutput(SedDocument_t* sd, unsigned int n)
4047 {
4048 return (sd != NULL) ? sd->removeOutput(n) : NULL;
4049 }
4050
4051
4052 /*
4053 * Removes the SedOutput_t from this SedDocument_t based on its identifier and
4054 * returns a pointer to it.
4055 */
4056 LIBSEDML_EXTERN
4057 SedOutput_t*
SedDocument_removeOutputById(SedDocument_t * sd,const char * sid)4058 SedDocument_removeOutputById(SedDocument_t* sd, const char* sid)
4059 {
4060 return (sd != NULL && sid != NULL) ? sd->removeOutput(sid) : NULL;
4061 }
4062
4063
4064 /*
4065 * Returns a ListOf_t * containing SedStyle_t objects from this SedDocument_t.
4066 */
4067 LIBSEDML_EXTERN
4068 SedListOf_t*
SedDocument_getListOfStyles(SedDocument_t * sd)4069 SedDocument_getListOfStyles(SedDocument_t* sd)
4070 {
4071 return (sd != NULL) ? sd->getListOfStyles() : NULL;
4072 }
4073
4074
4075 /*
4076 * Get a SedStyle_t from the SedDocument_t.
4077 */
4078 LIBSEDML_EXTERN
4079 SedStyle_t*
SedDocument_getStyle(SedDocument_t * sd,unsigned int n)4080 SedDocument_getStyle(SedDocument_t* sd, unsigned int n)
4081 {
4082 return (sd != NULL) ? sd->getStyle(n) : NULL;
4083 }
4084
4085
4086 /*
4087 * Get a SedStyle_t from the SedDocument_t based on its identifier.
4088 */
4089 LIBSEDML_EXTERN
4090 SedStyle_t*
SedDocument_getStyleById(SedDocument_t * sd,const char * sid)4091 SedDocument_getStyleById(SedDocument_t* sd, const char *sid)
4092 {
4093 return (sd != NULL && sid != NULL) ? sd->getStyle(sid) : NULL;
4094 }
4095
4096
4097 /*
4098 * Get a SedStyle_t from the SedDocument_t based on the BaseStyle to which it
4099 * refers.
4100 */
4101 LIBSEDML_EXTERN
4102 SedStyle_t*
SedDocument_getStyleByBaseStyle(SedDocument_t * sd,const char * sid)4103 SedDocument_getStyleByBaseStyle(SedDocument_t* sd, const char *sid)
4104 {
4105 return (sd != NULL && sid != NULL) ? sd->getStyleByBaseStyle(sid) : NULL;
4106 }
4107
4108
4109 /*
4110 * Adds a copy of the given SedStyle_t to this SedDocument_t.
4111 */
4112 LIBSEDML_EXTERN
4113 int
SedDocument_addStyle(SedDocument_t * sd,const SedStyle_t * ss)4114 SedDocument_addStyle(SedDocument_t* sd, const SedStyle_t* ss)
4115 {
4116 return (sd != NULL) ? sd->addStyle(ss) : LIBSEDML_INVALID_OBJECT;
4117 }
4118
4119
4120 /*
4121 * Get the number of SedStyle_t objects in this SedDocument_t.
4122 */
4123 LIBSEDML_EXTERN
4124 unsigned int
SedDocument_getNumStyles(SedDocument_t * sd)4125 SedDocument_getNumStyles(SedDocument_t* sd)
4126 {
4127 return (sd != NULL) ? sd->getNumStyles() : SEDML_INT_MAX;
4128 }
4129
4130
4131 /*
4132 * Creates a new SedStyle_t object, adds it to this SedDocument_t object and
4133 * returns the SedStyle_t object created.
4134 */
4135 LIBSEDML_EXTERN
4136 SedStyle_t*
SedDocument_createStyle(SedDocument_t * sd)4137 SedDocument_createStyle(SedDocument_t* sd)
4138 {
4139 return (sd != NULL) ? sd->createStyle() : NULL;
4140 }
4141
4142
4143 /*
4144 * Removes the nth SedStyle_t from this SedDocument_t and returns a pointer to
4145 * it.
4146 */
4147 LIBSEDML_EXTERN
4148 SedStyle_t*
SedDocument_removeStyle(SedDocument_t * sd,unsigned int n)4149 SedDocument_removeStyle(SedDocument_t* sd, unsigned int n)
4150 {
4151 return (sd != NULL) ? sd->removeStyle(n) : NULL;
4152 }
4153
4154
4155 /*
4156 * Removes the SedStyle_t from this SedDocument_t based on its identifier and
4157 * returns a pointer to it.
4158 */
4159 LIBSEDML_EXTERN
4160 SedStyle_t*
SedDocument_removeStyleById(SedDocument_t * sd,const char * sid)4161 SedDocument_removeStyleById(SedDocument_t* sd, const char* sid)
4162 {
4163 return (sd != NULL && sid != NULL) ? sd->removeStyle(sid) : NULL;
4164 }
4165
4166
4167 /*
4168 * Predicate returning @c 1 (true) if all the required attributes for this
4169 * SedDocument_t object have been set.
4170 */
4171 LIBSEDML_EXTERN
4172 int
SedDocument_hasRequiredAttributes(const SedDocument_t * sd)4173 SedDocument_hasRequiredAttributes(const SedDocument_t * sd)
4174 {
4175 return (sd != NULL) ? static_cast<int>(sd->hasRequiredAttributes()) : 0;
4176 }
4177
4178
4179
4180
4181 LIBSEDML_CPP_NAMESPACE_END
4182
4183
4184