1 //------------------------------------------------------------------------------ 2 // <auto-generated /> 3 // 4 // This file was automatically generated by SWIG (http://www.swig.org). 5 // Version 4.0.2 6 // 7 // Do not make changes to this file unless you know what you are doing--modify 8 // the SWIG interface file instead. 9 //------------------------------------------------------------------------------ 10 11 namespace libsbml { 12 13 using System; 14 using System.Runtime.InteropServices; 15 16 /** 17 * @sbmlpackage{core} 18 * 19 @htmlinclude pkg-marker-core.html Converter to expand user-defined functions in-line. 20 * 21 * @htmlinclude libsbml-facility-only-warning.html 22 * 23 * This converter manipulates user-defined functions in an SBML file. When 24 * invoked on a model, it performs the following operations: 25 * 26 * @li Reads the list of user-defined functions in the model (i.e., the list 27 * of FunctionDefinition objects); 28 * @li Looks for invocations of the function in mathematical expressions 29 * throughout the model; and 30 * @li For each invocation found, replaces the invocation with a in-line copy 31 * of the function's body, similar to how macro expansions might be performed 32 * in scripting and programming languages. 33 * 34 * For example, suppose the model contains a function definition 35 * representing the function <code>f(x, y) = x * y</code>. Further 36 * suppose this functions invoked somewhere else in the model, in 37 * a mathematical formula, as <code>f(s, p)</code>. The outcome of running 38 * SBMLFunctionDefinitionConverter on the model will be to replace 39 * the call to <code>f</code> with the expression <code>s * p</code>. 40 * 41 * @section usage Configuration and use of SBMLFunctionDefinitionConverter 42 * 43 * SBMLFunctionDefinitionConverter is enabled by creating a 44 * ConversionProperties object with the option 45 * @c 'expandFunctionDefinitions', and passing this properties object to 46 * SBMLDocument::convert(@if java ConversionProperties@endif). 47 * The converter accepts one option: 48 * 49 * @li @c 'skipIds': if set, it should be a string containing a 50 * comma-separated list of identifiers (SBML 'id' values) that are to be 51 * skipped during function conversion. Functions whose identifiers are 52 * found in this list will not be converted. 53 * 54 * 55 * @section using-converters General information about the use of SBML converters 56 * 57 * The use of all the converters follows a similar approach. First, one 58 * creates a ConversionProperties object and calls 59 * ConversionProperties::addOption(@if java ConversionOption@endif) 60 * on this object with one argument: a text string that identifies the desired 61 * converter. (The text string is specific to each converter; consult the 62 * documentation for a given converter to find out how it should be enabled.) 63 * 64 * Next, for some converters, the caller can optionally set some 65 * converter-specific properties using additional calls to 66 * ConversionProperties::addOption(@if java ConversionOption@endif). 67 * Many converters provide the ability to 68 * configure their behavior to some extent; this is realized through the use 69 * of properties that offer different options. The default property values 70 * for each converter can be interrogated using the method 71 * SBMLConverter::getDefaultProperties() on the converter class in question . 72 * 73 * Finally, the caller should invoke the method 74 * SBMLDocument::convert(@if java ConversionProperties@endif) 75 * with the ConversionProperties object as an argument. 76 * 77 * @subsection converter-example Example of invoking an SBML converter 78 * 79 * The following code fragment illustrates an example using 80 * SBMLReactionConverter, which is invoked using the option string 81 * @c 'replaceReactions': 82 * 83 * @if cpp 84 * @code{.cpp} 85 ConversionProperties props; 86 props.addOption('replaceReactions'); 87 @endcode 88 @endif 89 @if python 90 @code{.py} 91 config = ConversionProperties() 92 if config != None: 93 config.addOption('replaceReactions') 94 @endcode 95 @endif 96 @if java 97 @code{.java} 98 ConversionProperties props = new ConversionProperties(); 99 if (props != null) { 100 props.addOption('replaceReactions'); 101 } else { 102 // Deal with error. 103 } 104 @endcode 105 @endif 106 * 107 * In the case of SBMLReactionConverter, there are no options to affect 108 * its behavior, so the next step is simply to invoke the converter on 109 * an SBMLDocument object. Continuing the example code: 110 * 111 * @if cpp 112 * @code{.cpp} 113 // Assume that the variable 'document' has been set to an SBMLDocument object. 114 int status = document->convert(props); 115 if (status != LIBSBML_OPERATION_SUCCESS) 116 { 117 cerr << 'Unable to perform conversion due to the following:' << endl; 118 document->printErrors(cerr); 119 } 120 @endcode 121 @endif 122 @if python 123 @code{.py} 124 # Assume that the variable 'document' has been set to an SBMLDocument object. 125 status = document.convert(config) 126 if status != LIBSBML_OPERATION_SUCCESS: 127 # Handle error somehow. 128 print('Error: conversion failed due to the following:') 129 document.printErrors() 130 @endcode 131 @endif 132 @if java 133 @code{.java} 134 // Assume that the variable 'document' has been set to an SBMLDocument object. 135 status = document.convert(config); 136 if (status != libsbml.LIBSBML_OPERATION_SUCCESS) 137 { 138 // Handle error somehow. 139 System.out.println('Error: conversion failed due to the following:'); 140 document.printErrors(); 141 } 142 @endcode 143 @endif 144 * 145 * Here is an example of using a converter that offers an option. The 146 * following code invokes SBMLStripPackageConverter to remove the 147 * SBML Level 3 @em %Layout package from a model. It sets the name 148 * of the package to be removed by adding a value for the option named 149 * @c 'package' defined by that converter: 150 * 151 * @if cpp 152 * @code{.cpp} 153 ConversionProperties props; 154 props.addOption('stripPackage'); 155 props.addOption('package', 'layout'); 156 157 int status = document->convert(props); 158 if (status != LIBSBML_OPERATION_SUCCESS) 159 { 160 cerr << 'Unable to strip the Layout package from the model'; 161 cerr << 'Error returned: ' << status; 162 } 163 @endcode 164 @endif 165 @if python 166 @code{.py} 167 def strip_layout_example(document): 168 config = ConversionProperties() 169 if config != None: 170 config.addOption('stripPackage') 171 config.addOption('package', 'layout') 172 status = document.convert(config) 173 if status != LIBSBML_OPERATION_SUCCESS: 174 # Handle error somehow. 175 print('Error: unable to strip the Layout package.') 176 print('LibSBML returned error: ' + OperationReturnValue_toString(status).strip()) 177 else: 178 # Handle error somehow. 179 print('Error: unable to create ConversionProperties object') 180 @endcode 181 @endif 182 @if java 183 @code{.java} 184 ConversionProperties config = new ConversionProperties(); 185 if (config != None) { 186 config.addOption('stripPackage'); 187 config.addOption('package', 'layout'); 188 status = document.convert(config); 189 if (status != LIBSBML_OPERATION_SUCCESS) { 190 // Handle error somehow. 191 System.out.println('Error: unable to strip the Layout package'); 192 document.printErrors(); 193 } 194 } else { 195 // Handle error somehow. 196 System.out.println('Error: unable to create ConversionProperties object'); 197 } 198 @endcode 199 @endif 200 * 201 * @subsection available-converters Available SBML converters in libSBML 202 * 203 * LibSBML provides a number of built-in converters; by convention, their 204 * names end in @em Converter. The following are the built-in converters 205 * provided by libSBML @htmlinclude libsbml-version.html: 206 * 207 * @copydetails doc_list_of_libsbml_converters 208 * 209 * 210 */ 211 212 public class SBMLFunctionDefinitionConverter : SBMLConverter { 213 private HandleRef swigCPtr; 214 SBMLFunctionDefinitionConverter(IntPtr cPtr, bool cMemoryOwn)215 internal SBMLFunctionDefinitionConverter(IntPtr cPtr, bool cMemoryOwn) : base(libsbmlPINVOKE.SBMLFunctionDefinitionConverter_SWIGUpcast(cPtr), cMemoryOwn) 216 { 217 //super(libsbmlPINVOKE.SBMLFunctionDefinitionConverterUpcast(cPtr), cMemoryOwn); 218 swigCPtr = new HandleRef(this, cPtr); 219 } 220 getCPtr(SBMLFunctionDefinitionConverter obj)221 internal static HandleRef getCPtr(SBMLFunctionDefinitionConverter obj) 222 { 223 return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; 224 } 225 getCPtrAndDisown(SBMLFunctionDefinitionConverter obj)226 internal static HandleRef getCPtrAndDisown (SBMLFunctionDefinitionConverter obj) 227 { 228 HandleRef ptr = new HandleRef(null, IntPtr.Zero); 229 230 if (obj != null) 231 { 232 ptr = obj.swigCPtr; 233 obj.swigCMemOwn = false; 234 } 235 236 return ptr; 237 } 238 Dispose(bool disposing)239 protected override void Dispose(bool disposing) { 240 lock(this) { 241 if (swigCPtr.Handle != global::System.IntPtr.Zero) { 242 if (swigCMemOwn) { 243 swigCMemOwn = false; 244 libsbmlPINVOKE.delete_SBMLFunctionDefinitionConverter(swigCPtr); 245 } 246 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); 247 } 248 base.Dispose(disposing); 249 } 250 } 251 252 253 /** */ /* libsbml-internal */ public init()254 static void init() { 255 libsbmlPINVOKE.SBMLFunctionDefinitionConverter_init(); 256 } 257 258 259 /** 260 * Creates a new SBMLFunctionDefinitionConverter object. 261 */ public SBMLFunctionDefinitionConverter()262 SBMLFunctionDefinitionConverter() : this(libsbmlPINVOKE.new_SBMLFunctionDefinitionConverter__SWIG_0(), true) { 263 } 264 265 266 /** 267 * Copy constructor; creates a copy of an SBMLFunctionDefinitionConverter 268 * object. 269 * 270 * @param obj the SBMLFunctionDefinitionConverter object to copy. 271 */ public SBMLFunctionDefinitionConverter(SBMLFunctionDefinitionConverter obj)272 SBMLFunctionDefinitionConverter(SBMLFunctionDefinitionConverter obj) : this(libsbmlPINVOKE.new_SBMLFunctionDefinitionConverter__SWIG_1(SBMLFunctionDefinitionConverter.getCPtr(obj)), true) { 273 if (libsbmlPINVOKE.SWIGPendingException.Pending) throw libsbmlPINVOKE.SWIGPendingException.Retrieve(); 274 } 275 276 277 /** 278 * Creates and returns a deep copy of this SBMLFunctionDefinitionConverter 279 * object. 280 * 281 * @return a (deep) copy of this converter. 282 */ public new clone()283 SBMLConverter clone() { 284 global::System.IntPtr cPtr = libsbmlPINVOKE.SBMLFunctionDefinitionConverter_clone(swigCPtr); 285 SBMLFunctionDefinitionConverter ret = (cPtr == global::System.IntPtr.Zero) ? null : new SBMLFunctionDefinitionConverter(cPtr, true); 286 return ret; 287 } 288 289 290 /** 291 * Returns @c true if this converter object's properties match the given 292 * properties. 293 * 294 * A typical use of this method involves creating a ConversionProperties 295 * object, setting the options desired, and then calling this method on 296 * an SBMLFunctionDefinitionConverter object to find out if the object's 297 * property values match the given ones. This method is also used by 298 * SBMLConverterRegistry::getConverterFor(@if java ConversionProperties@endif) 299 * to search across all registered converters for one matching particular 300 * properties. 301 * 302 * @param props the properties to match. 303 * 304 * @return @c true if this converter's properties match, @c false 305 * otherwise. 306 */ public new matchesProperties(ConversionProperties props)307 bool matchesProperties(ConversionProperties props) { 308 bool ret = libsbmlPINVOKE.SBMLFunctionDefinitionConverter_matchesProperties(swigCPtr, ConversionProperties.getCPtr(props)); 309 if (libsbmlPINVOKE.SWIGPendingException.Pending) throw libsbmlPINVOKE.SWIGPendingException.Retrieve(); 310 return ret; 311 } 312 313 314 /** 315 * Perform the conversion. 316 * 317 * This method causes the converter to do the actual conversion work, 318 * that is, to convert the SBMLDocument object set by 319 * SBMLConverter::setDocument(@if java SBMLDocument@endif) and 320 * with the configuration options set by 321 * SBMLConverter::setProperties(@if java ConversionProperties@endif). 322 * 323 * 324 * @return integer value indicating success/failure of the 325 * function. @if clike The value is drawn from the 326 * enumeration #OperationReturnValues_t. @endif The possible values 327 * returned by this function are: 328 * @li @link libsbml#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS@endlink 329 * @li @link libsbml#LIBSBML_OPERATION_FAILED LIBSBML_OPERATION_FAILED@endlink 330 * @li @link libsbml#LIBSBML_INVALID_OBJECT LIBSBML_INVALID_OBJECT@endlink 331 * @li @link libsbml#LIBSBML_CONV_INVALID_SRC_DOCUMENT LIBSBML_CONV_INVALID_SRC_DOCUMENT@endlink 332 */ public new convert()333 int convert() { 334 int ret = libsbmlPINVOKE.SBMLFunctionDefinitionConverter_convert(swigCPtr); 335 return ret; 336 } 337 338 339 /** 340 * Returns the default properties of this converter. 341 * 342 * A given converter exposes one or more properties that can be adjusted 343 * in order to influence the behavior of the converter. This method 344 * returns the @em default property settings for this converter. It is 345 * meant to be called in order to discover all the settings for the 346 * converter object. 347 * 348 * @return the ConversionProperties object describing the default properties 349 * for this converter. 350 */ public new getDefaultProperties()351 ConversionProperties getDefaultProperties() { 352 ConversionProperties ret = new ConversionProperties(libsbmlPINVOKE.SBMLFunctionDefinitionConverter_getDefaultProperties(swigCPtr), true); 353 return ret; 354 } 355 356 } 357 358 } 359