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