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. 26 * 27 * This class is also the basis for 28 * SBMLDocument::setLevelAndVersion(@if java long, long, boolean@endif). 29 * 30 * @section SBMLLevelVersionConverter-usage Configuration and use of SBMLLevelVersionConverter 31 * 32 * SBMLLevelVersionConverter is enabled by creating a ConversionProperties 33 * object with the option @c 'setLevelAndVersion', 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 'strict': If this option has the value @c true, then the validity 43 * of the SBML document will be strictly preserved. This means that SBML 44 * validation will be performed, and if the original model is not valid or 45 * semantics cannot be preserved in the converted model, then conversion will 46 * not be performed. Conversely, if this option is set to @c false, model 47 * conversion will always be performed; if any errors are detected related to 48 * altered semantics, the errors will be logged in the usual way (i.e., the 49 * error log on the SBMLDocument object). 50 * 51 * @li @c 'addDefaultUnits': By default, a conversion from SBML Level 2 52 * to Level 3 will explicitly add UnitDefinition objects and unit 53 * attributes on the Model object to define units that are implicitly defined 54 * in SBML Level 2. This is usually desirable because in SBML 55 * Level 3, there are no default units and a conversion from 56 * Level 2 that did @em not add unit definitions would actually result 57 * in a loss of information. However, some users or software tools may not 58 * need or want this, or worse, may be fooled into thinking that libSBML has 59 * somehow inferred the proper units for model quantities. (It has not; it 60 * merely adds generic predefined units.) This option lets callers control 61 * this behavior. 62 * 63 * 64 * @section using-converters General information about the use of SBML converters 65 * 66 * The use of all the converters follows a similar approach. First, one 67 * creates a ConversionProperties object and calls 68 * ConversionProperties::addOption(@if java ConversionOption@endif) 69 * on this object with one argument: a text string that identifies the desired 70 * converter. (The text string is specific to each converter; consult the 71 * documentation for a given converter to find out how it should be enabled.) 72 * 73 * Next, for some converters, the caller can optionally set some 74 * converter-specific properties using additional calls to 75 * ConversionProperties::addOption(@if java ConversionOption@endif). 76 * Many converters provide the ability to 77 * configure their behavior to some extent; this is realized through the use 78 * of properties that offer different options. The default property values 79 * for each converter can be interrogated using the method 80 * SBMLConverter::getDefaultProperties() on the converter class in question . 81 * 82 * Finally, the caller should invoke the method 83 * SBMLDocument::convert(@if java ConversionProperties@endif) 84 * with the ConversionProperties object as an argument. 85 * 86 * @subsection converter-example Example of invoking an SBML converter 87 * 88 * The following code fragment illustrates an example using 89 * SBMLReactionConverter, which is invoked using the option string 90 * @c 'replaceReactions': 91 * 92 * @if cpp 93 * @code{.cpp} 94 ConversionProperties props; 95 props.addOption('replaceReactions'); 96 @endcode 97 @endif 98 @if python 99 @code{.py} 100 config = ConversionProperties() 101 if config != None: 102 config.addOption('replaceReactions') 103 @endcode 104 @endif 105 @if java 106 @code{.java} 107 ConversionProperties props = new ConversionProperties(); 108 if (props != null) { 109 props.addOption('replaceReactions'); 110 } else { 111 // Deal with error. 112 } 113 @endcode 114 @endif 115 * 116 * In the case of SBMLReactionConverter, there are no options to affect 117 * its behavior, so the next step is simply to invoke the converter on 118 * an SBMLDocument object. Continuing the example code: 119 * 120 * @if cpp 121 * @code{.cpp} 122 // Assume that the variable 'document' has been set to an SBMLDocument object. 123 int status = document->convert(props); 124 if (status != LIBSBML_OPERATION_SUCCESS) 125 { 126 cerr << 'Unable to perform conversion due to the following:' << endl; 127 document->printErrors(cerr); 128 } 129 @endcode 130 @endif 131 @if python 132 @code{.py} 133 # Assume that the variable 'document' has been set to an SBMLDocument object. 134 status = document.convert(config) 135 if status != LIBSBML_OPERATION_SUCCESS: 136 # Handle error somehow. 137 print('Error: conversion failed due to the following:') 138 document.printErrors() 139 @endcode 140 @endif 141 @if java 142 @code{.java} 143 // Assume that the variable 'document' has been set to an SBMLDocument object. 144 status = document.convert(config); 145 if (status != libsbml.LIBSBML_OPERATION_SUCCESS) 146 { 147 // Handle error somehow. 148 System.out.println('Error: conversion failed due to the following:'); 149 document.printErrors(); 150 } 151 @endcode 152 @endif 153 * 154 * Here is an example of using a converter that offers an option. The 155 * following code invokes SBMLStripPackageConverter to remove the 156 * SBML Level 3 @em %Layout package from a model. It sets the name 157 * of the package to be removed by adding a value for the option named 158 * @c 'package' defined by that converter: 159 * 160 * @if cpp 161 * @code{.cpp} 162 ConversionProperties props; 163 props.addOption('stripPackage'); 164 props.addOption('package', 'layout'); 165 166 int status = document->convert(props); 167 if (status != LIBSBML_OPERATION_SUCCESS) 168 { 169 cerr << 'Unable to strip the Layout package from the model'; 170 cerr << 'Error returned: ' << status; 171 } 172 @endcode 173 @endif 174 @if python 175 @code{.py} 176 def strip_layout_example(document): 177 config = ConversionProperties() 178 if config != None: 179 config.addOption('stripPackage') 180 config.addOption('package', 'layout') 181 status = document.convert(config) 182 if status != LIBSBML_OPERATION_SUCCESS: 183 # Handle error somehow. 184 print('Error: unable to strip the Layout package.') 185 print('LibSBML returned error: ' + OperationReturnValue_toString(status).strip()) 186 else: 187 # Handle error somehow. 188 print('Error: unable to create ConversionProperties object') 189 @endcode 190 @endif 191 @if java 192 @code{.java} 193 ConversionProperties config = new ConversionProperties(); 194 if (config != None) { 195 config.addOption('stripPackage'); 196 config.addOption('package', 'layout'); 197 status = document.convert(config); 198 if (status != LIBSBML_OPERATION_SUCCESS) { 199 // Handle error somehow. 200 System.out.println('Error: unable to strip the Layout package'); 201 document.printErrors(); 202 } 203 } else { 204 // Handle error somehow. 205 System.out.println('Error: unable to create ConversionProperties object'); 206 } 207 @endcode 208 @endif 209 * 210 * @subsection available-converters Available SBML converters in libSBML 211 * 212 * LibSBML provides a number of built-in converters; by convention, their 213 * names end in @em Converter. The following are the built-in converters 214 * provided by libSBML @htmlinclude libsbml-version.html: 215 * 216 * @copydetails doc_list_of_libsbml_converters 217 * 218 * 219 */ 220 221 public class SBMLLevelVersionConverter : SBMLConverter { 222 private HandleRef swigCPtr; 223 SBMLLevelVersionConverter(IntPtr cPtr, bool cMemoryOwn)224 internal SBMLLevelVersionConverter(IntPtr cPtr, bool cMemoryOwn) : base(libsbmlPINVOKE.SBMLLevelVersionConverter_SWIGUpcast(cPtr), cMemoryOwn) 225 { 226 //super(libsbmlPINVOKE.SBMLLevelVersionConverterUpcast(cPtr), cMemoryOwn); 227 swigCPtr = new HandleRef(this, cPtr); 228 } 229 getCPtr(SBMLLevelVersionConverter obj)230 internal static HandleRef getCPtr(SBMLLevelVersionConverter obj) 231 { 232 return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; 233 } 234 getCPtrAndDisown(SBMLLevelVersionConverter obj)235 internal static HandleRef getCPtrAndDisown (SBMLLevelVersionConverter obj) 236 { 237 HandleRef ptr = new HandleRef(null, IntPtr.Zero); 238 239 if (obj != null) 240 { 241 ptr = obj.swigCPtr; 242 obj.swigCMemOwn = false; 243 } 244 245 return ptr; 246 } 247 Dispose(bool disposing)248 protected override void Dispose(bool disposing) { 249 lock(this) { 250 if (swigCPtr.Handle != global::System.IntPtr.Zero) { 251 if (swigCMemOwn) { 252 swigCMemOwn = false; 253 libsbmlPINVOKE.delete_SBMLLevelVersionConverter(swigCPtr); 254 } 255 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); 256 } 257 base.Dispose(disposing); 258 } 259 } 260 261 262 /** */ /* libsbml-internal */ public init()263 static void init() { 264 libsbmlPINVOKE.SBMLLevelVersionConverter_init(); 265 } 266 267 268 /** 269 * Creates a new SBMLLevelVersionConverter object. 270 */ public SBMLLevelVersionConverter()271 SBMLLevelVersionConverter() : this(libsbmlPINVOKE.new_SBMLLevelVersionConverter__SWIG_0(), true) { 272 } 273 274 275 /** 276 * Copy constructor; creates a copy of an SBMLLevelVersionConverter 277 * object. 278 * 279 * @param obj the SBMLLevelVersionConverter object to copy. 280 */ public SBMLLevelVersionConverter(SBMLLevelVersionConverter obj)281 SBMLLevelVersionConverter(SBMLLevelVersionConverter obj) : this(libsbmlPINVOKE.new_SBMLLevelVersionConverter__SWIG_1(SBMLLevelVersionConverter.getCPtr(obj)), true) { 282 if (libsbmlPINVOKE.SWIGPendingException.Pending) throw libsbmlPINVOKE.SWIGPendingException.Retrieve(); 283 } 284 285 286 /** 287 * Creates and returns a deep copy of this SBMLLevelVersionConverter 288 * object. 289 * 290 * @return a (deep) copy of this converter. 291 */ public new clone()292 SBMLConverter clone() { 293 global::System.IntPtr cPtr = libsbmlPINVOKE.SBMLLevelVersionConverter_clone(swigCPtr); 294 SBMLLevelVersionConverter ret = (cPtr == global::System.IntPtr.Zero) ? null : new SBMLLevelVersionConverter(cPtr, true); 295 return ret; 296 } 297 298 299 /** 300 * Returns @c true if this converter object's properties match the given 301 * properties. 302 * 303 * A typical use of this method involves creating a ConversionProperties 304 * object, setting the options desired, and then calling this method on 305 * an SBMLLevelVersionConverter object to find out if the object's 306 * property values match the given ones. This method is also used by 307 * SBMLConverterRegistry::getConverterFor(@if java ConversionProperties@endif) 308 * to search across all registered converters for one matching particular 309 * properties. 310 * 311 * @param props the properties to match. 312 * 313 * @return @c true if this converter's properties match, @c false 314 * otherwise. 315 */ public new matchesProperties(ConversionProperties props)316 bool matchesProperties(ConversionProperties props) { 317 bool ret = libsbmlPINVOKE.SBMLLevelVersionConverter_matchesProperties(swigCPtr, ConversionProperties.getCPtr(props)); 318 if (libsbmlPINVOKE.SWIGPendingException.Pending) throw libsbmlPINVOKE.SWIGPendingException.Retrieve(); 319 return ret; 320 } 321 322 323 /** 324 * Perform the conversion. 325 * 326 * This method causes the converter to do the actual conversion work, 327 * that is, to convert the SBMLDocument object set by 328 * SBMLConverter::setDocument(@if java SBMLDocument@endif) and 329 * with the configuration options set by 330 * SBMLConverter::setProperties(@if java ConversionProperties@endif). 331 * 332 * 333 * @return integer value indicating success/failure of the 334 * function. @if clike The value is drawn from the 335 * enumeration #OperationReturnValues_t. @endif The possible values 336 * returned by this function are: 337 * @li @link libsbml#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS@endlink 338 * @li @link libsbml#LIBSBML_OPERATION_FAILED LIBSBML_OPERATION_FAILED@endlink 339 * @li @link libsbml#LIBSBML_CONV_INVALID_TARGET_NAMESPACE LIBSBML_CONV_INVALID_TARGET_NAMESPACE@endlink 340 * @li @link libsbml#LIBSBML_CONV_PKG_CONVERSION_NOT_AVAILABLE LIBSBML_CONV_PKG_CONVERSION_NOT_AVAILABLE@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.SBMLLevelVersionConverter_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.SBMLLevelVersionConverter_getDefaultProperties(swigCPtr), true); 363 return ret; 364 } 365 366 367 /** 368 * Returns the target SBML Level for the conversion. 369 * 370 * @return an integer indicating the SBML Level. 371 */ public getTargetLevel()372 long getTargetLevel() { return (long)libsbmlPINVOKE.SBMLLevelVersionConverter_getTargetLevel(swigCPtr); } 373 374 375 /** 376 * Returns the target SBML Version for the conversion. 377 * 378 * @return an integer indicating the Version within the SBML Level. 379 */ public getTargetVersion()380 long getTargetVersion() { return (long)libsbmlPINVOKE.SBMLLevelVersionConverter_getTargetVersion(swigCPtr); } 381 382 383 /** 384 * Returns the flag indicating whether the conversion has been set to 'strict'. 385 * 386 * @return @c true if strict validity has been requested, @c false 387 * otherwise. 388 */ public getValidityFlag()389 bool getValidityFlag() { 390 bool ret = libsbmlPINVOKE.SBMLLevelVersionConverter_getValidityFlag(swigCPtr); 391 return ret; 392 } 393 394 395 /** 396 * Returns the flag indicating whether default units should be added when 397 * converting to L3 or not. 398 * 399 * @return @c true if default units should be added, @c false 400 * otherwise. 401 */ public getAddDefaultUnits()402 bool getAddDefaultUnits() { 403 bool ret = libsbmlPINVOKE.SBMLLevelVersionConverter_getAddDefaultUnits(swigCPtr); 404 return ret; 405 } 406 407 } 408 409 } 410