001/* ----------------------------------------------------------------------------
002 * This file was automatically generated by SWIG (http://www.swig.org).
003 * Version 3.0.8
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 where package extensions are registered.
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.  This class is not prescribed by
017the SBML specifications, although it is used to implement features
018defined in SBML.
019</p>
020
021 <p>
022 * This class provides a central registry of all extensions known to libSBML.
023 * Each package extension must be registered with the registry.  The registry
024 * class is accessed by various classes to retrieve information about known
025 * package extensions and to create additional attributes and/or elements by
026 * factory objects of the package extensions.
027 <p>
028 * <p>
029 * The package extension registry is implemented as a singleton instance of
030 * {@link SBMLExtensionRegistry}.  The class provides only utility functionality;
031 * implementations of SBML packages do not need to implement any subclasses or
032 * methods of this class.  {@link SBMLExtensionRegistry} is useful for its facilities
033 * to query the known packages, and to enable or disable packages selectively.
034 */
035
036public class SBMLExtensionRegistry {
037   private long swigCPtr;
038   protected boolean swigCMemOwn;
039
040   protected SBMLExtensionRegistry(long cPtr, boolean cMemoryOwn)
041   {
042     swigCMemOwn = cMemoryOwn;
043     swigCPtr    = cPtr;
044   }
045
046   protected static long getCPtr(SBMLExtensionRegistry obj)
047   {
048     return (obj == null) ? 0 : obj.swigCPtr;
049   }
050
051   protected static long getCPtrAndDisown (SBMLExtensionRegistry obj)
052   {
053     long ptr = 0;
054
055     if (obj != null)
056     {
057       ptr             = obj.swigCPtr;
058       obj.swigCMemOwn = false;
059     }
060
061     return ptr;
062   }
063
064  public synchronized void delete() {
065    if (swigCPtr != 0) {
066      if (swigCMemOwn) {
067        swigCMemOwn = false;
068        throw new UnsupportedOperationException("C++ destructor does not have public access");
069      }
070      swigCPtr = 0;
071    }
072  }
073
074  
075/**
076   * Returns a singleton instance of the registry.
077   <p>
078   * Callers need to obtain a copy of the package extension registry before
079   * they can invoke its methods.  The registry is implemented as a
080   * singleton, and this is the method callers can use to get a copy of it.
081   <p>
082   * @return the instance of the {@link SBMLExtensionRegistry} object.
083   */ public
084 static SBMLExtensionRegistry getInstance() {
085    return new SBMLExtensionRegistry(libsbmlJNI.SBMLExtensionRegistry_getInstance(), false);
086  }
087
088  
089/**
090   * Add the given {@link SBMLExtension} object to this {@link SBMLExtensionRegistry}.
091   <p>
092   * @param ext the {@link SBMLExtension} object to be added.
093   <p>
094   * <p>
095 * @return integer value indicating success/failure of the
096 * function.   The possible values
097 * returned by this function are:
098   * <ul>
099   * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS}
100   * <li> {@link libsbmlConstants#LIBSBML_PKG_CONFLICT LIBSBML_PKG_CONFLICT}
101   * <li> {@link libsbmlConstants#LIBSBML_INVALID_ATTRIBUTE_VALUE LIBSBML_INVALID_ATTRIBUTE_VALUE}
102   * </ul>
103   */ public
104 int addExtension(SBMLExtension ext) {
105    return libsbmlJNI.SBMLExtensionRegistry_addExtension(swigCPtr, this, SBMLExtension.getCPtr(ext), ext);
106  }
107
108  
109/**
110   * Returns an {@link SBMLExtension} object with the given package URI or package
111   * name.
112   <p>
113   * @param package a string representing the URI or name of the SBML package
114   * whose package extension is being sought.
115   <p>
116   * @return a clone of the {@link SBMLExtension} object with the given package URI
117   * or name.
118   <p>
119   * @note The caller is responsible for freeing the object returned.  Since
120   * the object is a clone, freeing it will not result in the deletion of the
121   * original package extension object.
122   */ public
123 SBMLExtension getExtension(String arg0) {
124    return libsbml.DowncastExtension(libsbmlJNI.SBMLExtensionRegistry_getExtension(swigCPtr, this, arg0), false);
125}
126
127  
128/**
129   * Removes SBML Level&nbsp;2 namespaces from the namespace list.
130   <p>
131   * @param xmlns an {@link XMLNamespaces} object listing one or more namespaces
132   * to be removed.
133   */ public
134 void removeL2Namespaces(XMLNamespaces xmlns) {
135    libsbmlJNI.SBMLExtensionRegistry_removeL2Namespaces(swigCPtr, this, XMLNamespaces.getCPtr(xmlns), xmlns);
136  }
137
138  
139/**
140   * Adds SBML Level&nbsp;2 namespaces to the namespace list.
141   <p>
142   * @param xmlns an {@link XMLNamespaces} object providing one or more namespaces to
143   * be added.
144   */ public
145 void addL2Namespaces(XMLNamespaces xmlns) {
146    libsbmlJNI.SBMLExtensionRegistry_addL2Namespaces(swigCPtr, this, XMLNamespaces.getCPtr(xmlns), xmlns);
147  }
148
149  
150/**
151   * Enables package extensions that support serialization to SBML annotations.
152   <p>
153   * SBML Level&nbsp;2 does not have a package mechanism in the way that SBML
154   * Level&nbsp;3 does.  However, SBML annotations can be used to store SBML
155   * constructs.  In fact, a widely-used approach to developing SBML
156   * Level&nbsp;3 packages involves first using them as annotations.
157   <p>
158   * @param doc the {@link SBMLDocument} object for which this should be enabled.
159   */ public
160 void enableL2NamespaceForDocument(SBMLDocument doc) {
161    libsbmlJNI.SBMLExtensionRegistry_enableL2NamespaceForDocument(swigCPtr, this, SBMLDocument.getCPtr(doc), doc);
162  }
163
164  
165/**
166   * Disables unused packages.
167   <p>
168   * This method walks through all extensions in the list of plugins of the
169   * given SBML document <code>doc</code>, and disables all that are not being used.
170   <p>
171   * @param doc the {@link SBMLDocument} object whose unused package extensions
172   * should be disabled.
173   */ public
174 void disableUnusedPackages(SBMLDocument doc) {
175    libsbmlJNI.SBMLExtensionRegistry_disableUnusedPackages(swigCPtr, this, SBMLDocument.getCPtr(doc), doc);
176  }
177
178  
179/**
180   * Disables the package with the given URI or name.
181   <p>
182   * @param package a string representing the URI or name of the SBML package
183   * whose package extension is to be disabled.
184   */ public
185 static void disablePackage(String arg0) {
186    libsbmlJNI.SBMLExtensionRegistry_disablePackage(arg0);
187  }
188
189  
190/**
191   * Returns <code>true</code> if the named package is enabled.
192   <p>
193   * @param package the name or URI of a package to test.
194   <p>
195   * @return <code>true</code> if the package is enabled, <code>false</code> otherwise.
196   */ public
197 static boolean isPackageEnabled(String arg0) {
198    return libsbmlJNI.SBMLExtensionRegistry_isPackageEnabled(arg0);
199  }
200
201  
202/**
203   * Enables the package with the given URI / name.
204   <p>
205   * @param package the name or URI of a package to enable.
206   */ public
207 static void enablePackage(String arg0) {
208    libsbmlJNI.SBMLExtensionRegistry_enablePackage(arg0);
209  }
210
211  
212/**
213   * Returns the number of extensions that have a given extension point.
214   <p>
215   * @param extPoint the {@link SBaseExtensionPoint} object
216   <p>
217   * @return the number of {@link SBMLExtension}-derived objects with the given
218   * extension point.
219   */ public
220 long getNumExtension(SBaseExtensionPoint extPoint) {
221    return libsbmlJNI.SBMLExtensionRegistry_getNumExtension(swigCPtr, this, SBaseExtensionPoint.getCPtr(extPoint), extPoint);
222  }
223
224  
225/**
226   * Enables or disable the package with the given URI.
227   <p>
228   * @param uri the URI of the target package.
229   * @param isEnabled <code>true</code> to enable the package, <code>false</code> to disable.
230   <p>
231   * @return <code>false</code> if <code>isEnabled</code> is <code>false</code> or the given package is not
232   * registered, otherwise this method returns <code>true.</code>
233   */ public
234 boolean setEnabled(String uri, boolean isEnabled) {
235    return libsbmlJNI.SBMLExtensionRegistry_setEnabled(swigCPtr, this, uri, isEnabled);
236  }
237
238  
239/**
240   * Returns <code>true</code> if the given extension is enabled.
241   <p>
242   * @param uri the URI of the target package.
243   <p>
244   * @return <code>false</code> if the given package is disabled or not registered,
245   * <code>true</code> otherwise.
246   */ public
247 boolean isEnabled(String uri) {
248    return libsbmlJNI.SBMLExtensionRegistry_isEnabled(swigCPtr, this, uri);
249  }
250
251  
252/**
253   * Returns <code>true</code> if a package extension is registered for the
254   * corresponding package URI.
255   <p>
256   * @param uri the URI of the target package.
257   <p>
258   * @return <code>true</code> if the package with the given URI is registered,
259   * otherwise returns <code>false.</code>
260   */ public
261 boolean isRegistered(String uri) {
262    return libsbmlJNI.SBMLExtensionRegistry_isRegistered(swigCPtr, this, uri);
263  }
264
265  
266/**
267   * Returns a list of registered packages.
268   <p>
269   * This method returns a vector of strings containing the nicknames of the
270   * SBML packages for which package extensions are registered with this copy
271   * of libSBML.  The vector will contain <code>String</code> objects.
272   <p>
273   * @return a vector of strings
274   */ public
275 static SWIGTYPE_p_std__vectorT_std__string_t getAllRegisteredPackageNames() {
276    return new SWIGTYPE_p_std__vectorT_std__string_t(libsbmlJNI.SBMLExtensionRegistry_getAllRegisteredPackageNames(), true);
277  }
278
279  
280/**
281   * Returns the number of registered packages.
282   <p>
283   * @return a count of the registered package extensions.
284   */ public
285 static long getNumRegisteredPackages() {
286    return libsbmlJNI.SBMLExtensionRegistry_getNumRegisteredPackages();
287  }
288
289  
290/**
291   * Returns the nth registered package.
292   <p>
293   * @param index zero-based index of the package name to return.
294   <p>
295   * @return the package name with the given index, or <code>null</code> if none
296   * such exists.
297   <p>
298   * @see #getNumRegisteredPackages()
299   */ public
300 static String getRegisteredPackageName(long index) {
301    return libsbmlJNI.SBMLExtensionRegistry_getRegisteredPackageName(index);
302  }
303
304}