001/* ----------------------------------------------------------------------------
002 * This file was automatically generated by SWIG (http://www.swig.org).
003 * Version 2.0.12
004 *
005 * Do not make changes to this file unless you know what you are doing--modify
006 * the SWIG interface file instead.
007 * ----------------------------------------------------------------------------- */
008
009package org.sbml.libsbml;
010
011/** 
012 *  SBML converter to convert a model's units to SI units.
013 <p>
014 * <p style='color: #777; font-style: italic'>
015This class of objects is defined by libSBML only and has no direct
016equivalent in terms of SBML components.  It is a class used in
017the implementation of extra functionality provided by libSBML.
018</p>
019
020 <p>
021 * This SBML converter converts the units in a model to base SI units,
022 * namely metre, kilogram, second, Ampere, Kelvin, mole and candela.
023 <p>
024 * {@link Unit} conversion will only be performed on models that are fully unit
025 * consistent; that is, all objects have associated units, and there are no
026 * literal numbers with no units specified.  In the case of an SBML
027 * Level&nbsp;3 model involving math expressions, this means that the 
028 * <code>timeUnits</code> attribute on the {@link Model} object must be set, and if there are
029 * any reactions in the model, the <code>extentUnits</code> attribute on the {@link Model}
030 * object must also be set.
031 <p>
032 * This converter has the additional Boolean property 'removeUnusedUnits'
033 * that can be used to tell the converter whether to remove any
034 * {@link UnitDefinition} objects that are not referred to, after conversion is
035 * complete.  You can set this value by adding the property using
036 * <div class='fragment'><pre class='fragment'>
037prop.addOption('removeUnusedUnits', false);
038</pre></div>
039 * The converter's default behavior is to remove the unused
040 * {@link UnitDefinition} objects in the model.
041 <p>
042 * @see SBMLFunctionDefinitionConverter
043 * @see SBMLLevelVersionConverter
044 * @see SBMLRuleConverter
045 * @see SBMLStripPackageConverter
046 * @see SBMLUnitsConverter
047 */
048
049public class SBMLUnitsConverter extends SBMLConverter {
050   private long swigCPtr;
051
052   protected SBMLUnitsConverter(long cPtr, boolean cMemoryOwn)
053   {
054     super(libsbmlJNI.SBMLUnitsConverter_SWIGUpcast(cPtr), cMemoryOwn);
055     swigCPtr = cPtr;
056   }
057
058   protected static long getCPtr(SBMLUnitsConverter obj)
059   {
060     return (obj == null) ? 0 : obj.swigCPtr;
061   }
062
063   protected static long getCPtrAndDisown (SBMLUnitsConverter obj)
064   {
065     long ptr = 0;
066
067     if (obj != null)
068     {
069       ptr             = obj.swigCPtr;
070       obj.swigCMemOwn = false;
071     }
072
073     return ptr;
074   }
075
076  protected void finalize() {
077    delete();
078  }
079
080  public synchronized void delete() {
081    if (swigCPtr != 0) {
082      if (swigCMemOwn) {
083        swigCMemOwn = false;
084        libsbmlJNI.delete_SBMLUnitsConverter(swigCPtr);
085      }
086      swigCPtr = 0;
087    }
088    super.delete();
089  }
090
091  public static void init() {
092    libsbmlJNI.SBMLUnitsConverter_init();
093  }
094
095  
096/**
097   * Creates a new {@link SBMLUnitsConverter} object.
098   */ public
099 SBMLUnitsConverter() {
100    this(libsbmlJNI.new_SBMLUnitsConverter__SWIG_0(), true);
101  }
102
103  
104/**
105   * Copy constructor; creates a copy of an {@link SBMLUnitsConverter}
106   * object.
107   <p>
108   * @param obj the {@link SBMLUnitsConverter} object to copy.
109   */ public
110 SBMLUnitsConverter(SBMLUnitsConverter obj) {
111    this(libsbmlJNI.new_SBMLUnitsConverter__SWIG_1(SBMLUnitsConverter.getCPtr(obj), obj), true);
112  }
113
114  
115/**
116   * Creates and returns a deep copy of this {@link SBMLUnitsConverter}
117   * object.
118   <p>
119   * @return a (deep) copy of this converter.
120   */ public
121 SBMLConverter cloneObject() {
122    long cPtr = libsbmlJNI.SBMLUnitsConverter_cloneObject(swigCPtr, this);
123    return (cPtr == 0) ? null : new SBMLUnitsConverter(cPtr, true);
124  }
125
126  
127/**
128   * Returns <code>true</code> if this converter object's properties match the given
129   * properties. 
130   <p>
131   * A typical use of this method involves creating a {@link ConversionProperties}
132   * object, setting the options desired, and then calling this method on
133   * an {@link SBMLUnitsConverter} object to find out if the object's
134   * property values match the given ones.  This method is also used by
135   * {@link SBMLConverterRegistry#getConverterFor(ConversionProperties props)}
136   * to search across all registered converters for one matching particular
137   * properties.
138   <p>
139   * @param props the properties to match.
140   <p>
141   * @return <code>true</code> if this converter's properties match, <code>false</code>
142   * otherwise.
143   */ public
144 boolean matchesProperties(ConversionProperties props) {
145    return libsbmlJNI.SBMLUnitsConverter_matchesProperties(swigCPtr, this, ConversionProperties.getCPtr(props), props);
146  }
147
148  
149/**
150   * Convers the units in the model to base SI units; namely metre,
151   * kilogram, second, Ampere, Kelvin, mole and candela.
152   <p>
153   * @return  integer value indicating the success/failure of the operation.
154   *  The possible values are:
155   * <ul>
156   * <li> {@link  libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS }
157   * <li> {@link  libsbmlConstants#LIBSBML_INVALID_OBJECT LIBSBML_INVALID_OBJECT }
158   * <li> {@link  libsbmlConstants#LIBSBML_CONV_CONVERSION_NOT_AVAILABLE LIBSBML_CONV_CONVERSION_NOT_AVAILABLE }
159   * <li> {@link  libsbmlConstants#LIBSBML_CONV_INVALID_SRC_DOCUMENT LIBSBML_CONV_INVALID_SRC_DOCUMENT }
160   * <li> {@link  libsbmlConstants#LIBSBML_OPERATION_FAILED LIBSBML_OPERATION_FAILED }
161   * </ul>
162   */ public
163 int convert() {
164    return libsbmlJNI.SBMLUnitsConverter_convert(swigCPtr, this);
165  }
166
167  
168/**
169   * Returns the default properties of this converter.
170   <p>
171   * A given converter exposes one or more properties that can be adjusted
172   * in order to influence the behavior of the converter.  This method
173   * returns the <em>default</em> property settings for this converter.  It is
174   * meant to be called in order to discover all the settings for the
175   * converter object.
176   <p>
177   * @return the {@link ConversionProperties} object describing the default properties
178   * for this converter.
179   */ public
180 ConversionProperties getDefaultProperties() {
181    return new ConversionProperties(libsbmlJNI.SBMLUnitsConverter_getDefaultProperties(swigCPtr, this), true);
182  }
183
184}