1 /**
2  * @file SedFunctionalRange.cpp
3  * @brief Implementation of the SedFunctionalRange 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/SedFunctionalRange.h>
35 #include <sedml/SedVariable.h>
36 #include <sbml/xml/XMLInputStream.h>
37 #include <sbml/math/MathML.h>
38 
39 
40 using namespace std;
41 
42 
43 
44 LIBSEDML_CPP_NAMESPACE_BEGIN
45 
46 
47 
48 
49 #ifdef __cplusplus
50 
51 
52 /*
53  * Creates a new SedFunctionalRange using the given SED-ML Level and @ p version
54  * values.
55  */
SedFunctionalRange(unsigned int level,unsigned int version)56 SedFunctionalRange::SedFunctionalRange(unsigned int level,
57                                        unsigned int version)
58   : SedRange(level, version)
59   , mRange ("")
60   , mMath (NULL)
61   , mVariables (level, version)
62   , mParameters (level, version)
63 {
64   setSedNamespacesAndOwn(new SedNamespaces(level, version));
65   connectToChild();
66 }
67 
68 
69 /*
70  * Creates a new SedFunctionalRange using the given SedNamespaces object @p
71  * sedmlns.
72  */
SedFunctionalRange(SedNamespaces * sedmlns)73 SedFunctionalRange::SedFunctionalRange(SedNamespaces *sedmlns)
74   : SedRange(sedmlns)
75   , mRange ("")
76   , mMath (NULL)
77   , mVariables (sedmlns)
78   , mParameters (sedmlns)
79 {
80   setElementNamespace(sedmlns->getURI());
81   connectToChild();
82 }
83 
84 
85 /*
86  * Copy constructor for SedFunctionalRange.
87  */
SedFunctionalRange(const SedFunctionalRange & orig)88 SedFunctionalRange::SedFunctionalRange(const SedFunctionalRange& orig)
89   : SedRange( orig )
90   , mRange ( orig.mRange )
91   , mMath ( NULL )
92   , mVariables ( orig.mVariables )
93   , mParameters ( orig.mParameters )
94 {
95   if (orig.mMath != NULL)
96   {
97     mMath = orig.mMath->deepCopy();
98   }
99 
100   connectToChild();
101 }
102 
103 
104 /*
105  * Assignment operator for SedFunctionalRange.
106  */
107 SedFunctionalRange&
operator =(const SedFunctionalRange & rhs)108 SedFunctionalRange::operator=(const SedFunctionalRange& rhs)
109 {
110   if (&rhs != this)
111   {
112     SedRange::operator=(rhs);
113     mRange = rhs.mRange;
114     mVariables = rhs.mVariables;
115     mParameters = rhs.mParameters;
116     delete mMath;
117     if (rhs.mMath != NULL)
118     {
119       mMath = rhs.mMath->deepCopy();
120     }
121     else
122     {
123       mMath = NULL;
124     }
125 
126     connectToChild();
127   }
128 
129   return *this;
130 }
131 
132 
133 /*
134  * Creates and returns a deep copy of this SedFunctionalRange object.
135  */
136 SedFunctionalRange*
clone() const137 SedFunctionalRange::clone() const
138 {
139   return new SedFunctionalRange(*this);
140 }
141 
142 
143 /*
144  * Destructor for SedFunctionalRange.
145  */
~SedFunctionalRange()146 SedFunctionalRange::~SedFunctionalRange()
147 {
148   delete mMath;
149   mMath = NULL;
150 }
151 
152 
153 /*
154  * Returns the value of the "range" attribute of this SedFunctionalRange.
155  */
156 const std::string&
getRange() const157 SedFunctionalRange::getRange() const
158 {
159   return mRange;
160 }
161 
162 
163 /*
164  * Predicate returning @c true if this SedFunctionalRange's "range" attribute
165  * is set.
166  */
167 bool
isSetRange() const168 SedFunctionalRange::isSetRange() const
169 {
170   return (mRange.empty() == false);
171 }
172 
173 
174 /*
175  * Sets the value of the "range" attribute of this SedFunctionalRange.
176  */
177 int
setRange(const std::string & range)178 SedFunctionalRange::setRange(const std::string& range)
179 {
180   if (!(SyntaxChecker::isValidInternalSId(range)))
181   {
182     return LIBSEDML_INVALID_ATTRIBUTE_VALUE;
183   }
184   else
185   {
186     mRange = range;
187     return LIBSEDML_OPERATION_SUCCESS;
188   }
189 }
190 
191 
192 /*
193  * Unsets the value of the "range" attribute of this SedFunctionalRange.
194  */
195 int
unsetRange()196 SedFunctionalRange::unsetRange()
197 {
198   mRange.erase();
199 
200   if (mRange.empty() == true)
201   {
202     return LIBSEDML_OPERATION_SUCCESS;
203   }
204   else
205   {
206     return LIBSEDML_OPERATION_FAILED;
207   }
208 }
209 
210 
211 /*
212  * Returns the value of the "math" element of this SedFunctionalRange.
213  */
214 const LIBSBML_CPP_NAMESPACE_QUALIFIER ASTNode*
getMath() const215 SedFunctionalRange::getMath() const
216 {
217   return mMath;
218 }
219 
220 
221 /*
222  * Returns the value of the "math" element of this SedFunctionalRange.
223  */
224 LIBSBML_CPP_NAMESPACE_QUALIFIER ASTNode*
getMath()225 SedFunctionalRange::getMath()
226 {
227   return mMath;
228 }
229 
230 
231 /*
232  * Predicate returning @c true if this SedFunctionalRange's "math" element is
233  * set.
234  */
235 bool
isSetMath() const236 SedFunctionalRange::isSetMath() const
237 {
238   return (mMath != NULL);
239 }
240 
241 
242 /*
243  * Sets the value of the "math" element of this SedFunctionalRange.
244  */
245 int
setMath(const LIBSBML_CPP_NAMESPACE_QUALIFIER ASTNode * math)246 SedFunctionalRange::setMath(const LIBSBML_CPP_NAMESPACE_QUALIFIER ASTNode*
247   math)
248 {
249   if (mMath == math)
250   {
251     return LIBSEDML_OPERATION_SUCCESS;
252   }
253   else if (math == NULL)
254   {
255     delete mMath;
256     mMath = NULL;
257     return LIBSEDML_OPERATION_SUCCESS;
258   }
259   else if (!(math->isWellFormedASTNode()))
260   {
261     return LIBSEDML_INVALID_OBJECT;
262   }
263   else
264   {
265     delete mMath;
266     mMath = (math != NULL) ? math->deepCopy() : NULL;
267     return LIBSEDML_OPERATION_SUCCESS;
268   }
269 }
270 
271 
272 /*
273  * Unsets the value of the "math" element of this SedFunctionalRange.
274  */
275 int
unsetMath()276 SedFunctionalRange::unsetMath()
277 {
278   delete mMath;
279   mMath = NULL;
280   return LIBSEDML_OPERATION_SUCCESS;
281 }
282 
283 
284 /*
285  * Returns the SedListOfVariables from this SedFunctionalRange.
286  */
287 const SedListOfVariables*
getListOfVariables() const288 SedFunctionalRange::getListOfVariables() const
289 {
290   return &mVariables;
291 }
292 
293 
294 /*
295  * Returns the SedListOfVariables from this SedFunctionalRange.
296  */
297 SedListOfVariables*
getListOfVariables()298 SedFunctionalRange::getListOfVariables()
299 {
300   return &mVariables;
301 }
302 
303 
304 /*
305  * Get a SedVariable from the SedFunctionalRange.
306  */
307 SedVariable*
getVariable(unsigned int n)308 SedFunctionalRange::getVariable(unsigned int n)
309 {
310   return mVariables.get(n);
311 }
312 
313 
314 /*
315  * Get a SedVariable from the SedFunctionalRange.
316  */
317 const SedVariable*
getVariable(unsigned int n) const318 SedFunctionalRange::getVariable(unsigned int n) const
319 {
320   return mVariables.get(n);
321 }
322 
323 
324 /*
325  * Get a SedVariable from the SedFunctionalRange based on its identifier.
326  */
327 SedVariable*
getVariable(const std::string & sid)328 SedFunctionalRange::getVariable(const std::string& sid)
329 {
330   return mVariables.get(sid);
331 }
332 
333 
334 /*
335  * Get a SedVariable from the SedFunctionalRange based on its identifier.
336  */
337 const SedVariable*
getVariable(const std::string & sid) const338 SedFunctionalRange::getVariable(const std::string& sid) const
339 {
340   return mVariables.get(sid);
341 }
342 
343 
344 /*
345  * Get a SedVariable from the SedFunctionalRange based on the TaskReference to
346  * which it refers.
347  */
348 const SedVariable*
getVariableByTaskReference(const std::string & sid) const349 SedFunctionalRange::getVariableByTaskReference(const std::string& sid) const
350 {
351   return mVariables.getByTaskReference(sid);
352 }
353 
354 
355 /*
356  * Get a SedVariable from the SedFunctionalRange based on the TaskReference to
357  * which it refers.
358  */
359 SedVariable*
getVariableByTaskReference(const std::string & sid)360 SedFunctionalRange::getVariableByTaskReference(const std::string& sid)
361 {
362   return mVariables.getByTaskReference(sid);
363 }
364 
365 
366 /*
367  * Get a SedVariable from the SedFunctionalRange based on the ModelReference to
368  * which it refers.
369  */
370 const SedVariable*
getVariableByModelReference(const std::string & sid) const371 SedFunctionalRange::getVariableByModelReference(const std::string& sid) const
372 {
373   return mVariables.getByModelReference(sid);
374 }
375 
376 
377 /*
378  * Get a SedVariable from the SedFunctionalRange based on the ModelReference to
379  * which it refers.
380  */
381 SedVariable*
getVariableByModelReference(const std::string & sid)382 SedFunctionalRange::getVariableByModelReference(const std::string& sid)
383 {
384   return mVariables.getByModelReference(sid);
385 }
386 
387 
388 /*
389  * Adds a copy of the given SedVariable to this SedFunctionalRange.
390  */
391 int
addVariable(const SedVariable * sv)392 SedFunctionalRange::addVariable(const SedVariable* sv)
393 {
394   if (sv == NULL)
395   {
396     return LIBSEDML_OPERATION_FAILED;
397   }
398   else if (sv->hasRequiredAttributes() == false)
399   {
400     return LIBSEDML_INVALID_OBJECT;
401   }
402   else if (getLevel() != sv->getLevel())
403   {
404     return LIBSEDML_LEVEL_MISMATCH;
405   }
406   else if (getVersion() != sv->getVersion())
407   {
408     return LIBSEDML_VERSION_MISMATCH;
409   }
410   else if (matchesRequiredSedNamespacesForAddition(static_cast<const
411     SedBase*>(sv)) == false)
412   {
413     return LIBSEDML_NAMESPACES_MISMATCH;
414   }
415   else if (sv->isSetId() && (mVariables.get(sv->getId())) != NULL)
416   {
417     return LIBSEDML_DUPLICATE_OBJECT_ID;
418   }
419   else
420   {
421     return mVariables.append(sv);
422   }
423 }
424 
425 
426 /*
427  * Get the number of SedVariable objects in this SedFunctionalRange.
428  */
429 unsigned int
getNumVariables() const430 SedFunctionalRange::getNumVariables() const
431 {
432   return mVariables.size();
433 }
434 
435 
436 /*
437  * Creates a new SedVariable object, adds it to this SedFunctionalRange object
438  * and returns the SedVariable object created.
439  */
440 SedVariable*
createVariable()441 SedFunctionalRange::createVariable()
442 {
443   SedVariable* sv = NULL;
444 
445   try
446   {
447     sv = new SedVariable(getSedNamespaces());
448   }
449   catch (...)
450   {
451   }
452 
453   if (sv != NULL)
454   {
455     mVariables.appendAndOwn(sv);
456   }
457 
458   return sv;
459 }
460 
461 
462 /*
463  * Removes the nth SedVariable from this SedFunctionalRange and returns a
464  * pointer to it.
465  */
466 SedVariable*
removeVariable(unsigned int n)467 SedFunctionalRange::removeVariable(unsigned int n)
468 {
469   return mVariables.remove(n);
470 }
471 
472 
473 /*
474  * Removes the SedVariable from this SedFunctionalRange based on its identifier
475  * and returns a pointer to it.
476  */
477 SedVariable*
removeVariable(const std::string & sid)478 SedFunctionalRange::removeVariable(const std::string& sid)
479 {
480   return mVariables.remove(sid);
481 }
482 
483 
484 /*
485  * Returns the SedListOfParameters from this SedFunctionalRange.
486  */
487 const SedListOfParameters*
getListOfParameters() const488 SedFunctionalRange::getListOfParameters() const
489 {
490   return &mParameters;
491 }
492 
493 
494 /*
495  * Returns the SedListOfParameters from this SedFunctionalRange.
496  */
497 SedListOfParameters*
getListOfParameters()498 SedFunctionalRange::getListOfParameters()
499 {
500   return &mParameters;
501 }
502 
503 
504 /*
505  * Get a SedParameter from the SedFunctionalRange.
506  */
507 SedParameter*
getParameter(unsigned int n)508 SedFunctionalRange::getParameter(unsigned int n)
509 {
510   return mParameters.get(n);
511 }
512 
513 
514 /*
515  * Get a SedParameter from the SedFunctionalRange.
516  */
517 const SedParameter*
getParameter(unsigned int n) const518 SedFunctionalRange::getParameter(unsigned int n) const
519 {
520   return mParameters.get(n);
521 }
522 
523 
524 /*
525  * Get a SedParameter from the SedFunctionalRange based on its identifier.
526  */
527 SedParameter*
getParameter(const std::string & sid)528 SedFunctionalRange::getParameter(const std::string& sid)
529 {
530   return mParameters.get(sid);
531 }
532 
533 
534 /*
535  * Get a SedParameter from the SedFunctionalRange based on its identifier.
536  */
537 const SedParameter*
getParameter(const std::string & sid) const538 SedFunctionalRange::getParameter(const std::string& sid) const
539 {
540   return mParameters.get(sid);
541 }
542 
543 
544 /*
545  * Adds a copy of the given SedParameter to this SedFunctionalRange.
546  */
547 int
addParameter(const SedParameter * sp)548 SedFunctionalRange::addParameter(const SedParameter* sp)
549 {
550   if (sp == NULL)
551   {
552     return LIBSEDML_OPERATION_FAILED;
553   }
554   else if (sp->hasRequiredAttributes() == false)
555   {
556     return LIBSEDML_INVALID_OBJECT;
557   }
558   else if (getLevel() != sp->getLevel())
559   {
560     return LIBSEDML_LEVEL_MISMATCH;
561   }
562   else if (getVersion() != sp->getVersion())
563   {
564     return LIBSEDML_VERSION_MISMATCH;
565   }
566   else if (matchesRequiredSedNamespacesForAddition(static_cast<const
567     SedBase*>(sp)) == false)
568   {
569     return LIBSEDML_NAMESPACES_MISMATCH;
570   }
571   else if (sp->isSetId() && (mParameters.get(sp->getId())) != NULL)
572   {
573     return LIBSEDML_DUPLICATE_OBJECT_ID;
574   }
575   else
576   {
577     return mParameters.append(sp);
578   }
579 }
580 
581 
582 /*
583  * Get the number of SedParameter objects in this SedFunctionalRange.
584  */
585 unsigned int
getNumParameters() const586 SedFunctionalRange::getNumParameters() const
587 {
588   return mParameters.size();
589 }
590 
591 
592 /*
593  * Creates a new SedParameter object, adds it to this SedFunctionalRange object
594  * and returns the SedParameter object created.
595  */
596 SedParameter*
createParameter()597 SedFunctionalRange::createParameter()
598 {
599   SedParameter* sp = NULL;
600 
601   try
602   {
603     sp = new SedParameter(getSedNamespaces());
604   }
605   catch (...)
606   {
607   }
608 
609   if (sp != NULL)
610   {
611     mParameters.appendAndOwn(sp);
612   }
613 
614   return sp;
615 }
616 
617 
618 /*
619  * Removes the nth SedParameter from this SedFunctionalRange and returns a
620  * pointer to it.
621  */
622 SedParameter*
removeParameter(unsigned int n)623 SedFunctionalRange::removeParameter(unsigned int n)
624 {
625   return mParameters.remove(n);
626 }
627 
628 
629 /*
630  * Removes the SedParameter from this SedFunctionalRange based on its
631  * identifier and returns a pointer to it.
632  */
633 SedParameter*
removeParameter(const std::string & sid)634 SedFunctionalRange::removeParameter(const std::string& sid)
635 {
636   return mParameters.remove(sid);
637 }
638 
639 
640 /*
641  * @copydoc doc_renamesidref_common
642  */
643 void
renameSIdRefs(const std::string & oldid,const std::string & newid)644 SedFunctionalRange::renameSIdRefs(const std::string& oldid,
645                                   const std::string& newid)
646 {
647   if (isSetRange() && mRange == oldid)
648   {
649     setRange(newid);
650   }
651 
652   if (isSetMath())
653   {
654     mMath->renameSIdRefs(oldid, newid);
655   }
656 }
657 
658 
659 /*
660  * Returns the XML element name of this SedFunctionalRange object.
661  */
662 const std::string&
getElementName() const663 SedFunctionalRange::getElementName() const
664 {
665   static const string name = "functionalRange";
666   return name;
667 }
668 
669 
670 /*
671  * Returns the libSEDML type code for this SedFunctionalRange object.
672  */
673 int
getTypeCode() const674 SedFunctionalRange::getTypeCode() const
675 {
676   return SEDML_RANGE_FUNCTIONALRANGE;
677 }
678 
679 
680 /*
681  * Predicate returning @c true if all the required attributes for this
682  * SedFunctionalRange object have been set.
683  */
684 bool
hasRequiredAttributes() const685 SedFunctionalRange::hasRequiredAttributes() const
686 {
687   bool allPresent = SedRange::hasRequiredAttributes();
688 
689   if (isSetRange() == false)
690   {
691     allPresent = false;
692   }
693 
694   return allPresent;
695 }
696 
697 
698 /*
699  * Predicate returning @c true if all the required elements for this
700  * SedFunctionalRange object have been set.
701  */
702 bool
hasRequiredElements() const703 SedFunctionalRange::hasRequiredElements() const
704 {
705   bool allPresent = SedRange::hasRequiredElements();
706 
707   return allPresent;
708 }
709 
710 
711 
712 /** @cond doxygenLibSEDMLInternal */
713 
714 /*
715  * Write any contained elements
716  */
717 void
writeElements(LIBSBML_CPP_NAMESPACE_QUALIFIER XMLOutputStream & stream) const718 SedFunctionalRange::writeElements(LIBSBML_CPP_NAMESPACE_QUALIFIER
719   XMLOutputStream& stream) const
720 {
721   SedRange::writeElements(stream);
722 
723   if (isSetMath() == true)
724   {
725     writeMathML(getMath(), stream, NULL);
726   }
727 
728   if (getNumVariables() > 0)
729   {
730     mVariables.write(stream);
731   }
732 
733   if (getNumParameters() > 0)
734   {
735     mParameters.write(stream);
736   }
737 }
738 
739 /** @endcond */
740 
741 
742 
743 /** @cond doxygenLibSEDMLInternal */
744 
745 /*
746  * Accepts the given SedVisitor
747  */
748 bool
accept(SedVisitor & v) const749 SedFunctionalRange::accept(SedVisitor& v) const
750 {
751   return false;
752 }
753 
754 /** @endcond */
755 
756 
757 
758 /** @cond doxygenLibSEDMLInternal */
759 
760 /*
761  * Sets the parent SedDocument
762  */
763 void
setSedDocument(SedDocument * d)764 SedFunctionalRange::setSedDocument(SedDocument* d)
765 {
766   SedRange::setSedDocument(d);
767 
768   mVariables.setSedDocument(d);
769 
770   mParameters.setSedDocument(d);
771 }
772 
773 /** @endcond */
774 
775 
776 
777 /** @cond doxygenLibSEDMLInternal */
778 
779 /*
780  * Connects to child elements
781  */
782 void
connectToChild()783 SedFunctionalRange::connectToChild()
784 {
785   SedRange::connectToChild();
786 
787   mVariables.connectToParent(this);
788 
789   mParameters.connectToParent(this);
790 }
791 
792 /** @endcond */
793 
794 
795 
796 /** @cond doxygenLibSEDMLInternal */
797 
798 /*
799  * Gets the value of the "attributeName" attribute of this SedFunctionalRange.
800  */
801 int
getAttribute(const std::string & attributeName,bool & value) const802 SedFunctionalRange::getAttribute(const std::string& attributeName,
803                                  bool& value) const
804 {
805   int return_value = SedRange::getAttribute(attributeName, value);
806 
807   return return_value;
808 }
809 
810 /** @endcond */
811 
812 
813 
814 /** @cond doxygenLibSEDMLInternal */
815 
816 /*
817  * Gets the value of the "attributeName" attribute of this SedFunctionalRange.
818  */
819 int
getAttribute(const std::string & attributeName,int & value) const820 SedFunctionalRange::getAttribute(const std::string& attributeName,
821                                  int& value) const
822 {
823   int return_value = SedRange::getAttribute(attributeName, value);
824 
825   return return_value;
826 }
827 
828 /** @endcond */
829 
830 
831 
832 /** @cond doxygenLibSEDMLInternal */
833 
834 /*
835  * Gets the value of the "attributeName" attribute of this SedFunctionalRange.
836  */
837 int
getAttribute(const std::string & attributeName,double & value) const838 SedFunctionalRange::getAttribute(const std::string& attributeName,
839                                  double& value) const
840 {
841   int return_value = SedRange::getAttribute(attributeName, value);
842 
843   return return_value;
844 }
845 
846 /** @endcond */
847 
848 
849 
850 /** @cond doxygenLibSEDMLInternal */
851 
852 /*
853  * Gets the value of the "attributeName" attribute of this SedFunctionalRange.
854  */
855 int
getAttribute(const std::string & attributeName,unsigned int & value) const856 SedFunctionalRange::getAttribute(const std::string& attributeName,
857                                  unsigned int& value) const
858 {
859   int return_value = SedRange::getAttribute(attributeName, value);
860 
861   return return_value;
862 }
863 
864 /** @endcond */
865 
866 
867 
868 /** @cond doxygenLibSEDMLInternal */
869 
870 /*
871  * Gets the value of the "attributeName" attribute of this SedFunctionalRange.
872  */
873 int
getAttribute(const std::string & attributeName,std::string & value) const874 SedFunctionalRange::getAttribute(const std::string& attributeName,
875                                  std::string& value) const
876 {
877   int return_value = SedRange::getAttribute(attributeName, value);
878 
879   if (return_value == LIBSEDML_OPERATION_SUCCESS)
880   {
881     return return_value;
882   }
883 
884   if (attributeName == "range")
885   {
886     value = getRange();
887     return_value = LIBSEDML_OPERATION_SUCCESS;
888   }
889 
890   return return_value;
891 }
892 
893 /** @endcond */
894 
895 
896 
897 /** @cond doxygenLibSEDMLInternal */
898 
899 /*
900  * Predicate returning @c true if this SedFunctionalRange's attribute
901  * "attributeName" is set.
902  */
903 bool
isSetAttribute(const std::string & attributeName) const904 SedFunctionalRange::isSetAttribute(const std::string& attributeName) const
905 {
906   bool value = SedRange::isSetAttribute(attributeName);
907 
908   if (attributeName == "range")
909   {
910     value = isSetRange();
911   }
912 
913   return value;
914 }
915 
916 /** @endcond */
917 
918 
919 
920 /** @cond doxygenLibSEDMLInternal */
921 
922 /*
923  * Sets the value of the "attributeName" attribute of this SedFunctionalRange.
924  */
925 int
setAttribute(const std::string & attributeName,bool value)926 SedFunctionalRange::setAttribute(const std::string& attributeName, bool value)
927 {
928   int return_value = SedRange::setAttribute(attributeName, value);
929 
930   return return_value;
931 }
932 
933 /** @endcond */
934 
935 
936 
937 /** @cond doxygenLibSEDMLInternal */
938 
939 /*
940  * Sets the value of the "attributeName" attribute of this SedFunctionalRange.
941  */
942 int
setAttribute(const std::string & attributeName,int value)943 SedFunctionalRange::setAttribute(const std::string& attributeName, int value)
944 {
945   int return_value = SedRange::setAttribute(attributeName, value);
946 
947   return return_value;
948 }
949 
950 /** @endcond */
951 
952 
953 
954 /** @cond doxygenLibSEDMLInternal */
955 
956 /*
957  * Sets the value of the "attributeName" attribute of this SedFunctionalRange.
958  */
959 int
setAttribute(const std::string & attributeName,double value)960 SedFunctionalRange::setAttribute(const std::string& attributeName,
961                                  double value)
962 {
963   int return_value = SedRange::setAttribute(attributeName, value);
964 
965   return return_value;
966 }
967 
968 /** @endcond */
969 
970 
971 
972 /** @cond doxygenLibSEDMLInternal */
973 
974 /*
975  * Sets the value of the "attributeName" attribute of this SedFunctionalRange.
976  */
977 int
setAttribute(const std::string & attributeName,unsigned int value)978 SedFunctionalRange::setAttribute(const std::string& attributeName,
979                                  unsigned int value)
980 {
981   int return_value = SedRange::setAttribute(attributeName, value);
982 
983   return return_value;
984 }
985 
986 /** @endcond */
987 
988 
989 
990 /** @cond doxygenLibSEDMLInternal */
991 
992 /*
993  * Sets the value of the "attributeName" attribute of this SedFunctionalRange.
994  */
995 int
setAttribute(const std::string & attributeName,const std::string & value)996 SedFunctionalRange::setAttribute(const std::string& attributeName,
997                                  const std::string& value)
998 {
999   int return_value = SedRange::setAttribute(attributeName, value);
1000 
1001   if (attributeName == "range")
1002   {
1003     return_value = setRange(value);
1004   }
1005 
1006   return return_value;
1007 }
1008 
1009 /** @endcond */
1010 
1011 
1012 
1013 /** @cond doxygenLibSEDMLInternal */
1014 
1015 /*
1016  * Unsets the value of the "attributeName" attribute of this
1017  * SedFunctionalRange.
1018  */
1019 int
unsetAttribute(const std::string & attributeName)1020 SedFunctionalRange::unsetAttribute(const std::string& attributeName)
1021 {
1022   int value = SedRange::unsetAttribute(attributeName);
1023 
1024   if (attributeName == "range")
1025   {
1026     value = unsetRange();
1027   }
1028 
1029   return value;
1030 }
1031 
1032 /** @endcond */
1033 
1034 
1035 
1036 /** @cond doxygenLibSEDMLInternal */
1037 
1038 /*
1039  * Creates and returns an new "elementName" object in this SedFunctionalRange.
1040  */
1041 SedBase*
createChildObject(const std::string & elementName)1042 SedFunctionalRange::createChildObject(const std::string& elementName)
1043 {
1044   SedRange* obj = NULL;
1045 
1046   if (elementName == "variable")
1047   {
1048     return createVariable();
1049   }
1050 
1051   if (elementName == "parameter")
1052   {
1053     return createParameter();
1054   }
1055 
1056   return obj;
1057 }
1058 
1059 /** @endcond */
1060 
1061 
1062 
1063 /** @cond doxygenLibSEDMLInternal */
1064 
1065 /*
1066  * Adds a new "elementName" object to this SedFunctionalRange.
1067  */
1068 int
addChildObject(const std::string & elementName,const SedBase * element)1069 SedFunctionalRange::addChildObject(const std::string& elementName,
1070                                    const SedBase* element)
1071 {
1072   if (elementName == "variable" && element->getTypeCode() == SEDML_VARIABLE)
1073   {
1074     return addVariable((const SedVariable*)(element));
1075   }
1076   else if (elementName == "parameter" && element->getTypeCode() ==
1077     SEDML_PARAMETER)
1078   {
1079     return addParameter((const SedParameter*)(element));
1080   }
1081 
1082   return LIBSBML_OPERATION_FAILED;
1083 }
1084 
1085 /** @endcond */
1086 
1087 
1088 
1089 /** @cond doxygenLibSEDMLInternal */
1090 
1091 /*
1092  * Removes and returns the new "elementName" object with the given id in this
1093  * SedFunctionalRange.
1094  */
1095 SedBase*
removeChildObject(const std::string & elementName,const std::string & id)1096 SedFunctionalRange::removeChildObject(const std::string& elementName,
1097                                       const std::string& id)
1098 {
1099   if (elementName == "variable")
1100   {
1101     return removeVariable(id);
1102   }
1103   else if (elementName == "parameter")
1104   {
1105     return removeParameter(id);
1106   }
1107 
1108   return NULL;
1109 }
1110 
1111 /** @endcond */
1112 
1113 
1114 
1115 /** @cond doxygenLibSEDMLInternal */
1116 
1117 /*
1118  * Returns the number of "elementName" in this SedFunctionalRange.
1119  */
1120 unsigned int
getNumObjects(const std::string & elementName)1121 SedFunctionalRange::getNumObjects(const std::string& elementName)
1122 {
1123   unsigned int n = 0;
1124 
1125   if (elementName == "variable")
1126   {
1127     return getNumVariables();
1128   }
1129   else if (elementName == "parameter")
1130   {
1131     return getNumParameters();
1132   }
1133 
1134   return n;
1135 }
1136 
1137 /** @endcond */
1138 
1139 
1140 
1141 /** @cond doxygenLibSEDMLInternal */
1142 
1143 /*
1144  * Returns the nth object of "objectName" in this SedFunctionalRange.
1145  */
1146 SedBase*
getObject(const std::string & elementName,unsigned int index)1147 SedFunctionalRange::getObject(const std::string& elementName,
1148                               unsigned int index)
1149 {
1150   SedBase* obj = NULL;
1151 
1152   if (elementName == "variable")
1153   {
1154     return getVariable(index);
1155   }
1156   else if (elementName == "parameter")
1157   {
1158     return getParameter(index);
1159   }
1160 
1161   return obj;
1162 }
1163 
1164 /** @endcond */
1165 
1166 
1167 /*
1168  * Returns the first child element that has the given @p id in the model-wide
1169  * SId namespace, or @c NULL if no such object is found.
1170  */
1171 SedBase*
getElementBySId(const std::string & id)1172 SedFunctionalRange::getElementBySId(const std::string& id)
1173 {
1174   if (id.empty())
1175   {
1176     return NULL;
1177   }
1178 
1179   SedBase* obj = NULL;
1180 
1181   obj = mVariables.getElementBySId(id);
1182 
1183   if (obj != NULL)
1184   {
1185     return obj;
1186   }
1187 
1188   obj = mParameters.getElementBySId(id);
1189 
1190   if (obj != NULL)
1191   {
1192     return obj;
1193   }
1194 
1195   return obj;
1196 }
1197 
1198 
1199 /*
1200  * Returns a List of all child SedBase objects, including those nested to an
1201  * arbitrary depth.
1202  */
1203 List*
getAllElements(SedElementFilter * filter)1204 SedFunctionalRange::getAllElements(SedElementFilter* filter)
1205 {
1206   List* ret = new List();
1207   List* sublist = NULL;
1208 
1209   SED_ADD_FILTERED_LIST(ret, sublist, mVariables, filter);
1210   SED_ADD_FILTERED_LIST(ret, sublist, mParameters, filter);
1211 
1212   return ret;
1213 }
1214 
1215 
1216 
1217 /** @cond doxygenLibSEDMLInternal */
1218 
1219 /*
1220  * Creates a new object from the next XMLToken on the XMLInputStream
1221  */
1222 SedBase*
createObject(LIBSBML_CPP_NAMESPACE_QUALIFIER XMLInputStream & stream)1223 SedFunctionalRange::createObject(LIBSBML_CPP_NAMESPACE_QUALIFIER
1224   XMLInputStream& stream)
1225 {
1226   SedBase* obj = SedRange::createObject(stream);
1227 
1228   const std::string& name = stream.peek().getName();
1229 
1230   if (name == "listOfVariables")
1231   {
1232     if (getErrorLog() && mVariables.size() != 0)
1233     {
1234       getErrorLog()->logError(SedmlFunctionalRangeAllowedElements, getLevel(),
1235         getVersion(), "", getLine(), getColumn());
1236     }
1237 
1238     obj = &mVariables;
1239   }
1240   else if (name == "listOfParameters")
1241   {
1242     if (getErrorLog() && mParameters.size() != 0)
1243     {
1244       getErrorLog()->logError(SedmlFunctionalRangeAllowedElements, getLevel(),
1245         getVersion(), "", getLine(), getColumn());
1246     }
1247 
1248     obj = &mParameters;
1249   }
1250 
1251   connectToChild();
1252 
1253   return obj;
1254 }
1255 
1256 /** @endcond */
1257 
1258 
1259 
1260 /** @cond doxygenLibSEDMLInternal */
1261 
1262 /*
1263  * Adds the expected attributes for this element
1264  */
1265 void
addExpectedAttributes(LIBSBML_CPP_NAMESPACE_QUALIFIER ExpectedAttributes & attributes)1266 SedFunctionalRange::addExpectedAttributes(LIBSBML_CPP_NAMESPACE_QUALIFIER
1267   ExpectedAttributes& attributes)
1268 {
1269   SedRange::addExpectedAttributes(attributes);
1270 
1271   attributes.add("range");
1272 }
1273 
1274 /** @endcond */
1275 
1276 
1277 
1278 /** @cond doxygenLibSEDMLInternal */
1279 
1280 /*
1281  * Reads the expected attributes into the member data variables
1282  */
1283 void
readAttributes(const LIBSBML_CPP_NAMESPACE_QUALIFIER XMLAttributes & attributes,const LIBSBML_CPP_NAMESPACE_QUALIFIER ExpectedAttributes & expectedAttributes)1284 SedFunctionalRange::readAttributes(
1285                                    const LIBSBML_CPP_NAMESPACE_QUALIFIER
1286                                      XMLAttributes& attributes,
1287                                    const LIBSBML_CPP_NAMESPACE_QUALIFIER
1288                                      ExpectedAttributes& expectedAttributes)
1289 {
1290   unsigned int level = getLevel();
1291   unsigned int version = getVersion();
1292   unsigned int numErrs;
1293   bool assigned = false;
1294   SedErrorLog* log = getErrorLog();
1295 
1296   SedRange::readAttributes(attributes, expectedAttributes);
1297 
1298   if (log)
1299   {
1300     numErrs = log->getNumErrors();
1301 
1302     for (int n = numErrs-1; n >= 0; n--)
1303     {
1304       if (log->getError(n)->getErrorId() == SedUnknownCoreAttribute)
1305       {
1306         const std::string details = log->getError(n)->getMessage();
1307         log->remove(SedUnknownCoreAttribute);
1308         log->logError(SedmlFunctionalRangeAllowedAttributes, level, version,
1309           details, getLine(), getColumn());
1310       }
1311     }
1312   }
1313 
1314   //
1315   // range SIdRef (use = "required" )
1316   //
1317 
1318   assigned = attributes.readInto("range", mRange);
1319 
1320   if (assigned == true)
1321   {
1322     if (mRange.empty() == true)
1323     {
1324       logEmptyString(mRange, level, version, "<SedFunctionalRange>");
1325     }
1326     else if (SyntaxChecker::isValidSBMLSId(mRange) == false)
1327     {
1328       std::string msg = "The range attribute on the <" + getElementName() +
1329         ">";
1330       if (isSetId())
1331       {
1332         msg += " with id '" + getId() + "'";
1333       }
1334 
1335       msg += " is '" + mRange + "', which does not conform to the syntax.";
1336       logError(SedmlFunctionalRangeRangeMustBeRange, level, version, msg,
1337         getLine(), getColumn());
1338     }
1339   }
1340   else
1341   {
1342     if (log)
1343     {
1344       std::string message = "Sedml attribute 'range' is missing from the "
1345         "<SedFunctionalRange> element.";
1346       log->logError(SedmlFunctionalRangeAllowedAttributes, level, version,
1347         message, getLine(), getColumn());
1348     }
1349   }
1350 }
1351 
1352 /** @endcond */
1353 
1354 
1355 
1356 /** @cond doxygenLibSEDMLInternal */
1357 
1358 /*
1359  * Reads other XML such as math/notes etc.
1360  */
1361 bool
readOtherXML(LIBSBML_CPP_NAMESPACE_QUALIFIER XMLInputStream & stream)1362 SedFunctionalRange::readOtherXML(LIBSBML_CPP_NAMESPACE_QUALIFIER
1363   XMLInputStream& stream)
1364 {
1365   bool read = false;
1366   const string& name = stream.peek().getName();
1367 
1368   if (name == "math")
1369   {
1370     const LIBSBML_CPP_NAMESPACE_QUALIFIER XMLToken elem = stream.peek();
1371     const std::string prefix = checkMathMLNamespace(elem);
1372     delete mMath;
1373     mMath = readMathML(stream, prefix);
1374     read = true;
1375   }
1376 
1377   if (SedRange::readOtherXML(stream))
1378   {
1379     read = true;
1380   }
1381 
1382   return read;
1383 }
1384 
1385 /** @endcond */
1386 
1387 
1388 
1389 /** @cond doxygenLibSEDMLInternal */
1390 
1391 /*
1392  * Writes the attributes to the stream
1393  */
1394 void
writeAttributes(LIBSBML_CPP_NAMESPACE_QUALIFIER XMLOutputStream & stream) const1395 SedFunctionalRange::writeAttributes(LIBSBML_CPP_NAMESPACE_QUALIFIER
1396   XMLOutputStream& stream) const
1397 {
1398   SedRange::writeAttributes(stream);
1399 
1400   if (isSetRange() == true)
1401   {
1402     stream.writeAttribute("range", getPrefix(), mRange);
1403   }
1404 }
1405 
1406 /** @endcond */
1407 
1408 
1409 
1410 
1411 #endif /* __cplusplus */
1412 
1413 
1414 /*
1415  * Creates a new SedFunctionalRange_t using the given SED-ML Level and @ p
1416  * version values.
1417  */
1418 LIBSEDML_EXTERN
1419 SedFunctionalRange_t *
SedFunctionalRange_create(unsigned int level,unsigned int version)1420 SedFunctionalRange_create(unsigned int level, unsigned int version)
1421 {
1422   return new SedFunctionalRange(level, version);
1423 }
1424 
1425 
1426 /*
1427  * Creates and returns a deep copy of this SedFunctionalRange_t object.
1428  */
1429 LIBSEDML_EXTERN
1430 SedFunctionalRange_t*
SedFunctionalRange_clone(const SedFunctionalRange_t * sfr)1431 SedFunctionalRange_clone(const SedFunctionalRange_t* sfr)
1432 {
1433   if (sfr != NULL)
1434   {
1435     return static_cast<SedFunctionalRange_t*>(sfr->clone());
1436   }
1437   else
1438   {
1439     return NULL;
1440   }
1441 }
1442 
1443 
1444 /*
1445  * Frees this SedFunctionalRange_t object.
1446  */
1447 LIBSEDML_EXTERN
1448 void
SedFunctionalRange_free(SedFunctionalRange_t * sfr)1449 SedFunctionalRange_free(SedFunctionalRange_t* sfr)
1450 {
1451   if (sfr != NULL)
1452   {
1453     delete sfr;
1454   }
1455 }
1456 
1457 
1458 /*
1459  * Returns the value of the "range" attribute of this SedFunctionalRange_t.
1460  */
1461 LIBSEDML_EXTERN
1462 char *
SedFunctionalRange_getRange(const SedFunctionalRange_t * sfr)1463 SedFunctionalRange_getRange(const SedFunctionalRange_t * sfr)
1464 {
1465   if (sfr == NULL)
1466   {
1467     return NULL;
1468   }
1469 
1470   return sfr->getRange().empty() ? NULL : safe_strdup(sfr->getRange().c_str());
1471 }
1472 
1473 
1474 /*
1475  * Predicate returning @c 1 (true) if this SedFunctionalRange_t's "range"
1476  * attribute is set.
1477  */
1478 LIBSEDML_EXTERN
1479 int
SedFunctionalRange_isSetRange(const SedFunctionalRange_t * sfr)1480 SedFunctionalRange_isSetRange(const SedFunctionalRange_t * sfr)
1481 {
1482   return (sfr != NULL) ? static_cast<int>(sfr->isSetRange()) : 0;
1483 }
1484 
1485 
1486 /*
1487  * Sets the value of the "range" attribute of this SedFunctionalRange_t.
1488  */
1489 LIBSEDML_EXTERN
1490 int
SedFunctionalRange_setRange(SedFunctionalRange_t * sfr,const char * range)1491 SedFunctionalRange_setRange(SedFunctionalRange_t * sfr, const char * range)
1492 {
1493   return (sfr != NULL) ? sfr->setRange(range) : LIBSEDML_INVALID_OBJECT;
1494 }
1495 
1496 
1497 /*
1498  * Unsets the value of the "range" attribute of this SedFunctionalRange_t.
1499  */
1500 LIBSEDML_EXTERN
1501 int
SedFunctionalRange_unsetRange(SedFunctionalRange_t * sfr)1502 SedFunctionalRange_unsetRange(SedFunctionalRange_t * sfr)
1503 {
1504   return (sfr != NULL) ? sfr->unsetRange() : LIBSEDML_INVALID_OBJECT;
1505 }
1506 
1507 
1508 /*
1509  * Returns the value of the "math" element of this SedFunctionalRange_t.
1510  */
1511 LIBSEDML_EXTERN
1512 const LIBSBML_CPP_NAMESPACE_QUALIFIER ASTNode_t*
SedFunctionalRange_getMath(const SedFunctionalRange_t * sfr)1513 SedFunctionalRange_getMath(const SedFunctionalRange_t * sfr)
1514 {
1515   if (sfr == NULL)
1516   {
1517     return NULL;
1518   }
1519 
1520   return (LIBSBML_CPP_NAMESPACE_QUALIFIER ASTNode_t*)(sfr->getMath());
1521 }
1522 
1523 
1524 /*
1525  * Predicate returning @c 1 (true) if this SedFunctionalRange_t's "math"
1526  * element is set.
1527  */
1528 LIBSEDML_EXTERN
1529 int
SedFunctionalRange_isSetMath(const SedFunctionalRange_t * sfr)1530 SedFunctionalRange_isSetMath(const SedFunctionalRange_t * sfr)
1531 {
1532   return (sfr != NULL) ? static_cast<int>(sfr->isSetMath()) : 0;
1533 }
1534 
1535 
1536 /*
1537  * Sets the value of the "math" element of this SedFunctionalRange_t.
1538  */
1539 LIBSEDML_EXTERN
1540 int
SedFunctionalRange_setMath(SedFunctionalRange_t * sfr,const LIBSBML_CPP_NAMESPACE_QUALIFIER ASTNode_t * math)1541 SedFunctionalRange_setMath(SedFunctionalRange_t * sfr,
1542                            const LIBSBML_CPP_NAMESPACE_QUALIFIER ASTNode_t*
1543                              math)
1544 {
1545   return (sfr != NULL) ? sfr->setMath(math) : LIBSEDML_INVALID_OBJECT;
1546 }
1547 
1548 
1549 /*
1550  * Unsets the value of the "math" element of this SedFunctionalRange_t.
1551  */
1552 LIBSEDML_EXTERN
1553 int
SedFunctionalRange_unsetMath(SedFunctionalRange_t * sfr)1554 SedFunctionalRange_unsetMath(SedFunctionalRange_t * sfr)
1555 {
1556   return (sfr != NULL) ? sfr->unsetMath() : LIBSEDML_INVALID_OBJECT;
1557 }
1558 
1559 
1560 /*
1561  * Returns a ListOf_t * containing SedVariable_t objects from this
1562  * SedFunctionalRange_t.
1563  */
1564 LIBSEDML_EXTERN
1565 SedListOf_t*
SedFunctionalRange_getListOfVariables(SedFunctionalRange_t * sfr)1566 SedFunctionalRange_getListOfVariables(SedFunctionalRange_t* sfr)
1567 {
1568   return (sfr != NULL) ? sfr->getListOfVariables() : NULL;
1569 }
1570 
1571 
1572 /*
1573  * Get a SedVariable_t from the SedFunctionalRange_t.
1574  */
1575 LIBSEDML_EXTERN
1576 SedVariable_t*
SedFunctionalRange_getVariable(SedFunctionalRange_t * sfr,unsigned int n)1577 SedFunctionalRange_getVariable(SedFunctionalRange_t* sfr, unsigned int n)
1578 {
1579   return (sfr != NULL) ? sfr->getVariable(n) : NULL;
1580 }
1581 
1582 
1583 /*
1584  * Get a SedVariable_t from the SedFunctionalRange_t based on its identifier.
1585  */
1586 LIBSEDML_EXTERN
1587 SedVariable_t*
SedFunctionalRange_getVariableById(SedFunctionalRange_t * sfr,const char * sid)1588 SedFunctionalRange_getVariableById(SedFunctionalRange_t* sfr, const char *sid)
1589 {
1590   return (sfr != NULL && sid != NULL) ? sfr->getVariable(sid) : NULL;
1591 }
1592 
1593 
1594 /*
1595  * Get a SedVariable_t from the SedFunctionalRange_t based on the TaskReference
1596  * to which it refers.
1597  */
1598 LIBSEDML_EXTERN
1599 SedVariable_t*
SedFunctionalRange_getVariableByTaskReference(SedFunctionalRange_t * sfr,const char * sid)1600 SedFunctionalRange_getVariableByTaskReference(SedFunctionalRange_t* sfr,
1601                                               const char *sid)
1602 {
1603   return (sfr != NULL && sid != NULL) ? sfr->getVariableByTaskReference(sid) :
1604     NULL;
1605 }
1606 
1607 
1608 /*
1609  * Get a SedVariable_t from the SedFunctionalRange_t based on the
1610  * ModelReference to which it refers.
1611  */
1612 LIBSEDML_EXTERN
1613 SedVariable_t*
SedFunctionalRange_getVariableByModelReference(SedFunctionalRange_t * sfr,const char * sid)1614 SedFunctionalRange_getVariableByModelReference(SedFunctionalRange_t* sfr,
1615                                                const char *sid)
1616 {
1617   return (sfr != NULL && sid != NULL) ? sfr->getVariableByModelReference(sid) :
1618     NULL;
1619 }
1620 
1621 
1622 /*
1623  * Adds a copy of the given SedVariable_t to this SedFunctionalRange_t.
1624  */
1625 LIBSEDML_EXTERN
1626 int
SedFunctionalRange_addVariable(SedFunctionalRange_t * sfr,const SedVariable_t * sv)1627 SedFunctionalRange_addVariable(SedFunctionalRange_t* sfr,
1628                                const SedVariable_t* sv)
1629 {
1630   return (sfr != NULL) ? sfr->addVariable(sv) : LIBSEDML_INVALID_OBJECT;
1631 }
1632 
1633 
1634 /*
1635  * Get the number of SedVariable_t objects in this SedFunctionalRange_t.
1636  */
1637 LIBSEDML_EXTERN
1638 unsigned int
SedFunctionalRange_getNumVariables(SedFunctionalRange_t * sfr)1639 SedFunctionalRange_getNumVariables(SedFunctionalRange_t* sfr)
1640 {
1641   return (sfr != NULL) ? sfr->getNumVariables() : SEDML_INT_MAX;
1642 }
1643 
1644 
1645 /*
1646  * Creates a new SedVariable_t object, adds it to this SedFunctionalRange_t
1647  * object and returns the SedVariable_t object created.
1648  */
1649 LIBSEDML_EXTERN
1650 SedVariable_t*
SedFunctionalRange_createVariable(SedFunctionalRange_t * sfr)1651 SedFunctionalRange_createVariable(SedFunctionalRange_t* sfr)
1652 {
1653   return (sfr != NULL) ? sfr->createVariable() : NULL;
1654 }
1655 
1656 
1657 /*
1658  * Removes the nth SedVariable_t from this SedFunctionalRange_t and returns a
1659  * pointer to it.
1660  */
1661 LIBSEDML_EXTERN
1662 SedVariable_t*
SedFunctionalRange_removeVariable(SedFunctionalRange_t * sfr,unsigned int n)1663 SedFunctionalRange_removeVariable(SedFunctionalRange_t* sfr, unsigned int n)
1664 {
1665   return (sfr != NULL) ? sfr->removeVariable(n) : NULL;
1666 }
1667 
1668 
1669 /*
1670  * Removes the SedVariable_t from this SedFunctionalRange_t based on its
1671  * identifier and returns a pointer to it.
1672  */
1673 LIBSEDML_EXTERN
1674 SedVariable_t*
SedFunctionalRange_removeVariableById(SedFunctionalRange_t * sfr,const char * sid)1675 SedFunctionalRange_removeVariableById(SedFunctionalRange_t* sfr,
1676                                       const char* sid)
1677 {
1678   return (sfr != NULL && sid != NULL) ? sfr->removeVariable(sid) : NULL;
1679 }
1680 
1681 
1682 /*
1683  * Returns a ListOf_t * containing SedParameter_t objects from this
1684  * SedFunctionalRange_t.
1685  */
1686 LIBSEDML_EXTERN
1687 SedListOf_t*
SedFunctionalRange_getListOfParameters(SedFunctionalRange_t * sfr)1688 SedFunctionalRange_getListOfParameters(SedFunctionalRange_t* sfr)
1689 {
1690   return (sfr != NULL) ? sfr->getListOfParameters() : NULL;
1691 }
1692 
1693 
1694 /*
1695  * Get a SedParameter_t from the SedFunctionalRange_t.
1696  */
1697 LIBSEDML_EXTERN
1698 SedParameter_t*
SedFunctionalRange_getParameter(SedFunctionalRange_t * sfr,unsigned int n)1699 SedFunctionalRange_getParameter(SedFunctionalRange_t* sfr, unsigned int n)
1700 {
1701   return (sfr != NULL) ? sfr->getParameter(n) : NULL;
1702 }
1703 
1704 
1705 /*
1706  * Get a SedParameter_t from the SedFunctionalRange_t based on its identifier.
1707  */
1708 LIBSEDML_EXTERN
1709 SedParameter_t*
SedFunctionalRange_getParameterById(SedFunctionalRange_t * sfr,const char * sid)1710 SedFunctionalRange_getParameterById(SedFunctionalRange_t* sfr,
1711                                     const char *sid)
1712 {
1713   return (sfr != NULL && sid != NULL) ? sfr->getParameter(sid) : NULL;
1714 }
1715 
1716 
1717 /*
1718  * Adds a copy of the given SedParameter_t to this SedFunctionalRange_t.
1719  */
1720 LIBSEDML_EXTERN
1721 int
SedFunctionalRange_addParameter(SedFunctionalRange_t * sfr,const SedParameter_t * sp)1722 SedFunctionalRange_addParameter(SedFunctionalRange_t* sfr,
1723                                 const SedParameter_t* sp)
1724 {
1725   return (sfr != NULL) ? sfr->addParameter(sp) : LIBSEDML_INVALID_OBJECT;
1726 }
1727 
1728 
1729 /*
1730  * Get the number of SedParameter_t objects in this SedFunctionalRange_t.
1731  */
1732 LIBSEDML_EXTERN
1733 unsigned int
SedFunctionalRange_getNumParameters(SedFunctionalRange_t * sfr)1734 SedFunctionalRange_getNumParameters(SedFunctionalRange_t* sfr)
1735 {
1736   return (sfr != NULL) ? sfr->getNumParameters() : SEDML_INT_MAX;
1737 }
1738 
1739 
1740 /*
1741  * Creates a new SedParameter_t object, adds it to this SedFunctionalRange_t
1742  * object and returns the SedParameter_t object created.
1743  */
1744 LIBSEDML_EXTERN
1745 SedParameter_t*
SedFunctionalRange_createParameter(SedFunctionalRange_t * sfr)1746 SedFunctionalRange_createParameter(SedFunctionalRange_t* sfr)
1747 {
1748   return (sfr != NULL) ? sfr->createParameter() : NULL;
1749 }
1750 
1751 
1752 /*
1753  * Removes the nth SedParameter_t from this SedFunctionalRange_t and returns a
1754  * pointer to it.
1755  */
1756 LIBSEDML_EXTERN
1757 SedParameter_t*
SedFunctionalRange_removeParameter(SedFunctionalRange_t * sfr,unsigned int n)1758 SedFunctionalRange_removeParameter(SedFunctionalRange_t* sfr, unsigned int n)
1759 {
1760   return (sfr != NULL) ? sfr->removeParameter(n) : NULL;
1761 }
1762 
1763 
1764 /*
1765  * Removes the SedParameter_t from this SedFunctionalRange_t based on its
1766  * identifier and returns a pointer to it.
1767  */
1768 LIBSEDML_EXTERN
1769 SedParameter_t*
SedFunctionalRange_removeParameterById(SedFunctionalRange_t * sfr,const char * sid)1770 SedFunctionalRange_removeParameterById(SedFunctionalRange_t* sfr,
1771                                        const char* sid)
1772 {
1773   return (sfr != NULL && sid != NULL) ? sfr->removeParameter(sid) : NULL;
1774 }
1775 
1776 
1777 /*
1778  * Predicate returning @c 1 (true) if all the required attributes for this
1779  * SedFunctionalRange_t object have been set.
1780  */
1781 LIBSEDML_EXTERN
1782 int
SedFunctionalRange_hasRequiredAttributes(const SedFunctionalRange_t * sfr)1783 SedFunctionalRange_hasRequiredAttributes(const SedFunctionalRange_t * sfr)
1784 {
1785   return (sfr != NULL) ? static_cast<int>(sfr->hasRequiredAttributes()) : 0;
1786 }
1787 
1788 
1789 /*
1790  * Predicate returning @c 1 (true) if all the required elements for this
1791  * SedFunctionalRange_t object have been set.
1792  */
1793 LIBSEDML_EXTERN
1794 int
SedFunctionalRange_hasRequiredElements(const SedFunctionalRange_t * sfr)1795 SedFunctionalRange_hasRequiredElements(const SedFunctionalRange_t * sfr)
1796 {
1797   return (sfr != NULL) ? static_cast<int>(sfr->hasRequiredElements()) : 0;
1798 }
1799 
1800 
1801 
1802 
1803 LIBSEDML_CPP_NAMESPACE_END
1804 
1805 
1806