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