001/* ---------------------------------------------------------------------------- 002 * This file was automatically generated by SWIG (http://www.swig.org). 003 * Version 3.0.7 004 * 005 * Do not make changes to this file unless you know what you are doing--modify 006 * the SWIG interface file instead. 007 * ----------------------------------------------------------------------------- */ 008 009package org.sbml.libsbml; 010 011/** 012 * Registry of all libSBML SBML converters. 013 <p> 014 * <p style='color: #777; font-style: italic'> 015This class of objects is defined by libSBML only and has no direct 016equivalent in terms of SBML components. It is a class used in 017the implementation of extra functionality provided by libSBML. 018</p> 019 020 <p> 021 * LibSBML provides facilities for transforming and converting SBML 022 * documents in various ways. These transformations can involve 023 * essentially anything that can be written algorithmically; examples 024 * include converting the units of measurement in a model, or converting 025 * from one Level+Version combination of SBML to another. Converters are 026 * implemented as objects derived from the class {@link SBMLConverter}. 027 <p> 028 * The converter registry, implemented as a singleton object of class 029 * {@link SBMLConverterRegistry}, maintains a list of known converters and provides 030 * methods for discovering them. Callers can use the method 031 * {@link SBMLConverterRegistry#getNumConverters()} to find out how many 032 * converters are registered, then use 033 * {@link SBMLConverterRegistry#getConverterByIndex(int)} to 034 * iterate over each one; alternatively, callers can use 035 * {@link SBMLConverterRegistry#getConverterFor(ConversionProperties)} 036 * to search for a converter having specific properties. 037 */ 038 039public class SBMLConverterRegistry { 040 private long swigCPtr; 041 protected boolean swigCMemOwn; 042 043 protected SBMLConverterRegistry(long cPtr, boolean cMemoryOwn) 044 { 045 swigCMemOwn = cMemoryOwn; 046 swigCPtr = cPtr; 047 } 048 049 protected static long getCPtr(SBMLConverterRegistry obj) 050 { 051 return (obj == null) ? 0 : obj.swigCPtr; 052 } 053 054 protected static long getCPtrAndDisown (SBMLConverterRegistry obj) 055 { 056 long ptr = 0; 057 058 if (obj != null) 059 { 060 ptr = obj.swigCPtr; 061 obj.swigCMemOwn = false; 062 } 063 064 return ptr; 065 } 066 067 protected void finalize() { 068 delete(); 069 } 070 071 public synchronized void delete() { 072 if (swigCPtr != 0) { 073 if (swigCMemOwn) { 074 swigCMemOwn = false; 075 libsbmlJNI.delete_SBMLConverterRegistry(swigCPtr); 076 } 077 swigCPtr = 0; 078 } 079 } 080 081 082/** 083 * Returns the singleton instance for the converter registry. 084 <p> 085 * Prior to using the registry, callers have to obtain a copy of the 086 * registry. This static method provides the means for doing that. 087 <p> 088 * @return the singleton for the converter registry. 089 */ public 090 static SBMLConverterRegistry getInstance() { 091 return new SBMLConverterRegistry(libsbmlJNI.SBMLConverterRegistry_getInstance(), false); 092 } 093 094 095/** 096 * Adds the given converter to the registry of SBML converters. 097 <p> 098 * @param converter the converter to add to the registry. 099 <p> 100 * <p> 101 * @return integer value indicating success/failure of the 102 * function. The possible values 103 * returned by this function are: 104 * <ul> 105 * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS} 106 * <li> {@link libsbmlConstants#LIBSBML_INVALID_OBJECT LIBSBML_INVALID_OBJECT} 107 * </ul> 108 */ public 109 int addConverter(SBMLConverter converter) { 110 return libsbmlJNI.SBMLConverterRegistry_addConverter(swigCPtr, this, SBMLConverter.getCPtr(converter), converter); 111 } 112 113 114/** 115 * Returns the converter with the given index number. 116 <p> 117 * Converters are given arbitrary index numbers by the registry. Callers 118 * can use the method {@link SBMLConverterRegistry#getNumConverters()} to find 119 * out how many converters are registered, then use this method to 120 * iterate over the list and obtain each one in turn. 121 <p> 122 * @param index the zero-based index of the converter to fetch. 123 <p> 124 * @return the converter with the given index number, or <code>null</code> if the 125 * number is less than <code>0</code> or there is no converter at the given index 126 * position. 127 */ public 128 SBMLConverter getConverterByIndex(int index) { 129 return libsbml.DowncastSBMLConverter(libsbmlJNI.SBMLConverterRegistry_getConverterByIndex(swigCPtr, this, index), false); 130} 131 132 133/** 134 * Returns the converter that best matches the given configuration 135 * properties. 136 <p> 137 * Many converters provide the ability to configure their behavior. This 138 * is realized through the use of <em>properties</em> that offer different 139 * <em>options</em>. The present method allows callers to search for converters 140 * that have specific property values. Callers can do this by creating a 141 * {@link ConversionProperties} object, adding the desired option(s) to the 142 * object, then passing the object to this method. 143 <p> 144 * @param props a {@link ConversionProperties} object defining the properties 145 * to match against. 146 <p> 147 * @return the converter matching the properties, or <code>null</code> if no 148 * suitable converter is found. 149 <p> 150 * @see #getConverterByIndex(int) 151 */ public 152 SBMLConverter getConverterFor(ConversionProperties props) { 153 return libsbml.DowncastSBMLConverter(libsbmlJNI.SBMLConverterRegistry_getConverterFor(swigCPtr, this, ConversionProperties.getCPtr(props), props), false); 154} 155 156 157/** 158 * Returns the number of converters known by the registry. 159 <p> 160 * @return the number of registered converters. 161 <p> 162 * @see #getConverterByIndex(int) 163 */ public 164 int getNumConverters() { 165 return libsbmlJNI.SBMLConverterRegistry_getNumConverters(swigCPtr, this); 166 } 167 168}