/* ----------------------------------------------------------------------------
 * This file was automatically generated by SWIG (http://www.swig.org).
 * Version 1.3.38
 *
 * Do not make changes to this file unless you know what you are doing--modify
 * the SWIG interface file instead.
 * ----------------------------------------------------------------------------- */

package org.sbml.libsbml;

/** 
 * LibSBML implementation of SBML's Trigger construct for Event.
 * <p>
 * An {@link Event} object defines when the event can occur, the variables that
 * are affected by the event, and how the variables are affected.  The
 * {@link Trigger} construct in SBML is used to define a mathematical expression
 * that determines when an {@link Event} <em>fires</em>.
 * <p>
 * A {@link Trigger} contains one subelement named 'math' containing a MathML
 * expression.  The expression must evaluate to a value of type <code>boolean</code>.
 * The exact moment at which the expression evaluates to <code>true</code> is the
 * time point when the {@link Event} is <em>fired</em>.
 * <p>
 * An event only fires when its {@link Trigger} expression makes the transition in
 * value from <code>false</code> to <code>true</code>.  The event will also fire at any future
 * time points when the trigger expression makes this transition; in other
 * words, an event can fire multiple times during a simulation if its
 * trigger condition makes the transition from <code>false</code> to <code>true</code> more
 * than once.
 * <p>
 * An important question is whether an event can fire prior to, or at,
 * initial simulation time, that is <em>t &lt; 0</em>.  The answer is no:
 * an event can only be triggered immediately after initial simulation time
 * i.e., <em>t &gt; 0</em>.
 * <p>
 * @see Event
 * @see Delay
 * @see EventAssignment
 */

public class Trigger extends SBase {
   private long swigCPtr;

   protected Trigger(long cPtr, boolean cMemoryOwn)
   {
     super(libsbmlJNI.SWIGTriggerUpcast(cPtr), cMemoryOwn);
     swigCPtr = cPtr;
   }

   protected static long getCPtr(Trigger obj)
   {
     return (obj == null) ? 0 : obj.swigCPtr;
   }

   protected static long getCPtrAndDisown (Trigger obj)
   {
     long ptr = 0;

     if (obj != null)
     {
       ptr             = obj.swigCPtr;
       obj.swigCMemOwn = false;
     }

     return ptr;
   }

  protected void finalize() {
    delete();
  }

