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