1 /**
2  * @file    Delay.cpp
3  * @brief   Implementation of Delay.
4  * @author  Sarah Keating
5  *
6  * <!--------------------------------------------------------------------------
7  * This file is part of libSBML.  Please visit http://sbml.org for more
8  * information about SBML, and the latest version of libSBML.
9  *
10  * Copyright (C) 2020 jointly by the following organizations:
11  *     1. California Institute of Technology, Pasadena, CA, USA
12  *     2. University of Heidelberg, Heidelberg, Germany
13  *     3. University College London, London, UK
14  *
15  * Copyright (C) 2019 jointly by the following organizations:
16  *     1. California Institute of Technology, Pasadena, CA, USA
17  *     2. University of Heidelberg, Heidelberg, Germany
18  *
19  * Copyright (C) 2013-2018 jointly by the following organizations:
20  *     1. California Institute of Technology, Pasadena, CA, USA
21  *     2. EMBL European Bioinformatics Institute (EMBL-EBI), Hinxton, UK
22  *     3. University of Heidelberg, Heidelberg, Germany
23  *
24  * Copyright (C) 2009-2013 jointly by the following organizations:
25  *     1. California Institute of Technology, Pasadena, CA, USA
26  *     2. EMBL European Bioinformatics Institute (EMBL-EBI), Hinxton, UK
27  *
28  * Copyright (C) 2006-2008 by the California Institute of Technology,
29  *     Pasadena, CA, USA
30  *
31  * Copyright (C) 2002-2005 jointly by the following organizations:
32  *     1. California Institute of Technology, Pasadena, CA, USA
33  *     2. Japan Science and Technology Agency, Japan
34  *
35  * This library is free software; you can redistribute it and/or modify it
36  * under the terms of the GNU Lesser General Public License as published by
37  * the Free Software Foundation.  A copy of the license agreement is provided
38  * in the file named "LICENSE.txt" included with this software distribution
39  * and also available online as http://sbml.org/software/libsbml/license.html
40  * ---------------------------------------------------------------------- -->*/
41 
42 #include <sbml/xml/XMLNode.h>
43 #include <sbml/xml/XMLAttributes.h>
44 #include <sbml/xml/XMLInputStream.h>
45 #include <sbml/xml/XMLOutputStream.h>
46 
47 #include <sbml/math/FormulaFormatter.h>
48 #include <sbml/math/FormulaParser.h>
49 #include <sbml/math/MathML.h>
50 #include <sbml/math/ASTNode.h>
51 
52 #include <sbml/SBO.h>
53 #include <sbml/SBMLVisitor.h>
54 #include <sbml/SBMLDocument.h>
55 #include <sbml/SBMLError.h>
56 #include <sbml/Model.h>
57 #include <sbml/Parameter.h>
58 #include <sbml/Delay.h>
59 
60 /** @cond doxygenIgnored */
61 using namespace std;
62 /** @endcond */
63 
64 LIBSBML_CPP_NAMESPACE_BEGIN
65 #ifdef __cplusplus
66 
Delay(unsigned int level,unsigned int version)67 Delay::Delay (unsigned int level, unsigned int version) :
68    SBase ( level, version )
69  , mMath      ( NULL              )
70  , mInternalId ( "" )
71 {
72   if (!hasValidLevelVersionNamespaceCombination())
73     throw SBMLConstructorException();
74 }
75 
76 
Delay(SBMLNamespaces * sbmlns)77 Delay::Delay (SBMLNamespaces * sbmlns) :
78    SBase ( sbmlns )
79  , mMath      ( NULL              )
80  , mInternalId ( "" )
81 {
82   if (!hasValidLevelVersionNamespaceCombination())
83   {
84     throw SBMLConstructorException(getElementName(), sbmlns);
85   }
86 
87   loadPlugins(sbmlns);
88 }
89 
90 
91 /*
92  * Destroys this Delay.
93  */
~Delay()94 Delay::~Delay ()
95 {
96   delete mMath;
97 }
98 
99 
100 /*
101  * Copy constructor. Creates a copy of this Delay.
102  */
Delay(const Delay & orig)103 Delay::Delay (const Delay& orig)
104  : SBase          ( orig )
105  , mMath          ( NULL )
106  , mInternalId    ( orig.mInternalId )
107 {
108 
109   if (orig.mMath != NULL)
110   {
111     mMath = orig.mMath->deepCopy();
112     mMath->setParentSBMLObject(this);
113   }
114 
115 }
116 
117 
118 /*
119  * Assignment operator
120  */
operator =(const Delay & rhs)121 Delay& Delay::operator=(const Delay& rhs)
122 {
123   if(&rhs!=this)
124   {
125     this->SBase::operator =(rhs);
126     this->mInternalId = rhs.mInternalId;
127 
128     delete mMath;
129     if (rhs.mMath != NULL)
130     {
131       mMath = rhs.mMath->deepCopy();
132       mMath->setParentSBMLObject(this);
133     }
134     else
135     {
136       mMath = NULL;
137     }
138   }
139 
140   return *this;
141 }
142 
143 
144 /** @cond doxygenLibsbmlInternal */
145 bool
accept(SBMLVisitor & v) const146 Delay::accept (SBMLVisitor& v) const
147 {
148   return v.visit(*this);
149 }
150 /** @endcond */
151 
152 
153 /*
154  * @return a (deep) copy of this Delay.
155  */
156 Delay*
clone() const157 Delay::clone () const
158 {
159   return new Delay(*this);
160 }
161 
162 
163 
164 /*
165  * @return the math of this Delay.
166  */
167 const ASTNode*
getMath() const168 Delay::getMath () const
169 {
170   return mMath;
171 }
172 
173 
174 /*
175  * @return @c true if the math (or equivalently the formula) of this
176  * Delay is set, false otherwise.
177  */
178 bool
isSetMath() const179 Delay::isSetMath () const
180 {
181   return (mMath != NULL);
182 }
183 
184 
185 /*
186  * Sets the math of this Delay to a copy of the given ASTNode.
187  */
188 int
setMath(const ASTNode * math)189 Delay::setMath (const ASTNode* math)
190 {
191   if (mMath == math)
192   {
193     return LIBSBML_OPERATION_SUCCESS;
194   }
195   else if (math == NULL)
196   {
197     delete mMath;
198     mMath = NULL;
199     return LIBSBML_OPERATION_SUCCESS;
200   }
201   else if (!(math->isWellFormedASTNode()))
202   {
203     return LIBSBML_INVALID_OBJECT;
204   }
205   else
206   {
207     delete mMath;
208     mMath = (math != NULL) ? math->deepCopy() : NULL;
209     if (mMath != NULL) mMath->setParentSBMLObject(this);
210     return LIBSBML_OPERATION_SUCCESS;
211   }
212 }
213 
214 /*
215   * Calculates and returns a UnitDefinition that expresses the units
216   * returned by the math expression of this InitialAssignment.
217   */
218 UnitDefinition *
getDerivedUnitDefinition()219 Delay::getDerivedUnitDefinition()
220 {
221   if (!isSetMath())
222     return NULL;
223   /* if we have the whole model but it is not in a document
224    * it is still possible to determine the units
225    */
226 
227   /* VERY NASTY HACK THAT WILL WORK IF WE DONT KNOW ABOUT COMP
228    * but will identify if the parent model is a ModelDefinition
229    */
230   Model * m = NULL;
231 
232   if (this->isPackageEnabled("comp"))
233   {
234     m = static_cast <Model *> (getAncestorOfType(251, "comp"));
235   }
236 
237   if (m == NULL)
238   {
239     m = static_cast <Model *> (getAncestorOfType(SBML_MODEL));
240   }
241 
242   /* we should have a model by this point
243    * OR the object is not yet a child of a model
244    */
245 
246 
247   if (m != NULL)
248   {
249     if (!m->isPopulatedListFormulaUnitsData())
250     {
251       m->populateListFormulaUnitsData();
252     }
253 
254     FormulaUnitsData *fud = m->getFormulaUnitsData(getId(), SBML_EVENT);
255     if (fud != NULL)
256     {
257       return fud->getUnitDefinition();
258     }
259     else
260     {
261       return NULL;
262     }
263   }
264   else
265   {
266     return NULL;
267   }
268 }
269 
270 
271 /*
272   * Constructs and returns a UnitDefinition that expresses the units of this
273   * Compartment.
274   */
275 const UnitDefinition *
getDerivedUnitDefinition() const276 Delay::getDerivedUnitDefinition() const
277 {
278   return const_cast <Delay *> (this)->getDerivedUnitDefinition();
279 }
280 
281 
282 /** @cond doxygenLibsbmlInternal */
283 /*
284  * Predicate returning @c true or @c false depending on whether
285  * the math expression of this InitialAssignment contains
286  * parameters/numbers with undeclared units that cannot be ignored.
287  */
288 bool
containsUndeclaredUnits()289 Delay::containsUndeclaredUnits()
290 {
291   if (!isSetMath())
292     return false;
293   /* if we have the whole model but it is not in a document
294    * it is still possible to determine the units
295    */
296 
297   /* VERY NASTY HACK THAT WILL WORK IF WE DONT KNOW ABOUT COMP
298    * but will identify if the parent model is a ModelDefinition
299    */
300   Model * m = NULL;
301 
302   if (this->isPackageEnabled("comp"))
303   {
304     m = static_cast <Model *> (getAncestorOfType(251, "comp"));
305   }
306 
307   if (m == NULL)
308   {
309     m = static_cast <Model *> (getAncestorOfType(SBML_MODEL));
310   }
311 
312   /* we should have a model by this point
313    * OR the object is not yet a child of a model
314    */
315 
316   if (m != NULL)
317   {
318     if (!m->isPopulatedListFormulaUnitsData())
319     {
320       m->populateListFormulaUnitsData();
321     }
322 
323     FormulaUnitsData *fud = m->getFormulaUnitsData(getId(), SBML_EVENT);
324     if (fud != NULL)
325     {
326       return fud->getContainsUndeclaredUnits();
327     }
328     else
329     {
330       return false;
331     }
332   }
333   else
334   {
335     return false;
336   }
337 }
338 /** @endcond */
339 
340 
341 /** @cond doxygenLibsbmlInternal */
342 /*
343  * Predicate returning @c true if
344  * the math expression of this InitialAssignment contains
345  * parameters/numbers with undeclared units that cannot be ignored.
346  */
347 bool
containsUndeclaredUnits() const348 Delay::containsUndeclaredUnits() const
349 {
350   return const_cast<Delay *> (this)->containsUndeclaredUnits();
351 }
352 /** @endcond */
353 
354 
355 /*
356  * @return the typecode (int) of this SBML object or SBML_UNKNOWN
357  * (default).
358  *
359  * @see getElementName()
360  */
361 int
getTypeCode() const362 Delay::getTypeCode () const
363 {
364   return SBML_DELAY;
365 }
366 
367 
368 /*
369  * @return the name of this element ie "delay".
370  */
371 const string&
getElementName() const372 Delay::getElementName () const
373 {
374   static const string name = "delay";
375   return name;
376 }
377 
378 
379 /** @cond doxygenLibsbmlInternal */
380 /*
381  * @return the ordinal position of the element with respect to its siblings
382  * or -1 (default) to indicate the position is not significant.
383  */
384 int
getElementPosition() const385 Delay::getElementPosition () const
386 {
387   return 1;
388 }
389 /** @endcond */
390 
391 
392 bool
hasRequiredElements() const393 Delay::hasRequiredElements() const
394 {
395   bool allPresent = true;
396 
397   /* required attributes for delay: math */
398   /* l3v2 removed that requirement */
399 
400   if ((getLevel() < 3 ) || (getLevel() == 3 && getVersion() == 1))
401   {
402     if (!isSetMath())
403       allPresent = false;
404   }
405 
406   return allPresent;
407 }
408 
removeFromParentAndDelete()409 int Delay::removeFromParentAndDelete()
410 {
411   SBase* parent = getParentSBMLObject();
412   if (parent==NULL) return LIBSBML_OPERATION_FAILED;
413   Event* parentEvent = static_cast<Event*>(parent);
414   if (parentEvent == NULL) return LIBSBML_OPERATION_FAILED;
415   return parentEvent->unsetDelay();
416 }
417 
418 
419 void
renameSIdRefs(const std::string & oldid,const std::string & newid)420 Delay::renameSIdRefs(const std::string& oldid, const std::string& newid)
421 {
422   SBase::renameSIdRefs(oldid, newid);
423   if (isSetMath()) {
424     mMath->renameSIdRefs(oldid, newid);
425   }
426 }
427 
428 void
renameUnitSIdRefs(const std::string & oldid,const std::string & newid)429 Delay::renameUnitSIdRefs(const std::string& oldid, const std::string& newid)
430 {
431   SBase::renameUnitSIdRefs(oldid, newid);
432   if (isSetMath()) {
433     mMath->renameUnitSIdRefs(oldid, newid);
434   }
435 }
436 
437 /** @cond doxygenLibsbmlInternal */
438 void
replaceSIDWithFunction(const std::string & id,const ASTNode * function)439 Delay::replaceSIDWithFunction(const std::string& id, const ASTNode* function)
440 {
441   if (isSetMath()) {
442     if (mMath->getType() == AST_NAME && mMath->getName() == id) {
443       delete mMath;
444       mMath = function->deepCopy();
445     }
446     else {
447       mMath->replaceIDWithFunction(id, function);
448     }
449   }
450 }
451 /** @endcond */
452 /** @cond doxygenLibsbmlInternal */
453 
454 /*
455  * Returns the value of the "attributeName" attribute of this Delay.
456  */
457 int
getAttribute(const std::string & attributeName,bool & value) const458 Delay::getAttribute(const std::string& attributeName, bool& value) const
459 {
460   int return_value = SBase::getAttribute(attributeName, value);
461 
462   return return_value;
463 }
464 
465 /** @endcond */
466 
467 
468 
469 /** @cond doxygenLibsbmlInternal */
470 
471 /*
472  * Returns the value of the "attributeName" attribute of this Delay.
473  */
474 int
getAttribute(const std::string & attributeName,int & value) const475 Delay::getAttribute(const std::string& attributeName, int& value) const
476 {
477   int return_value = SBase::getAttribute(attributeName, value);
478 
479   return return_value;
480 }
481 
482 /** @endcond */
483 
484 
485 
486 /** @cond doxygenLibsbmlInternal */
487 
488 /*
489  * Returns the value of the "attributeName" attribute of this Delay.
490  */
491 int
getAttribute(const std::string & attributeName,double & value) const492 Delay::getAttribute(const std::string& attributeName, double& value) const
493 {
494   int return_value = SBase::getAttribute(attributeName, value);
495 
496   return return_value;
497 }
498 
499 /** @endcond */
500 
501 
502 
503 /** @cond doxygenLibsbmlInternal */
504 
505 /*
506  * Returns the value of the "attributeName" attribute of this Delay.
507  */
508 int
getAttribute(const std::string & attributeName,unsigned int & value) const509 Delay::getAttribute(const std::string& attributeName,
510                     unsigned int& value) const
511 {
512   int return_value = SBase::getAttribute(attributeName, value);
513 
514   return return_value;
515 }
516 
517 /** @endcond */
518 
519 
520 
521 /** @cond doxygenLibsbmlInternal */
522 
523 /*
524  * Returns the value of the "attributeName" attribute of this Delay.
525  */
526 int
getAttribute(const std::string & attributeName,std::string & value) const527 Delay::getAttribute(const std::string& attributeName,
528                     std::string& value) const
529 {
530   int return_value = SBase::getAttribute(attributeName, value);
531 
532   return return_value;
533 }
534 
535 /** @endcond */
536 
537 
538 
539 /** @cond doxygenLibsbmlInternal */
540 
541 /*
542  * Returns the value of the "attributeName" attribute of this Delay.
543  */
544 //int
545 //Delay::getAttribute(const std::string& attributeName, const char* value) const
546 //{
547 //  int return_value = SBase::getAttribute(attributeName, value);
548 //
549 //  return return_value;
550 //}
551 
552 /** @endcond */
553 
554 
555 
556 /** @cond doxygenLibsbmlInternal */
557 
558 /*
559  * Predicate returning @c true if this Delay's attribute "attributeName" is
560  * set.
561  */
562 bool
isSetAttribute(const std::string & attributeName) const563 Delay::isSetAttribute(const std::string& attributeName) const
564 {
565   bool value = SBase::isSetAttribute(attributeName);
566 
567   return value;
568 }
569 
570 /** @endcond */
571 
572 
573 
574 /** @cond doxygenLibsbmlInternal */
575 
576 /*
577  * Sets the value of the "attributeName" attribute of this Delay.
578  */
579 int
setAttribute(const std::string & attributeName,bool value)580 Delay::setAttribute(const std::string& attributeName, bool value)
581 {
582   int return_value = SBase::setAttribute(attributeName, value);
583 
584   return return_value;
585 }
586 
587 /** @endcond */
588 
589 
590 
591 /** @cond doxygenLibsbmlInternal */
592 
593 /*
594  * Sets the value of the "attributeName" attribute of this Delay.
595  */
596 int
setAttribute(const std::string & attributeName,int value)597 Delay::setAttribute(const std::string& attributeName, int value)
598 {
599   int return_value = SBase::setAttribute(attributeName, value);
600 
601   return return_value;
602 }
603 
604 /** @endcond */
605 
606 
607 
608 /** @cond doxygenLibsbmlInternal */
609 
610 /*
611  * Sets the value of the "attributeName" attribute of this Delay.
612  */
613 int
setAttribute(const std::string & attributeName,double value)614 Delay::setAttribute(const std::string& attributeName, double value)
615 {
616   int return_value = SBase::setAttribute(attributeName, value);
617 
618   return return_value;
619 }
620 
621 /** @endcond */
622 
623 
624 
625 /** @cond doxygenLibsbmlInternal */
626 
627 /*
628  * Sets the value of the "attributeName" attribute of this Delay.
629  */
630 int
setAttribute(const std::string & attributeName,unsigned int value)631 Delay::setAttribute(const std::string& attributeName, unsigned int value)
632 {
633   int return_value = SBase::setAttribute(attributeName, value);
634 
635   return return_value;
636 }
637 
638 /** @endcond */
639 
640 
641 
642 /** @cond doxygenLibsbmlInternal */
643 
644 /*
645  * Sets the value of the "attributeName" attribute of this Delay.
646  */
647 int
setAttribute(const std::string & attributeName,const std::string & value)648 Delay::setAttribute(const std::string& attributeName,
649                     const std::string& value)
650 {
651   int return_value = SBase::setAttribute(attributeName, value);
652 
653   return return_value;
654 }
655 
656 /** @endcond */
657 
658 
659 
660 /** @cond doxygenLibsbmlInternal */
661 
662 /*
663  * Sets the value of the "attributeName" attribute of this Delay.
664  */
665 //int
666 //Delay::setAttribute(const std::string& attributeName, const char* value)
667 //{
668 //  int return_value = SBase::setAttribute(attributeName, value);
669 //
670 //  return return_value;
671 //}
672 
673 /** @endcond */
674 
675 
676 
677 /** @cond doxygenLibsbmlInternal */
678 
679 /*
680  * Unsets the value of the "attributeName" attribute of this Delay.
681  */
682 int
unsetAttribute(const std::string & attributeName)683 Delay::unsetAttribute(const std::string& attributeName)
684 {
685   int value = SBase::unsetAttribute(attributeName);
686 
687   return value;
688 }
689 
690 /** @endcond */
691 
692 
693 
694 /** @cond doxygenLibsbmlInternal */
695 /*
696  * Subclasses should override this method to read (and store) XHTML,
697  * MathML, etc. directly from the XMLInputStream.
698  *
699  * @return @c true if the subclass read from the stream, false otherwise.
700  */
701 bool
readOtherXML(XMLInputStream & stream)702 Delay::readOtherXML (XMLInputStream& stream)
703 {
704   bool          read = false;
705   const string& name = stream.peek().getName();
706 
707   if (name == "math")
708   {
709     // if this is level 1 there shouldnt be any math!!!
710     if (getLevel() == 1)
711     {
712       logError(NotSchemaConformant, getLevel(), getVersion(),
713 	       "SBML Level 1 does not support MathML.");
714       delete mMath;
715       return false;
716     }
717 
718     if (mMath != NULL)
719     {
720       if (getLevel() < 3)
721       {
722         logError(NotSchemaConformant, getLevel(), getVersion(),
723 	        "Only one <math> element is permitted inside a "
724 	        "particular containing element.");
725       }
726       else
727       {
728         logError(OneMathPerDelay, getLevel(), getVersion());
729       }
730     }
731     /* check for MathML namespace
732      * this may be explicitly declared here
733      * or implicitly declared on the whole document
734      */
735     const XMLToken elem = stream.peek();
736     const std::string prefix = checkMathMLNamespace(elem);
737 
738     delete mMath;
739     mMath = readMathML(stream, prefix);
740     if (mMath != NULL) mMath->setParentSBMLObject(this);
741     read  = true;
742   }
743 
744   /* ------------------------------
745    *
746    *   (EXTENSION)
747    *
748    * ------------------------------ */
749   if ( SBase::readOtherXML(stream) )
750     read = true;
751 
752   return read;
753 }
754 /** @endcond */
755 
756 
757 /** @cond doxygenLibsbmlInternal */
758 /**
759  * Subclasses should override this method to get the list of
760  * expected attributes.
761  * This function is invoked from corresponding readAttributes()
762  * function.
763  */
764 void
addExpectedAttributes(ExpectedAttributes & attributes)765 Delay::addExpectedAttributes(ExpectedAttributes& attributes)
766 {
767   SBase::addExpectedAttributes(attributes);
768 }
769 
770 
771 /*
772  * Subclasses should override this method to read values from the given
773  * XMLAttributes set into their specific fields.  Be sure to call your
774  * parent's implementation of this method as well.
775  */
776 void
readAttributes(const XMLAttributes & attributes,const ExpectedAttributes & expectedAttributes)777 Delay::readAttributes (const XMLAttributes& attributes,
778                        const ExpectedAttributes& expectedAttributes)
779 {
780   const unsigned int level   = getLevel  ();
781   const unsigned int version = getVersion();
782 
783   SBase::readAttributes(attributes, expectedAttributes);
784 
785   switch (level)
786   {
787   case 1:
788     logError(NotSchemaConformant, level, version,
789 	      "Delay is not a valid component for this level/version.");
790     break;
791   case 2:
792     readL2Attributes(attributes);
793     break;
794   case 3:
795   default:
796     readL3Attributes(attributes);
797     break;
798   }
799 }
800 /** @endcond */
801 
802 
803 /** @cond doxygenLibsbmlInternal */
804 /*
805  * Subclasses should override this method to read values from the given
806  * XMLAttributes set into their specific fields.  Be sure to call your
807  * parent's implementation of this method as well.
808  */
809 void
readL2Attributes(const XMLAttributes &)810 Delay::readL2Attributes (const XMLAttributes&)
811 {
812 }
813 /** @endcond */
814 
815 
816 /** @cond doxygenLibsbmlInternal */
817 /*
818  * Subclasses should override this method to read values from the given
819  * XMLAttributes set into their specific fields.  Be sure to call your
820  * parent's implementation of this method as well.
821  */
822 void
readL3Attributes(const XMLAttributes &)823 Delay::readL3Attributes (const XMLAttributes&)
824 {
825 }
826 /** @endcond */
827 
828 
829 /** @cond doxygenLibsbmlInternal */
830 /*
831  * Subclasses should override this method to write their XML attributes
832  * to the XMLOutputStream.  Be sure to call your parent's implementation
833  * of this method as well.
834  */
835 void
writeAttributes(XMLOutputStream & stream) const836 Delay::writeAttributes (XMLOutputStream& stream) const
837 {
838   SBase::writeAttributes(stream);
839 
840   const unsigned int level = getLevel();
841 
842   /* invalid level/version */
843   if (level < 2)
844   {
845     return;
846   }
847 
848   //
849   // sboTerm: SBOTerm { use="optional" }  (L2v3 ->)
850   // is written in SBase::writeAttributes()
851   //
852 
853   //
854   // (EXTENSION)
855   //
856   SBase::writeExtensionAttributes(stream);
857 }
858 /** @endcond */
859 
860 
861 /** @cond doxygenLibsbmlInternal */
862 /*
863  * Subclasses should override this method to write out their contained
864  * SBML objects as XML elements.  Be sure to call your parent's
865  * implementation of this method as well.
866  */
867 void
writeElements(XMLOutputStream & stream) const868 Delay::writeElements (XMLOutputStream& stream) const
869 {
870   SBase::writeElements(stream);
871 
872   if ( getLevel() > 1 && isSetMath() ) writeMathML(getMath(), stream, getSBMLNamespaces());
873 
874   //
875   // (EXTENSION)
876   //
877   SBase::writeExtensionElements(stream);
878 }
879 /** @endcond */
880 
881 
882 #endif /* __cplusplus */
883 /** @cond doxygenIgnored */
884 LIBSBML_EXTERN
885 Delay_t *
Delay_create(unsigned int level,unsigned int version)886 Delay_create (unsigned int level, unsigned int version)
887 {
888   try
889   {
890     Delay* obj = new Delay(level,version);
891     return obj;
892   }
893   catch (SBMLConstructorException)
894   {
895     return NULL;
896   }
897 }
898 
899 
900 LIBSBML_EXTERN
901 Delay_t *
Delay_createWithNS(SBMLNamespaces_t * sbmlns)902 Delay_createWithNS (SBMLNamespaces_t* sbmlns)
903 {
904   try
905   {
906     Delay* obj = new Delay(sbmlns);
907     return obj;
908   }
909   catch (SBMLConstructorException)
910   {
911     return NULL;
912   }
913 }
914 
915 
916 LIBSBML_EXTERN
917 void
Delay_free(Delay_t * t)918 Delay_free (Delay_t *t)
919 {
920   if (t != NULL)
921   delete t;
922 }
923 
924 
925 LIBSBML_EXTERN
926 Delay_t *
Delay_clone(const Delay_t * t)927 Delay_clone (const Delay_t *t)
928 {
929   return (t != NULL) ? t->clone() : NULL;
930 }
931 
932 
933 LIBSBML_EXTERN
934 const XMLNamespaces_t *
Delay_getNamespaces(Delay_t * d)935 Delay_getNamespaces(Delay_t *d)
936 {
937   return (d != NULL) ? d->getNamespaces() : NULL;
938 }
939 
940 LIBSBML_EXTERN
941 const ASTNode_t *
Delay_getMath(const Delay_t * t)942 Delay_getMath (const Delay_t *t)
943 {
944   return (t != NULL) ? t->getMath() : NULL;
945 }
946 
947 
948 LIBSBML_EXTERN
949 int
Delay_isSetMath(const Delay_t * t)950 Delay_isSetMath (const Delay_t *t)
951 {
952   return (t != NULL) ? static_cast<int>( t->isSetMath() ) : 0;
953 }
954 
955 
956 LIBSBML_EXTERN
957 int
Delay_setMath(Delay_t * t,const ASTNode_t * math)958 Delay_setMath (Delay_t *t, const ASTNode_t *math)
959 {
960   if (t != NULL)
961     return t->setMath(math);
962   else
963     return LIBSBML_INVALID_OBJECT;
964 
965 }
966 
967 LIBSBML_EXTERN
968 UnitDefinition_t *
Delay_getDerivedUnitDefinition(Delay_t * d)969 Delay_getDerivedUnitDefinition(Delay_t *d)
970 {
971   return (d != NULL) ? d->getDerivedUnitDefinition() : NULL;
972 }
973 
974 
975 LIBSBML_EXTERN
976 int
Delay_containsUndeclaredUnits(Delay_t * d)977 Delay_containsUndeclaredUnits(Delay_t *d)
978 {
979   return (d != NULL) ? static_cast<int>(d->containsUndeclaredUnits()) : 0;
980 }
981 /** @endcond */
982 
983 LIBSBML_CPP_NAMESPACE_END
984