  public synchronized void delete() {
    if(swigCPtr != 0 && swigCMemOwn) {
      swigCMemOwn = false;
      libsbmlJNI.delete_Trigger(swigCPtr);
    }
    swigCPtr = 0;
    super.delete();
  }

  
  /**
   * Creates a new {@link Trigger}, optionally with the given math. 
   * <p>
   * @param math an {@link ASTNode} representing the mathematical formula for
   * the trigger expression.
   * <p>
   * @docnote The native C++ implementation of this method defines a
   * default argument value.  In the documentation generated for different
   * libSBML language bindings, you may or may not see corresponding
   * arguments in the method declarations.  For example, in Java, a default
   * argument is handled by declaring two separate methods, with one of
   * them having the argument and the other one lacking the argument.
   * However, the libSBML documentation will be <em>identical</em> for both
   * methods.  Consequently, if you are reading this and do not see an
   * argument even though one is described, please look for descriptions of
   * other variants of this method near where this one appears in the
   * documentation.
   */
 public Trigger(ASTNode math) {
    this(libsbmlJNI.new_Trigger__SWIG_0(ASTNode.getCPtr(math), math), true);
  }

  
  /**
   * Creates a new {@link Trigger}, optionally with the given math. 
   * <p>
   * @param math an {@link ASTNode} representing the mathematical formula for
   * the trigger expression.
   * <p>
   * @docnote The native C++ implementation of this method defines a
   * default argument value.  In the documentation generated for different
   * libSBML language bindings, you may or may not see corresponding
   * arguments in the method declarations.  For example, in Java, a default
   * argument is handled by declaring two separate methods, with one of
   * them having the argument and the other one lacking the argument.
   * However, the libSBML documentation will be <em>identical</em> for both
   * methods.  Consequently, if you are reading this and do not see an
   * argument even though one is described, please look for descriptions of
   * other variants of this method near where this one appears in the
   * documentation.
   */
 public Trigger() {
    this(libsbmlJNI.new_Trigger__SWIG_1(), true);
  }

  
  /**
   * Creates a new {@link Trigger} using the given SBML <code>level</code> and <code>version</code>
   * values and optionally a set of XMLNamespaces.
   * <p>
   * @param level a long integer, the SBML Level to assign to this {@link Trigger}
   * <p>
   * @param version a long integer, the SBML Version to assign to this
   * {@link Trigger}
   * <p>
   * @param xmlns XMLNamespaces, a pointer to an array of XMLNamespaces to
   * assign to this {@link Trigger}
   * <p>
   * @note Once a {@link Trigger} has been added to an {@link SBMLDocument}, the <code>level</code>,
   * <code>version</code> and <code>xmlns</code> namespaces for the document <em>override</em> those used
   * to create the {@link Trigger}.  Despite this, the ability to supply the values
   * at creation time is an important aid to creating valid SBML.  Knowledge of
   * the intented SBML Level and Version determine whether it is valid to
   * assign a particular value to an attribute, or whether it is valid to add
   * an object to an existing {@link SBMLDocument}.
   * <p>
   * @docnote The native C++ implementation of this method defines a
   * default argument value.  In the documentation generated for different
   * libSBML language bindings, you may or may not see corresponding
   * arguments in the method declarations.  For example, in Java, a default
   * argument is handled by declaring two separate methods, with one of
   * them having the argument and the other one lacking the argument.
   * However, the libSBML documentation will be <em>identical</em> for both
   * methods.  Consequently, if you are reading this and do not see an
   * argument even though one is described, please look for descriptions of
   * other variants of this method near where this one appears in the
   * documentation.
   <p>
 * @deprecated libSBML internal
 */
 public Trigger(long level, long version, XMLNamespaces xmlns) {
    this(libsbmlJNI.new_Trigger__SWIG_2(level, version, XMLNamespaces.getCPtr(xmlns), xmlns), true);
  }

  
  /**
   * Creates a new {@link Trigger} using the given SBML <code>level</code> and <code>version</code>
   * values and optionally a set of XMLNamespaces.
   * <p>
   * @param level a long integer, the SBML Level to assign to this {@link Trigger}
   * <p>
   * @param version a long integer, the SBML Version to assign to this
   * {@link Trigger}
   * <p>
   * @param xmlns XMLNamespaces, a pointer to an array of XMLNamespaces to
   * assign to this {@link Trigger}
   * <p>
   * @note Once a {@link Trigger} has been added to an {@link SBMLDocument}, the <code>level</code>,
   * <code>version</code> and <code>xmlns</code> namespaces for the document <em>override</em> those used
   * to create the {@link Trigger}.  Despite this, the ability to supply the values
   * at creation time is an important aid to creating valid SBML.  Knowledge of
   * the intented SBML Level and Version determine whether it is valid to
   * assign a particular value to an attribute, or whether it is valid to add
   * an object to an existing {@link SBMLDocument}.
   * <p>
   * @docnote The native C++ implementation of this method defines a
   * default argument value.  In the documentation generated for different
   * libSBML language bindings, you may or may not see corresponding
   * arguments in the method declarations.  For example, in Java, a default
   * argument is handled by declaring two separate methods, with one of
   * them having the argument and the other one lacking the argument.
   * However, the libSBML documentation will be <em>identical</em> for both
   * methods.  Consequently, if you are reading this and do not see an
   * argument even though one is described, please look for descriptions of
   * other variants of this method near where this one appears in the
   * documentation.
   <p>
 * @deprecated libSBML internal
 */
 public Trigger(long level, long version) {
    this(libsbmlJNI.new_Trigger__SWIG_3(level, version), true);
  }

  
  /**
   * Copy constructor; creates a copy of this {@link Trigger}.
   */
 public Trigger(Trigger orig) {
    this(libsbmlJNI.new_Trigger__SWIG_4(Trigger.getCPtr(orig), orig), true);
  }

  
  /**
   * Creates and returns a deep copy of this {@link Trigger}.
   * <p>
   * @return a (deep) copy of this {@link Trigger}.
   */
 public Trigger cloneObject() {
    long cPtr = libsbmlJNI.Trigger_cloneObject(swigCPtr, this);
    return (cPtr == 0) ? null : new Trigger(cPtr, true);
  }

  
  /**
   * Get the mathematical formula for the trigger and return it
   * as an AST.
   * <p>
   * @return the math of this {@link Trigger}.
   */
 public ASTNode getMath() {
    long cPtr = libsbmlJNI.Trigger_getMath(swigCPtr, this);
    return (cPtr == 0) ? null : new ASTNode(cPtr, false);
  }

  
  /**
   * Predicate to test whether the math for this trigger has been set.
   * <p>
   * @return <code>true</code> if the formula (meaning the 'math' subelement) of
   * this {@link Trigger} has been set, <code>false</code> otherwise.
   */
 public boolean isSetMath() {
    return libsbmlJNI.Trigger_isSetMath(swigCPtr, this);
  }

  
  /**
   * Sets the trigger expression of this {@link Trigger} instance to a copy of the given
   * {@link ASTNode}.
   * <p>
   * @param math an {@link ASTNode} representing a formula tree.
   */
 public void setMath(ASTNode math) {
    libsbmlJNI.Trigger_setMath(swigCPtr, this, ASTNode.getCPtr(math), math);
  }

  
  /**
   * Sets the parent {@link SBMLDocument} of this SBML object.
   * <p>
   * @param d the {@link SBMLDocument} to use.
   <p>
 * @deprecated libSBML internal
 */
 public void setSBMLDocument(SBMLDocument d) {
    libsbmlJNI.Trigger_setSBMLDocument(swigCPtr, this, SBMLDocument.getCPtr(d), d);
  }

  
  /**
   * Sets the parent SBML object of this SBML object.
   * <p>
   * @param sb the SBML object to use
   <p>
 * @deprecated libSBML internal
 */
 public void setParentSBMLObject(SBase sb) {
    libsbmlJNI.Trigger_setParentSBMLObject(swigCPtr, this, SBase.getCPtr(sb), sb);
  }

  
  /**
   * Returns the libSBML type code of this object instance.
   * <p>
   * LibSBML attaches an
   * identifying code to every kind of SBML object.  These are known as
   * <em>SBML type codes</em>.  In other languages, the set of type codes
   * is stored in an enumeration; in the Java language interface for
   * libSBML, the type codes are defined as static integer constants in
   * interface class {@link libsbmlConstants}.  The names of the type codes
   * all begin with the characters <code>SBML_</code>. 
   * <p>
   * @return the SBML type code for this object, or <code>SBML_UNKNOWN</code> (default).
   * <p>
   * @see #getElementName()
   */
 public int getTypeCode() {
    return libsbmlJNI.Trigger_getTypeCode(swigCPtr, this);
  }

  
  /**
   * Returns the XML element name of this object, which for {@link Trigger}, is
   * always <code>'trigger'</code>.
   * <p>
   * @return the name of this element, i.e., <code>'trigger'</code>. 
   */
 public String getElementName() {
    return libsbmlJNI.Trigger_getElementName(swigCPtr, this);
  }

}
