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 Whole-document SBML Level/Version converter. 20 * 21 * @htmlinclude libsbml-facility-only-warning.html 22 * 23 * This SBML converter takes an SBML document having one SBML Level+Version 24 * combination, and attempts to convert it to an SBML document having a 25 * different Level+Version combination. This converter 26 * (SBMLLevel1Version1Converter) converts models to SBML Level 1 27 * Version 1, to the extent possible by the limited features of 28 * that Level/Version combination of SBML. 29 * 30 * @section SBMLLevel1Version1Converter-usage Configuration and use of SBMLLevel1Version1Converter 31 * 32 * SBMLLevel1Version1Converter is enabled by creating a ConversionProperties 33 * object with the option @c 'convertToL1V1', and passing this 34 * properties object to SBMLDocument::convert(@if java 35 * ConversionProperties@endif). The target SBML Level and Version 36 * combination are determined by the value of the SBML namespace set on the 37 * ConversionProperties object (using 38 * ConversionProperties::setTargetNamespaces(SBMLNamespaces targetNS)). 39 * 40 * In addition, this converter offers the following options: 41 * 42 * @li @c 'changePow': Mathematical expressions for exponentiation of 43 * the form <code>pow(s1, 2)</code> will be converted to the expression 44 * <code>s1^2</code>. 45 * 46 * @li @c 'inlineCompartmentSizes': Back in the days of SBML Level 1 47 * Version 1, many software tools assumed that the 'kinetic laws' of 48 * SBML were written in terms of units of 49 * <em>concentration</em>/<em>time</em>. These tools would not expect (and 50 * thus not handle) rate expressions such as 51 * <code>CompartmentOfS1 * k * S1</code>. 52 * When the option @c 'inlineCompartmentSizes' is enabled, libSBML will 53 * replace the references to compartments (such as @c 'CompartmentOfS1' in 54 * this example) with their initial sizes. This is not strictly correct in 55 * all cases; in particular, if the compartment volume varies during 56 * simulation, this conversion will not reflect the expected behavior. 57 * However, many models do not have time-varying compartment sizes, so this 58 * option makes it easy to get modern SBML rate expressions into a form that 59 * old software tools may better understand. 60 * 61 * 62 * @section using-converters General information about the use of SBML converters 63 * 64 * The use of all the converters follows a similar approach. First, one 65 * creates a ConversionProperties object and calls 66 * ConversionProperties::addOption(@if java ConversionOption@endif) 67 * on this object with one argument: a text string that identifies the desired 68 * converter. (The text string is specific to each converter; consult the 69 * documentation for a given converter to find out how it should be enabled.) 70 * 71 * Next, for some converters, the caller can optionally set some 72 * converter-specific properties using additional calls to 73 * ConversionProperties::addOption(@if java ConversionOption@endif). 74 * Many converters provide the ability to 75 * configure their behavior to some extent; this is realized through the use 76 * of properties that offer different options. The default property values 77 * for each converter can be interrogated using the method 78 * SBMLConverter::getDefaultProperties() on the converter class in question . 79 * 80 * Finally, the caller should invoke the method 81 * SBMLDocument::convert(@if java ConversionProperties@endif) 82 * with the ConversionProperties object as an argument. 83 * 84 * @subsection converter-example Example of invoking an SBML converter 85 * 86 * The following code fragment illustrates an example using 87 * SBMLReactionConverter, which is invoked using the option string 88 * @c 'replaceReactions': 89 * 90 * @if cpp 91 * @code{.cpp} 92 ConversionProperties props; 93 props.addOption('replaceReactions'); 94 @endcode 95 @endif 96 @if python 97 @code{.py} 98 config = ConversionProperties() 99 if config != None: 100 config.addOption('replaceReactions') 101 @endcode 102 @endif 103 @if java 104 @code{.java} 105 ConversionProperties props = new ConversionProperties(); 106 if (props != null) { 107 props.addOption('replaceReactions'); 108 } else { 109 // Deal with error. 110 } 111 @endcode 112 @endif 113 * 114 * In the case of SBMLReactionConverter, there are no options to affect 115 * its behavior, so the next step is simply to invoke the converter on 116 * an SBMLDocument object. Continuing the example code: 117 * 118 * @if cpp 119 * @code{.cpp} 120 // Assume that the variable 'document' has been set to an SBMLDocument object. 121 int status = document->convert(props); 122 if (status != LIBSBML_OPERATION_SUCCESS) 123 { 124 cerr << 'Unable to perform conversion due to the following:' << endl; 125 document->printErrors(cerr); 126 } 127 @endcode 128 @endif 129 @if python 130 @code{.py} 131 # Assume that the variable 'document' has been set to an SBMLDocument object. 132 status = document.convert(config) 133 if status != LIBSBML_OPERATION_SUCCESS: 134 # Handle error somehow. 135 print('Error: conversion failed due to the following:') 136 document.printErrors() 137 @endcode 138 @endif 139 @if java 140 @code{.java} 141 // Assume that the variable 'document' has been set to an SBMLDocument object. 142 status = document.convert(config); 143 if (status != libsbml.LIBSBML_OPERATION_SUCCESS) 144 { 145 // Handle error somehow. 146 System.out.println('Error: conversion failed due to the following:'); 147 document.printErrors(); 148 } 149 @endcode 150 @endif 151 * 152 * Here is an example of using a converter that offers an option. The 153 * following code invokes SBMLStripPackageConverter to remove the 154 * SBML Level 3 @em %Layout package from a model. It sets the name 155 * of the package to be removed by adding a value for the option named 156 * @c 'package' defined by that converter: 157 * 158 * @if cpp 159 * @code{.cpp} 160 ConversionProperties props; 161 props.addOption('stripPackage'); 162 props.addOption('package', 'layout'); 163 164 int status = document->convert(props); 165 if (status != LIBSBML_OPERATION_SUCCESS) 166 { 167 cerr << 'Unable to strip the Layout package from the model'; 168 cerr << 'Error returned: ' << status; 169 } 170 @endcode 171 @endif 172 @if python 173 @code{.py} 174 def strip_layout_example(document): 175 config = ConversionProperties() 176 if config != None: 177 config.addOption('stripPackage') 178 config.addOption('package', 'layout') 179 status = document.convert(config) 180 if status != LIBSBML_OPERATION_SUCCESS: 181 # Handle error somehow. 182 print('Error: unable to strip the Layout package.') 183 print('LibSBML returned error: ' + OperationReturnValue_toString(status).strip()) 184 else: 185 # Handle error somehow. 186 print('Error: unable to create ConversionProperties object') 187 @endcode 188 @endif 189 @if java 190 @code{.java} 191 ConversionProperties config = new ConversionProperties(); 192 if (config != None) { 193 config.addOption('stripPackage'); 194 config.addOption('package', 'layout'); 195 status = document.convert(config); 196 if (status != LIBSBML_OPERATION_SUCCESS) { 197 // Handle error somehow. 198 System.out.println('Error: unable to strip the Layout package'); 199 document.printErrors(); 200 } 201 } else { 202 // Handle error somehow. 203 System.out.println('Error: unable to create ConversionProperties object'); 204 } 205 @endcode 206 @endif 207 * 208 * @subsection available-converters Available SBML converters in libSBML 209 * 210 * LibSBML provides a number of built-in converters; by convention, their 211 * names end in @em Converter. The following are the built-in converters 212 * provided by libSBML @htmlinclude libsbml-version.html: 213 * 214 * @copydetails doc_list_of_libsbml_converters 215 * 216 * 217 */ 218 219 public class SBMLLevel1Version1Converter : SBMLConverter { 220 private HandleRef swigCPtr; 221 SBMLLevel1Version1Converter(IntPtr cPtr, bool cMemoryOwn)222 internal SBMLLevel1Version1Converter(IntPtr cPtr, bool cMemoryOwn) : base(libsbmlPINVOKE.SBMLLevel1Version1Converter_SWIGUpcast(cPtr), cMemoryOwn) 223 { 224 //super(libsbmlPINVOKE.SBMLLevel1Version1ConverterUpcast(cPtr), cMemoryOwn); 225 swigCPtr = new HandleRef(this, cPtr); 226 } 227 getCPtr(SBMLLevel1Version1Converter obj)228 internal static HandleRef getCPtr(SBMLLevel1Version1Converter obj) 229 { 230 return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; 231 } 232 getCPtrAndDisown(SBMLLevel1Version1Converter obj)233 internal static HandleRef getCPtrAndDisown (SBMLLevel1Version1Converter obj) 234 { 235 HandleRef ptr = new HandleRef(null, IntPtr.Zero); 236 237 if (obj != null) 238 { 239 ptr = obj.swigCPtr; 240 obj.swigCMemOwn = false; 241 } 242 243 return ptr; 244 } 245 Dispose(bool disposing)246 protected override void Dispose(bool disposing) { 247 lock(this) { 248 if (swigCPtr.Handle != global::System.IntPtr.Zero) { 249 if (swigCMemOwn) { 250 swigCMemOwn = false; 251 libsbmlPINVOKE.delete_SBMLLevel1Version1Converter(swigCPtr); 252 } 253 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); 254 } 255 base.Dispose(disposing); 256 } 257 } 258 259 260 /** */ /* libsbml-internal */ public init()261 static void init() { 262 libsbmlPINVOKE.SBMLLevel1Version1Converter_init(); 263 } 264 265 266 /** 267 * Creates a new SBMLLevel1Version1Converter object. 268 */ public SBMLLevel1Version1Converter()269 SBMLLevel1Version1Converter() : this(libsbmlPINVOKE.new_SBMLLevel1Version1Converter__SWIG_0(), true) { 270 } 271 272 273 /** 274 * Copy constructor; creates a copy of an SBMLLevel1Version1Converter 275 * object. 276 * 277 * @param obj the SBMLLevel1Version1Converter object to copy. 278 */ public SBMLLevel1Version1Converter(SBMLLevel1Version1Converter obj)279 SBMLLevel1Version1Converter(SBMLLevel1Version1Converter obj) : this(libsbmlPINVOKE.new_SBMLLevel1Version1Converter__SWIG_1(SBMLLevel1Version1Converter.getCPtr(obj)), true) { 280 if (libsbmlPINVOKE.SWIGPendingException.Pending) throw libsbmlPINVOKE.SWIGPendingException.Retrieve(); 281 } 282 283 284 /** 285 * Creates and returns a deep copy of this SBMLLevel1Version1Converter 286 * object. 287 * 288 * @return a (deep) copy of this converter. 289 */ public new clone()290 SBMLConverter clone() { 291 global::System.IntPtr cPtr = libsbmlPINVOKE.SBMLLevel1Version1Converter_clone(swigCPtr); 292 SBMLLevel1Version1Converter ret = (cPtr == global::System.IntPtr.Zero) ? null : new SBMLLevel1Version1Converter(cPtr, true); 293 return ret; 294 } 295 296 297 /** 298 * Returns @c true if this converter object's properties match the given 299 * properties. 300 * 301 * A typical use of this method involves creating a ConversionProperties 302 * object, setting the options desired, and then calling this method on 303 * an SBMLLevel1Version1Converter object to find out if the object's 304 * property values match the given ones. This method is also used by 305 * SBMLConverterRegistry::getConverterFor(@if java ConversionProperties@endif) 306 * to search across all registered converters for one matching particular 307 * properties. 308 * 309 * @param props the properties to match. 310 * 311 * @return @c true if this converter's properties match, @c false 312 * otherwise. 313 */ public new matchesProperties(ConversionProperties props)314 bool matchesProperties(ConversionProperties props) { 315 bool ret = libsbmlPINVOKE.SBMLLevel1Version1Converter_matchesProperties(swigCPtr, ConversionProperties.getCPtr(props)); 316 if (libsbmlPINVOKE.SWIGPendingException.Pending) throw libsbmlPINVOKE.SWIGPendingException.Retrieve(); 317 return ret; 318 } 319 320 321 /** 322 * Perform the conversion. 323 * 324 * This method causes the converter to do the actual conversion work, 325 * that is, to convert the SBMLDocument object set by 326 * SBMLConverter::setDocument(@if java SBMLDocument@endif) and 327 * with the configuration options set by 328 * SBMLConverter::setProperties(@if java ConversionProperties@endif). 329 * 330 * 331 * @return integer value indicating success/failure of the 332 * function. @if clike The value is drawn from the 333 * enumeration #OperationReturnValues_t. @endif The possible values 334 * returned by this function are: 335 * @li @link libsbml#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS@endlink 336 * @li @link libsbml#LIBSBML_OPERATION_FAILED LIBSBML_OPERATION_FAILED@endlink 337 * @li @link libsbml#LIBSBML_CONV_INVALID_TARGET_NAMESPACE LIBSBML_CONV_INVALID_TARGET_NAMESPACE@endlink 338 * @li @link libsbml#LIBSBML_CONV_PKG_CONVERSION_NOT_AVAILABLE LIBSBML_CONV_PKG_CONVERSION_NOT_AVAILABLE@endlink 339 * @li @link libsbml#LIBSBML_CONV_INVALID_SRC_DOCUMENT LIBSBML_CONV_INVALID_SRC_DOCUMENT@endlink 340 */ public new convert()341 int convert() { 342 int ret = libsbmlPINVOKE.SBMLLevel1Version1Converter_convert(swigCPtr); 343 return ret; 344 } 345 346 347 /** 348 * Returns the default properties of this converter. 349 * 350 * A given converter exposes one or more properties that can be adjusted 351 * in order to influence the behavior of the converter. This method 352 * returns the @em default property settings for this converter. It is 353 * meant to be called in order to discover all the settings for the 354 * converter object. 355 * 356 * @return the ConversionProperties object describing the default properties 357 * for this converter. 358 */ public new getDefaultProperties()359 ConversionProperties getDefaultProperties() { 360 ConversionProperties ret = new ConversionProperties(libsbmlPINVOKE.SBMLLevel1Version1Converter_getDefaultProperties(swigCPtr), true); 361 return ret; 362 } 363 364 } 365 366 } 367