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 Registry of all libSBML SBML converters. 20 * 21 * @htmlinclude libsbml-facility-only-warning.html 22 * 23 * LibSBML provides facilities for transforming and converting SBML 24 * documents in various ways. These transformations can involve 25 * essentially anything that can be written algorithmically; examples 26 * include converting the units of measurement in a model, or converting 27 * from one Level+Version combination of SBML to another. Converters are 28 * implemented as objects derived from the class SBMLConverter. 29 * 30 * The converter registry, implemented as a singleton object of class 31 * SBMLConverterRegistry, maintains a list of known converters and provides 32 * methods for discovering them. Callers can use the method 33 * SBMLConverterRegistry::getNumConverters() to find out how many 34 * converters are registered, then use 35 * SBMLConverterRegistry::getConverterByIndex(@if java int@endif) to 36 * iterate over each one; alternatively, callers can use 37 * SBMLConverterRegistry::getConverterFor(@if java ConversionProperties@endif) 38 * to search for a converter having specific properties. 39 */ 40 41 public class SBMLConverterRegistry : global::System.IDisposable { 42 private HandleRef swigCPtr; 43 protected bool swigCMemOwn; 44 SBMLConverterRegistry(IntPtr cPtr, bool cMemoryOwn)45 internal SBMLConverterRegistry(IntPtr cPtr, bool cMemoryOwn) 46 { 47 swigCMemOwn = cMemoryOwn; 48 swigCPtr = new HandleRef(this, cPtr); 49 } 50 getCPtr(SBMLConverterRegistry obj)51 internal static HandleRef getCPtr(SBMLConverterRegistry obj) 52 { 53 return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; 54 } 55 getCPtrAndDisown(SBMLConverterRegistry obj)56 internal static HandleRef getCPtrAndDisown (SBMLConverterRegistry obj) 57 { 58 HandleRef ptr = new HandleRef(null, IntPtr.Zero); 59 60 if (obj != null) 61 { 62 ptr = obj.swigCPtr; 63 obj.swigCMemOwn = false; 64 } 65 66 return ptr; 67 } 68 ~SBMLConverterRegistry()69 ~SBMLConverterRegistry() { 70 Dispose(false); 71 } 72 Dispose()73 public void Dispose() { 74 Dispose(true); 75 global::System.GC.SuppressFinalize(this); 76 } 77 Dispose(bool disposing)78 protected virtual void Dispose(bool disposing) { 79 lock(this) { 80 if (swigCPtr.Handle != global::System.IntPtr.Zero) { 81 if (swigCMemOwn) { 82 swigCMemOwn = false; 83 libsbmlPINVOKE.delete_SBMLConverterRegistry(swigCPtr); 84 } 85 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); 86 } 87 } 88 } 89 90 91 /** 92 * Returns the singleton instance for the converter registry. 93 * 94 * Prior to using the registry, callers have to obtain a copy of the 95 * registry. This static method provides the means for doing that. 96 * 97 * @return the singleton for the converter registry. 98 */ public getInstance()99 static SBMLConverterRegistry getInstance() { 100 SBMLConverterRegistry ret = new SBMLConverterRegistry(libsbmlPINVOKE.SBMLConverterRegistry_getInstance(), false); 101 return ret; 102 } 103 104 105 /** 106 * Adds the given converter to the registry of SBML converters. 107 * 108 * @param converter the converter to add to the registry. 109 * 110 * 111 * @return integer value indicating success/failure of the 112 * function. @if clike The value is drawn from the 113 * enumeration #OperationReturnValues_t. @endif The possible values 114 * returned by this function are: 115 * @li @link libsbml#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS@endlink 116 * @li @link libsbml#LIBSBML_INVALID_OBJECT LIBSBML_INVALID_OBJECT@endlink 117 */ public addConverter(SBMLConverter converter)118 int addConverter(SBMLConverter converter) { 119 int ret = libsbmlPINVOKE.SBMLConverterRegistry_addConverter(swigCPtr, SBMLConverter.getCPtr(converter)); 120 return ret; 121 } 122 123 124 /** 125 * Returns the converter with the given index number. 126 * 127 * Converters are given arbitrary index numbers by the registry. Callers 128 * can use the method SBMLConverterRegistry::getNumConverters() to find 129 * out how many converters are registered, then use this method to 130 * iterate over the list and obtain each one in turn. 131 * 132 * @param index the zero-based index of the converter to fetch. 133 * 134 * @return the converter with the given index number, or @c null if the 135 * number is less than @c 0 or there is no converter at the given index 136 * position. 137 */ public getConverterByIndex(int index)138 SBMLConverter getConverterByIndex(int index) { 139 SBMLConverter ret 140 = (SBMLConverter) libsbml.DowncastSBMLConverter(libsbmlPINVOKE.SBMLConverterRegistry_getConverterByIndex(swigCPtr, index), false); 141 return ret; 142 } 143 144 145 /** 146 * Returns the converter that best matches the given configuration 147 * properties. 148 * 149 * Many converters provide the ability to configure their behavior. This 150 * is realized through the use of @em properties that offer different @em 151 * options. The present method allows callers to search for converters 152 * that have specific property values. Callers can do this by creating a 153 * ConversionProperties object, adding the desired option(s) to the 154 * object, then passing the object to this method. 155 * 156 * @param props a ConversionProperties object defining the properties 157 * to match against. 158 * 159 * @return the converter matching the properties, or @c null if no 160 * suitable converter is found. 161 * 162 * @see getConverterByIndex(@if java int@endif) 163 */ public getConverterFor(ConversionProperties props)164 SBMLConverter getConverterFor(ConversionProperties props) { 165 SBMLConverter ret 166 = (SBMLConverter) libsbml.DowncastSBMLConverter(libsbmlPINVOKE.SBMLConverterRegistry_getConverterFor(swigCPtr, ConversionProperties.getCPtr(props)), false); 167 if (libsbmlPINVOKE.SWIGPendingException.Pending) throw libsbmlPINVOKE.SWIGPendingException.Retrieve(); 168 return ret; 169 } 170 171 172 /** 173 * Returns the number of converters known by the registry. 174 * 175 * @return the number of registered converters. 176 * 177 * @see getConverterByIndex(@if java int@endif) 178 */ public getNumConverters()179 int getNumConverters() { 180 int ret = libsbmlPINVOKE.SBMLConverterRegistry_getNumConverters(swigCPtr); 181 return ret; 182 } 183 184 } 185 186 } 187