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