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 that removes SBML <em>initial assignments</em>. 20 * 21 * @htmlinclude libsbml-facility-only-warning.html 22 * 23 * This is an SBML converter for replacing InitialAssignment objects, when 24 * possible, by setting the initial value attributes on the model objects 25 * being assigned. In other words, for every object that is the target of an 26 * initial assignment in the model, the converter evaluates the mathematical 27 * expression of the assignment to get a @em numerical value, and then sets 28 * the corresponding attribute of the object to the value. The effects for 29 * different kinds of SBML components are as follows: 30 * 31 * <center> 32 * <table border='0' class='text-table width80 normal-font alt-row-colors'> 33 * <tr style='background: lightgray; font-size: 14px;'> 34 * <th align='left' width='200'>Component</th> 35 * <th align='left'>Effect</th> 36 * </tr> 37 * <tr> 38 * <td>Compartment</td> 39 * <td>Sets the value of the <code>size</code> attribute.</td> 40 * </tr> 41 * <tr> 42 * <td>Species</td> 43 * <td>Sets the value of either the <code>initialAmount</code> 44 * or the <code>initialConcentration</code> attributes, depending 45 * on the value of the Species object's 46 * <code>hasOnlySubstanceUnits</code> attribute.</td> 47 * </tr> 48 * <tr> 49 * <td>Parameter</td> 50 * <td>Sets the value of the <code>value</code> attribute.</td> 51 * </tr> 52 * <tr> 53 * <td>SpeciesReference</td> 54 * <td>Sets the value of the <code>stoichiometry</code> attribute 55 * in the Reaction object where the SpeciesReference object appears.</td> 56 * </tr> 57 * </table> 58 * </center> 59 * 60 * @section SBMLInitialAssignmentConverter-usage Configuration and use of SBMLInitialAssignmentConverter 61 * 62 * SBMLInitialAssignmentConverter is enabled by creating a 63 * ConversionProperties object with the option @c 'expandInitialAssignments', 64 * and passing this properties object to SBMLDocument::convert(@if java 65 * ConversionProperties@endif). The converter offers no other options. 66 * 67 * 68 * @section using-converters General information about the use of SBML converters 69 * 70 * The use of all the converters follows a similar approach. First, one 71 * creates a ConversionProperties object and calls 72 * ConversionProperties::addOption(@if java ConversionOption@endif) 73 * on this object with one argument: a text string that identifies the desired 74 * converter. (The text string is specific to each converter; consult the 75 * documentation for a given converter to find out how it should be enabled.) 76 * 77 * Next, for some converters, the caller can optionally set some 78 * converter-specific properties using additional calls to 79 * ConversionProperties::addOption(@if java ConversionOption@endif). 80 * Many converters provide the ability to 81 * configure their behavior to some extent; this is realized through the use 82 * of properties that offer different options. The default property values 83 * for each converter can be interrogated using the method 84 * SBMLConverter::getDefaultProperties() on the converter class in question . 85 * 86 * Finally, the caller should invoke the method 87 * SBMLDocument::convert(@if java ConversionProperties@endif) 88 * with the ConversionProperties object as an argument. 89 * 90 * @subsection converter-example Example of invoking an SBML converter 91 * 92 * The following code fragment illustrates an example using 93 * SBMLReactionConverter, which is invoked using the option string 94 * @c 'replaceReactions': 95 * 96 * @if cpp 97 * @code{.cpp} 98 ConversionProperties props; 99 props.addOption('replaceReactions'); 100 @endcode 101 @endif 102 @if python 103 @code{.py} 104 config = ConversionProperties() 105 if config != None: 106 config.addOption('replaceReactions') 107 @endcode 108 @endif 109 @if java 110 @code{.java} 111 ConversionProperties props = new ConversionProperties(); 112 if (props != null) { 113 props.addOption('replaceReactions'); 114 } else { 115 // Deal with error. 116 } 117 @endcode 118 @endif 119 * 120 * In the case of SBMLReactionConverter, there are no options to affect 121 * its behavior, so the next step is simply to invoke the converter on 122 * an SBMLDocument object. Continuing the example code: 123 * 124 * @if cpp 125 * @code{.cpp} 126 // Assume that the variable 'document' has been set to an SBMLDocument object. 127 int status = document->convert(props); 128 if (status != LIBSBML_OPERATION_SUCCESS) 129 { 130 cerr << 'Unable to perform conversion due to the following:' << endl; 131 document->printErrors(cerr); 132 } 133 @endcode 134 @endif 135 @if python 136 @code{.py} 137 # Assume that the variable 'document' has been set to an SBMLDocument object. 138 status = document.convert(config) 139 if status != LIBSBML_OPERATION_SUCCESS: 140 # Handle error somehow. 141 print('Error: conversion failed due to the following:') 142 document.printErrors() 143 @endcode 144 @endif 145 @if java 146 @code{.java} 147 // Assume that the variable 'document' has been set to an SBMLDocument object. 148 status = document.convert(config); 149 if (status != libsbml.LIBSBML_OPERATION_SUCCESS) 150 { 151 // Handle error somehow. 152 System.out.println('Error: conversion failed due to the following:'); 153 document.printErrors(); 154 } 155 @endcode 156 @endif 157 * 158 * Here is an example of using a converter that offers an option. The 159 * following code invokes SBMLStripPackageConverter to remove the 160 * SBML Level 3 @em %Layout package from a model. It sets the name 161 * of the package to be removed by adding a value for the option named 162 * @c 'package' defined by that converter: 163 * 164 * @if cpp 165 * @code{.cpp} 166 ConversionProperties props; 167 props.addOption('stripPackage'); 168 props.addOption('package', 'layout'); 169 170 int status = document->convert(props); 171 if (status != LIBSBML_OPERATION_SUCCESS) 172 { 173 cerr << 'Unable to strip the Layout package from the model'; 174 cerr << 'Error returned: ' << status; 175 } 176 @endcode 177 @endif 178 @if python 179 @code{.py} 180 def strip_layout_example(document): 181 config = ConversionProperties() 182 if config != None: 183 config.addOption('stripPackage') 184 config.addOption('package', 'layout') 185 status = document.convert(config) 186 if status != LIBSBML_OPERATION_SUCCESS: 187 # Handle error somehow. 188 print('Error: unable to strip the Layout package.') 189 print('LibSBML returned error: ' + OperationReturnValue_toString(status).strip()) 190 else: 191 # Handle error somehow. 192 print('Error: unable to create ConversionProperties object') 193 @endcode 194 @endif 195 @if java 196 @code{.java} 197 ConversionProperties config = new ConversionProperties(); 198 if (config != None) { 199 config.addOption('stripPackage'); 200 config.addOption('package', 'layout'); 201 status = document.convert(config); 202 if (status != LIBSBML_OPERATION_SUCCESS) { 203 // Handle error somehow. 204 System.out.println('Error: unable to strip the Layout package'); 205 document.printErrors(); 206 } 207 } else { 208 // Handle error somehow. 209 System.out.println('Error: unable to create ConversionProperties object'); 210 } 211 @endcode 212 @endif 213 * 214 * @subsection available-converters Available SBML converters in libSBML 215 * 216 * LibSBML provides a number of built-in converters; by convention, their 217 * names end in @em Converter. The following are the built-in converters 218 * provided by libSBML @htmlinclude libsbml-version.html: 219 * 220 * @copydetails doc_list_of_libsbml_converters 221 * 222 * 223 */ 224 225 public class SBMLInitialAssignmentConverter : SBMLConverter { 226 private HandleRef swigCPtr; 227 SBMLInitialAssignmentConverter(IntPtr cPtr, bool cMemoryOwn)228 internal SBMLInitialAssignmentConverter(IntPtr cPtr, bool cMemoryOwn) : base(libsbmlPINVOKE.SBMLInitialAssignmentConverter_SWIGUpcast(cPtr), cMemoryOwn) 229 { 230 //super(libsbmlPINVOKE.SBMLInitialAssignmentConverterUpcast(cPtr), cMemoryOwn); 231 swigCPtr = new HandleRef(this, cPtr); 232 } 233 getCPtr(SBMLInitialAssignmentConverter obj)234 internal static HandleRef getCPtr(SBMLInitialAssignmentConverter obj) 235 { 236 return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; 237 } 238 getCPtrAndDisown(SBMLInitialAssignmentConverter obj)239 internal static HandleRef getCPtrAndDisown (SBMLInitialAssignmentConverter obj) 240 { 241 HandleRef ptr = new HandleRef(null, IntPtr.Zero); 242 243 if (obj != null) 244 { 245 ptr = obj.swigCPtr; 246 obj.swigCMemOwn = false; 247 } 248 249 return ptr; 250 } 251 Dispose(bool disposing)252 protected override void Dispose(bool disposing) { 253 lock(this) { 254 if (swigCPtr.Handle != global::System.IntPtr.Zero) { 255 if (swigCMemOwn) { 256 swigCMemOwn = false; 257 libsbmlPINVOKE.delete_SBMLInitialAssignmentConverter(swigCPtr); 258 } 259 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); 260 } 261 base.Dispose(disposing); 262 } 263 } 264 265 266 /** */ /* libsbml-internal */ public init()267 static void init() { 268 libsbmlPINVOKE.SBMLInitialAssignmentConverter_init(); 269 } 270 271 272 /** 273 * Creates a new SBMLInitialAssignmentConverter object. 274 */ public SBMLInitialAssignmentConverter()275 SBMLInitialAssignmentConverter() : this(libsbmlPINVOKE.new_SBMLInitialAssignmentConverter__SWIG_0(), true) { 276 } 277 278 279 /** 280 * Copy constructor; creates a copy of an SBMLInitialAssignmentConverter 281 * object. 282 * 283 * @param obj the SBMLInitialAssignmentConverter object to copy. 284 */ public SBMLInitialAssignmentConverter(SBMLInitialAssignmentConverter obj)285 SBMLInitialAssignmentConverter(SBMLInitialAssignmentConverter obj) : this(libsbmlPINVOKE.new_SBMLInitialAssignmentConverter__SWIG_1(SBMLInitialAssignmentConverter.getCPtr(obj)), true) { 286 if (libsbmlPINVOKE.SWIGPendingException.Pending) throw libsbmlPINVOKE.SWIGPendingException.Retrieve(); 287 } 288 289 290 /** 291 * Creates and returns a deep copy of this SBMLInitialAssignmentConverter 292 * object. 293 * 294 * @return a (deep) copy of this converter. 295 */ public new clone()296 SBMLConverter clone() { 297 global::System.IntPtr cPtr = libsbmlPINVOKE.SBMLInitialAssignmentConverter_clone(swigCPtr); 298 SBMLInitialAssignmentConverter ret = (cPtr == global::System.IntPtr.Zero) ? null : new SBMLInitialAssignmentConverter(cPtr, true); 299 return ret; 300 } 301 302 303 /** 304 * Returns @c true if this converter object's properties match the given 305 * properties. 306 * 307 * A typical use of this method involves creating a ConversionProperties 308 * object, setting the options desired, and then calling this method on 309 * an SBMLInitialAssignmentConverter object to find out if the object's 310 * property values match the given ones. This method is also used by 311 * SBMLConverterRegistry::getConverterFor(@if java ConversionProperties@endif) 312 * to search across all registered converters for one matching particular 313 * properties. 314 * 315 * @param props the properties to match. 316 * 317 * @return @c true if this converter's properties match, @c false 318 * otherwise. 319 */ public new matchesProperties(ConversionProperties props)320 bool matchesProperties(ConversionProperties props) { 321 bool ret = libsbmlPINVOKE.SBMLInitialAssignmentConverter_matchesProperties(swigCPtr, ConversionProperties.getCPtr(props)); 322 if (libsbmlPINVOKE.SWIGPendingException.Pending) throw libsbmlPINVOKE.SWIGPendingException.Retrieve(); 323 return ret; 324 } 325 326 327 /** 328 * Perform the conversion. 329 * 330 * This method causes the converter to do the actual conversion work, 331 * that is, to convert the SBMLDocument object set by 332 * SBMLConverter::setDocument(@if java SBMLDocument@endif) and 333 * with the configuration options set by 334 * SBMLConverter::setProperties(@if java ConversionProperties@endif). 335 * 336 * 337 * @return integer value indicating success/failure of the 338 * function. @if clike The value is drawn from the 339 * enumeration #OperationReturnValues_t. @endif The possible values 340 * returned by this function are: 341 * @li @link libsbml#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS@endlink 342 * @li @link libsbml#LIBSBML_OPERATION_FAILED LIBSBML_OPERATION_FAILED@endlink 343 * @li @link libsbml#LIBSBML_INVALID_OBJECT LIBSBML_INVALID_OBJECT@endlink 344 */ public new convert()345 int convert() { 346 int ret = libsbmlPINVOKE.SBMLInitialAssignmentConverter_convert(swigCPtr); 347 return ret; 348 } 349 350 351 /** 352 * Returns the default properties of this converter. 353 * 354 * A given converter exposes one or more properties that can be adjusted 355 * in order to influence the behavior of the converter. This method 356 * returns the @em default property settings for this converter. It is 357 * meant to be called in order to discover all the settings for the 358 * converter object. 359 * 360 * @return the ConversionProperties object describing the default properties 361 * for this converter. 362 */ public new getDefaultProperties()363 ConversionProperties getDefaultProperties() { 364 ConversionProperties ret = new ConversionProperties(libsbmlPINVOKE.SBMLInitialAssignmentConverter_getDefaultProperties(swigCPtr), true); 365 return ret; 366 } 367 368 } 369 370 } 371