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