001/* ----------------------------------------------------------------------------
002 * This file was automatically generated by SWIG (http://www.swig.org).
003 * Version 3.0.10
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 *  Converter for inferring and setting parameter 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 takes an SBML document and attempts to infer units for
022 * any {@link Parameter} objects whose units are undeclared.  It then sets the
023 * 'units' attribute of those parameters to the units inferred (if necessary,
024 * creating new {@link UnitDefinition} objects on the model in the process).
025 <p>
026 * <h2>Configuration and use of {@link SBMLInferUnitsConverter}</h2>
027 <p>
028 * {@link SBMLInferUnitsConverter} is enabled by creating a {@link ConversionProperties}
029 * object with the option <code>'inferUnits'</code>, and passing this
030 * properties object to {@link SBMLDocument#convert(ConversionProperties)}.
031 * The converter offers no other options.
032 <p>
033 * <p>
034 * <h2>General information about the use of SBML converters</h2>
035 <p>
036 * The use of all the converters follows a similar approach.  First, one
037 * creates a {@link ConversionProperties} object and calls
038 * {@link ConversionProperties#addOption(ConversionOption)}
039 * on this object with one argument: a text string that identifies the desired
040 * converter.  (The text string is specific to each converter; consult the
041 * documentation for a given converter to find out how it should be enabled.)
042 <p>
043 * Next, for some converters, the caller can optionally set some
044 * converter-specific properties using additional calls to
045 * {@link ConversionProperties#addOption(ConversionOption)}.
046 * Many converters provide the ability to
047 * configure their behavior to some extent; this is realized through the use
048 * of properties that offer different options.  The default property values
049 * for each converter can be interrogated using the method
050 * {@link SBMLConverter#getDefaultProperties()} on the converter class in question .
051 <p>
052 * Finally, the caller should invoke the method
053 * {@link SBMLDocument#convert(ConversionProperties)}
054 * with the {@link ConversionProperties} object as an argument.
055 <p>
056 * <h3>Example of invoking an SBML converter</h3>
057 <p>
058 * The following code fragment illustrates an example using
059 * {@link SBMLReactionConverter}, which is invoked using the option string 
060 * <code>'replaceReactions':</code>
061 <p>
062<pre class='fragment'>
063{@link ConversionProperties} props = new {@link ConversionProperties}();
064if (props != null) {
065  props.addOption('replaceReactions');
066} else {
067  // Deal with error.
068}
069</pre>
070<p>
071 * In the case of {@link SBMLReactionConverter}, there are no options to affect
072 * its behavior, so the next step is simply to invoke the converter on
073 * an {@link SBMLDocument} object.  Continuing the example code:
074 <p>
075<pre class='fragment'>
076  // Assume that the variable 'document' has been set to an {@link SBMLDocument} object.
077  status = document.convert(config);
078  if (status != libsbml.LIBSBML_OPERATION_SUCCESS)
079  {
080    // Handle error somehow.
081    System.out.println('Error: conversion failed due to the following:');
082    document.printErrors();
083  }
084</pre>
085<p>
086 * Here is an example of using a converter that offers an option. The
087 * following code invokes {@link SBMLStripPackageConverter} to remove the
088 * SBML Level&nbsp;3 <em>Layout</em> package from a model.  It sets the name
089 * of the package to be removed by adding a value for the option named
090 * <code>'package'</code> defined by that converter:
091 <p>
092<pre class='fragment'>
093{@link ConversionProperties} config = new {@link ConversionProperties}();
094if (config != None) {
095  config.addOption('stripPackage');
096  config.addOption('package', 'layout');
097  status = document.convert(config);
098  if (status != LIBSBML_OPERATION_SUCCESS) {
099    // Handle error somehow.
100    System.out.println('Error: unable to strip the {@link Layout} package');
101    document.printErrors();
102  }
103} else {
104  // Handle error somehow.
105  System.out.println('Error: unable to create {@link ConversionProperties} object');
106}
107</pre>
108<p>
109 * <h3>Available SBML converters in libSBML</h3>
110 <p>
111 * LibSBML provides a number of built-in converters; by convention, their
112 * names end in <em>Converter</em>. The following are the built-in converters
113 * provided by libSBML 5.15.2
114:
115 <p>
116 * <p>
117 * <ul>
118 * <li> ArraysFlatteningConverter
119 * <li> {@link CobraToFbcConverter}
120 * <li> {@link CompFlatteningConverter}
121 * <li> {@link FbcToCobraConverter}
122 * <li> {@link FbcV1ToV2Converter}
123 * <li> {@link FbcV2ToV1Converter}
124 * <li> {@link SBMLFunctionDefinitionConverter}
125 * <li> {@link SBMLIdConverter}
126 * <li> {@link SBMLInferUnitsConverter}
127 * <li> {@link SBMLInitialAssignmentConverter}
128 * <li> {@link SBMLLevel1Version1Converter}
129 * <li> {@link SBMLLevelVersionConverter}
130 * <li> {@link SBMLLocalParameterConverter}
131 * <li> SBMLRateOfConverter
132 * <li> {@link SBMLReactionConverter}
133 * <li> {@link SBMLRuleConverter}
134 * <li> {@link SBMLStripPackageConverter}
135 * <li> {@link SBMLUnitsConverter}
136 *
137 * </ul>
138 */
139
140public class SBMLInferUnitsConverter extends SBMLConverter {
141   private long swigCPtr;
142
143   protected SBMLInferUnitsConverter(long cPtr, boolean cMemoryOwn)
144   {
145     super(libsbmlJNI.SBMLInferUnitsConverter_SWIGUpcast(cPtr), cMemoryOwn);
146     swigCPtr = cPtr;
147   }
148
149   protected static long getCPtr(SBMLInferUnitsConverter obj)
150   {
151     return (obj == null) ? 0 : obj.swigCPtr;
152   }
153
154   protected static long getCPtrAndDisown (SBMLInferUnitsConverter obj)
155   {
156     long ptr = 0;
157
158     if (obj != null)
159     {
160       ptr             = obj.swigCPtr;
161       obj.swigCMemOwn = false;
162     }
163
164     return ptr;
165   }
166
167  protected void finalize() {
168    delete();
169  }
170
171  public synchronized void delete() {
172    if (swigCPtr != 0) {
173      if (swigCMemOwn) {
174        swigCMemOwn = false;
175        libsbmlJNI.delete_SBMLInferUnitsConverter(swigCPtr);
176      }
177      swigCPtr = 0;
178    }
179    super.delete();
180  }
181
182  
183/** * @internal */ public
184 static void init() {
185    libsbmlJNI.SBMLInferUnitsConverter_init();
186  }
187
188  
189/**
190   * Creates a new {@link SBMLInferUnitsConverter} object.
191   */ public
192 SBMLInferUnitsConverter() {
193    this(libsbmlJNI.new_SBMLInferUnitsConverter__SWIG_0(), true);
194  }
195
196  
197/**
198   * Copy constructor; creates a copy of an {@link SBMLInferUnitsConverter}
199   * object.
200   <p>
201   * @param obj the {@link SBMLInferUnitsConverter} object to copy.
202   */ public
203 SBMLInferUnitsConverter(SBMLInferUnitsConverter obj) {
204    this(libsbmlJNI.new_SBMLInferUnitsConverter__SWIG_1(SBMLInferUnitsConverter.getCPtr(obj), obj), true);
205  }
206
207  
208/**
209   * Creates and returns a deep copy of this {@link SBMLInferUnitsConverter}
210   * object.
211   <p>
212   * @return a (deep) copy of this converter.
213   */ public
214 SBMLConverter cloneObject() {
215    long cPtr = libsbmlJNI.SBMLInferUnitsConverter_cloneObject(swigCPtr, this);
216    return (cPtr == 0) ? null : new SBMLInferUnitsConverter(cPtr, true);
217  }
218
219  
220/**
221   * Returns <code>true</code> if this converter object's properties match the given
222   * properties.
223   <p>
224   * A typical use of this method involves creating a {@link ConversionProperties}
225   * object, setting the options desired, and then calling this method on
226   * an {@link SBMLInferUnitsConverter} object to find out if the object's
227   * property values match the given ones.  This method is also used by
228   * {@link SBMLConverterRegistry#getConverterFor(ConversionProperties)}
229   * to search across all registered converters for one matching particular
230   * properties.
231   <p>
232   * @param props the properties to match.
233   <p>
234   * @return <code>true</code> if this converter's properties match, <code>false</code>
235   * otherwise.
236   */ public
237 boolean matchesProperties(ConversionProperties props) {
238    return libsbmlJNI.SBMLInferUnitsConverter_matchesProperties(swigCPtr, this, ConversionProperties.getCPtr(props), props);
239  }
240
241  
242/**
243   * Perform the conversion.
244   <p>
245   * This method causes the converter to do the actual conversion work,
246   * that is, to convert the {@link SBMLDocument} object set by
247   * {@link SBMLConverter#setDocument(SBMLDocument)} and
248   * with the configuration options set by
249   * {@link SBMLConverter#setProperties(ConversionProperties)}.
250   <p>
251   * <p>
252 * @return integer value indicating success/failure of the
253 * function.   The possible values
254 * returned by this function are:
255   * <ul>
256   * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS}
257   * <li> {@link libsbmlConstants#LIBSBML_OPERATION_FAILED LIBSBML_OPERATION_FAILED}
258   * <li> {@link libsbmlConstants#LIBSBML_INVALID_OBJECT LIBSBML_INVALID_OBJECT}
259   * <li> {@link libsbmlConstants#LIBSBML_CONV_INVALID_SRC_DOCUMENT LIBSBML_CONV_INVALID_SRC_DOCUMENT}
260   * </ul>
261   */ public
262 int convert() {
263    return libsbmlJNI.SBMLInferUnitsConverter_convert(swigCPtr, this);
264  }
265
266  
267/**
268   * Returns the default properties of this converter.
269   <p>
270   * A given converter exposes one or more properties that can be adjusted
271   * in order to influence the behavior of the converter.  This method
272   * returns the <em>default</em> property settings for this converter.  It is
273   * meant to be called in order to discover all the settings for the
274   * converter object.
275   <p>
276   * @return the {@link ConversionProperties} object describing the default properties
277   * for this converter.
278   */ public
279 ConversionProperties getDefaultProperties() {
280    return new ConversionProperties(libsbmlJNI.SBMLInferUnitsConverter_getDefaultProperties(swigCPtr, this), true);
281  }
282
283}