001/* ---------------------------------------------------------------------------- 002 * This file was automatically generated by SWIG (http://www.swig.org). 003 * Version 3.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 * 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 argument: 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 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.16.0 137: 138 <p> 139 * <p> 140 * <ul> 141 * <li> ArraysFlatteningConverter 142 * <li> {@link CobraToFbcConverter} 143 * <li> {@link CompFlatteningConverter} 144 * <li> {@link FbcToCobraConverter} 145 * <li> {@link FbcV1ToV2Converter} 146 * <li> {@link FbcV2ToV1Converter} 147 * <li> {@link SBMLFunctionDefinitionConverter} 148 * <li> {@link SBMLIdConverter} 149 * <li> {@link SBMLInferUnitsConverter} 150 * <li> {@link SBMLInitialAssignmentConverter} 151 * <li> {@link SBMLLevel1Version1Converter} 152 * <li> {@link SBMLLevelVersionConverter} 153 * <li> {@link SBMLLocalParameterConverter} 154 * <li> SBMLRateOfConverter 155 * <li> {@link SBMLReactionConverter} 156 * <li> {@link SBMLRuleConverter} 157 * <li> {@link SBMLStripPackageConverter} 158 * <li> {@link SBMLUnitsConverter} 159 * 160 * </ul> 161 */ 162 163public class SBMLFunctionDefinitionConverter extends SBMLConverter { 164 private long swigCPtr; 165 166 protected SBMLFunctionDefinitionConverter(long cPtr, boolean cMemoryOwn) 167 { 168 super(libsbmlJNI.SBMLFunctionDefinitionConverter_SWIGUpcast(cPtr), cMemoryOwn); 169 swigCPtr = cPtr; 170 } 171 172 protected static long getCPtr(SBMLFunctionDefinitionConverter obj) 173 { 174 return (obj == null) ? 0 : obj.swigCPtr; 175 } 176 177 protected static long getCPtrAndDisown (SBMLFunctionDefinitionConverter obj) 178 { 179 long ptr = 0; 180 181 if (obj != null) 182 { 183 ptr = obj.swigCPtr; 184 obj.swigCMemOwn = false; 185 } 186 187 return ptr; 188 } 189 190 protected void finalize() { 191 delete(); 192 } 193 194 public synchronized void delete() { 195 if (swigCPtr != 0) { 196 if (swigCMemOwn) { 197 swigCMemOwn = false; 198 libsbmlJNI.delete_SBMLFunctionDefinitionConverter(swigCPtr); 199 } 200 swigCPtr = 0; 201 } 202 super.delete(); 203 } 204 205 206/** * @internal */ public 207 static void init() { 208 libsbmlJNI.SBMLFunctionDefinitionConverter_init(); 209 } 210 211 212/** 213 * Creates a new {@link SBMLFunctionDefinitionConverter} object. 214 */ public 215 SBMLFunctionDefinitionConverter() { 216 this(libsbmlJNI.new_SBMLFunctionDefinitionConverter__SWIG_0(), true); 217 } 218 219 220/** 221 * Copy constructor; creates a copy of an {@link SBMLFunctionDefinitionConverter} 222 * object. 223 <p> 224 * @param obj the {@link SBMLFunctionDefinitionConverter} object to copy. 225 */ public 226 SBMLFunctionDefinitionConverter(SBMLFunctionDefinitionConverter obj) { 227 this(libsbmlJNI.new_SBMLFunctionDefinitionConverter__SWIG_1(SBMLFunctionDefinitionConverter.getCPtr(obj), obj), true); 228 } 229 230 231/** 232 * Creates and returns a deep copy of this {@link SBMLFunctionDefinitionConverter} 233 * object. 234 <p> 235 * @return a (deep) copy of this converter. 236 */ public 237 SBMLConverter cloneObject() { 238 long cPtr = libsbmlJNI.SBMLFunctionDefinitionConverter_cloneObject(swigCPtr, this); 239 return (cPtr == 0) ? null : new SBMLFunctionDefinitionConverter(cPtr, true); 240 } 241 242 243/** 244 * Returns <code>true</code> if this converter object's properties match the given 245 * properties. 246 <p> 247 * A typical use of this method involves creating a {@link ConversionProperties} 248 * object, setting the options desired, and then calling this method on 249 * an {@link SBMLFunctionDefinitionConverter} object to find out if the object's 250 * property values match the given ones. This method is also used by 251 * {@link SBMLConverterRegistry#getConverterFor(ConversionProperties)} 252 * to search across all registered converters for one matching particular 253 * properties. 254 <p> 255 * @param props the properties to match. 256 <p> 257 * @return <code>true</code> if this converter's properties match, <code>false</code> 258 * otherwise. 259 */ public 260 boolean matchesProperties(ConversionProperties props) { 261 return libsbmlJNI.SBMLFunctionDefinitionConverter_matchesProperties(swigCPtr, this, ConversionProperties.getCPtr(props), props); 262 } 263 264 265/** 266 * Perform the conversion. 267 <p> 268 * This method causes the converter to do the actual conversion work, 269 * that is, to convert the {@link SBMLDocument} object set by 270 * {@link SBMLConverter#setDocument(SBMLDocument)} and 271 * with the configuration options set by 272 * {@link SBMLConverter#setProperties(ConversionProperties)}. 273 <p> 274 * <p> 275 * @return integer value indicating success/failure of the 276 * function. The possible values 277 * returned by this function are: 278 * <ul> 279 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 280 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_FAILED LIBSBML_OPERATION_FAILED} 281 * <li> {@link libsbmlConstants#LIBSBML_INVALID_OBJECT LIBSBML_INVALID_OBJECT} 282 * <li> {@link libsbmlConstants#LIBSBML_CONV_INVALID_SRC_DOCUMENT LIBSBML_CONV_INVALID_SRC_DOCUMENT} 283 * </ul> 284 */ public 285 int convert() { 286 return libsbmlJNI.SBMLFunctionDefinitionConverter_convert(swigCPtr, this); 287 } 288 289 290/** 291 * Returns the default properties of this converter. 292 <p> 293 * A given converter exposes one or more properties that can be adjusted 294 * in order to influence the behavior of the converter. This method 295 * returns the <em>default</em> property settings for this converter. It is 296 * meant to be called in order to discover all the settings for the 297 * converter object. 298 <p> 299 * @return the {@link ConversionProperties} object describing the default properties 300 * for this converter. 301 */ public 302 ConversionProperties getDefaultProperties() { 303 return new ConversionProperties(libsbmlJNI.SBMLFunctionDefinitionConverter_getDefaultProperties(swigCPtr, this), true); 304 } 305 306}