001/* ----------------------------------------------------------------------------
002 * This file was automatically generated by SWIG (http://www.swig.org).
003 * Version 2.0.12
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 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 index)} to
034 * iterate over each one; alternatively, callers can use
035 * {@link SBMLConverterRegistry#getConverterFor(ConversionProperties props)}
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   * @return integer value indicating the success/failure of the operation.
101   *  The possible values are:
102   * <ul>
103   * <li> {@link  libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS }
104   * <li> {@link  libsbmlConstants#LIBSBML_INVALID_OBJECT LIBSBML_INVALID_OBJECT }
105   * </ul>
106   */ public
107 int addConverter(SBMLConverter converter) {
108    return libsbmlJNI.SBMLConverterRegistry_addConverter(swigCPtr, this, SBMLConverter.getCPtr(converter), converter);
109  }
110
111  
112/** 
113   * Returns the converter with the given index number.
114   <p>
115   * Converters are given arbitrary index numbers by the registry.  Callers
116   * can use the method {@link SBMLConverterRegistry#getNumConverters()} to find
117   * out how many converters are registered, then use this method to
118   * iterate over the list and obtain each one in turn.
119   <p>
120   * @param index the zero-based index of the converter to fetch.
121   <p>
122   * @return the converter with the given index number, or <code>null</code> if the
123   * number is less than <code>0</code> or there is no converter at the given index
124   * position.
125   */ public
126 SBMLConverter getConverterByIndex(int index) {
127    long cPtr = libsbmlJNI.SBMLConverterRegistry_getConverterByIndex(swigCPtr, this, index);
128    return (cPtr == 0) ? null : new SBMLConverter(cPtr, false);
129  }
130
131  
132/** 
133   * Returns the converter that best matches the given configuration
134   * properties.
135   <p>
136   * Many converters provide the ability to configure their behavior.  This
137   * is realized through the use of <em>properties</em> that offer different 
138   * <em>options</em>.  The present method allows callers to search for converters
139   * that have specific property values.  Callers can do this by creating a
140   * {@link ConversionProperties} object, adding the desired option(s) to the
141   * object, then passing the object to this method.
142   <p>
143   * @param props a {@link ConversionProperties} object defining the properties
144   * to match against.
145   <p>
146   * @return the converter matching the properties, or <code>null</code> if no
147   * suitable converter is found.
148   <p>
149   * @see #getConverterByIndex(int index)
150   */ public
151 SBMLConverter getConverterFor(ConversionProperties props) {
152    long cPtr = libsbmlJNI.SBMLConverterRegistry_getConverterFor(swigCPtr, this, ConversionProperties.getCPtr(props), props);
153    return (cPtr == 0) ? null : new SBMLConverter(cPtr, 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 index)
163   */ public
164 int getNumConverters() {
165    return libsbmlJNI.SBMLConverterRegistry_getNumConverters(swigCPtr, this);
166  }
167
168}