001/* ----------------------------------------------------------------------------
002 * This file was automatically generated by SWIG (http://www.swig.org).
003 * Version 3.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 * <span class="pkg-marker pkg-color-comp"><a href="group__comp.html">comp</a></span>
013 Extension of {@link Model}.
014 <p>
015 * The {@link CompModelPlugin} class inherits from the SBMLSBasePlugin class, and
016 * codifies the extensions to the {@link Model} class defined in the SBML
017 * Level&nbsp;3 <a href='../../../extensions-summary.html#comp'>Hierarchical Model Composition</a> (&ldquo;comp&rdquo;) package.  This extension
018 * allows a {@link Model} to define Submodels (other Models that are instantiated as
019 * new parts of the parent {@link Model}), and Ports, a defined interface for
020 * including the given {@link Model} as a {@link Submodel} of a different {@link Model}.
021 <p>
022 * Submodels are stored in an optional child {@link ListOfSubmodels} object, which, 
023 * if present, must contain one or more {@link Submodel} objects.  All of the Submodels
024 * present in the {@link ListOfSubmodels} are defined to be instantiated in the
025 * 'complete' {@link Model}.
026 <p>
027 * Ports are stored in an optional child {@link ListOfPorts} object, which, 
028 * if present, must contain one or more {@link Port} objects.  All of the Ports
029 * present in the {@link ListOfPorts} collectively define the 'port interface'
030 * of the {@link Model}.
031 */
032
033public class CompModelPlugin extends CompSBasePlugin {
034   private long swigCPtr;
035
036   protected CompModelPlugin(long cPtr, boolean cMemoryOwn)
037   {
038     super(libsbmlJNI.CompModelPlugin_SWIGUpcast(cPtr), cMemoryOwn);
039     swigCPtr = cPtr;
040   }
041
042   protected static long getCPtr(CompModelPlugin obj)
043   {
044     return (obj == null) ? 0 : obj.swigCPtr;
045   }
046
047   protected static long getCPtrAndDisown (CompModelPlugin obj)
048   {
049     long ptr = 0;
050
051     if (obj != null)
052     {
053       ptr             = obj.swigCPtr;
054       obj.swigCMemOwn = false;
055     }
056
057     return ptr;
058   }
059
060  protected void finalize() {
061    delete();
062  }
063
064  public synchronized void delete() {
065    if (swigCPtr != 0) {
066      if (swigCMemOwn) {
067        swigCMemOwn = false;
068        libsbmlJNI.delete_CompModelPlugin(swigCPtr);
069      }
070      swigCPtr = 0;
071    }
072    super.delete();
073  }
074
075  
076/**
077   * Creates a new {@link CompModelPlugin} object using the given parameters.
078   <p>
079   * <p>
080 * In the XML representation of an SBML document, XML namespaces are used to
081 * identify the origin of each XML construct used.  XML namespaces are
082 * identified by their unique resource identifiers (URIs).  The core SBML
083 * specifications stipulate the namespaces that must be used for core SBML
084 * constructs; for example, all XML elements that belong to SBML Level&nbsp;3
085 * Version&nbsp;1 Core must be placed in the XML namespace identified by the URI
086 * <code>'http://www.sbml.org/sbml/level3/version1/core'</code>.  Individual
087 * SBML Level&nbsp;3 packages define their own XML namespaces; for example,
088 * all elements belonging to the SBML Level&nbsp;3 Layout Version&nbsp;1
089 * package must be placed in the XML namespace
090 * <code>'http://www.sbml.org/sbml/level3/version1/layout/version1/'</code>.
091   <p>
092   * <p>
093 * The {@link SBMLNamespaces} object encapsulates SBML Level/Version/namespaces
094 * information.  It is used to communicate the SBML Level, Version, and (in
095 * Level&nbsp;3) packages used in addition to SBML Level&nbsp;3 Core.  A
096 * common approach to using libSBML's {@link SBMLNamespaces} facilities is to create an
097 * {@link SBMLNamespaces} object somewhere in a program once, then hand that object
098 * as needed to object constructors that accept {@link SBMLNamespaces} as arguments.
099   <p>
100   * @param uri the URI of the SBML Level&nbsp;3 package implemented by
101   * this libSBML package extension.
102   <p>
103   * @param prefix the XML namespace prefix being used for the package.
104   <p>
105   * @param compns the namespaces object for the package.
106   */ public
107 CompModelPlugin(String uri, String prefix, CompPkgNamespaces compns) {
108    this(libsbmlJNI.new_CompModelPlugin__SWIG_0(uri, prefix, CompPkgNamespaces.getCPtr(compns), compns), true);
109  }
110
111  
112/**
113   * Copy constructor. Creates a copy of this {@link CompModelPlugin} object.
114   <p>
115   * @param orig the instance to copy.
116   */ public
117 CompModelPlugin(CompModelPlugin orig) {
118    this(libsbmlJNI.new_CompModelPlugin__SWIG_1(CompModelPlugin.getCPtr(orig), orig), true);
119  }
120
121  
122/**
123   * Creates and returns a deep copy of this {@link CompModelPlugin} object.
124   <p>
125   * @return a (deep) copy of this {@link CompModelPlugin} object.
126   */ public
127 SBasePlugin cloneObject() {
128    long cPtr = libsbmlJNI.CompModelPlugin_cloneObject(swigCPtr, this);
129    return (cPtr == 0) ? null : new CompModelPlugin(cPtr, true);
130  }
131
132  
133/** * @internal */ public
134 SBase createObject(XMLInputStream stream) {
135  return libsbml.DowncastSBase(libsbmlJNI.CompModelPlugin_createObject(swigCPtr, this, XMLInputStream.getCPtr(stream), stream), false);
136}
137
138  
139/**
140   * Returns the first child element found that has the given <code>id</code> in the
141   * model-wide SId namespace, or <code>null</code> if no such object is found.
142   <p>
143   * @param id a string representing the id of the object to find.
144   <p>
145   * @return a pointer to the {@link SBase} element with the given <code>id</code>.
146   */ public
147 SBase getElementBySId(String id) {
148  return libsbml.DowncastSBase(libsbmlJNI.CompModelPlugin_getElementBySId(swigCPtr, this, id), false);
149}
150
151  
152/**
153   * Returns the first child element it can find with the given meta
154   * identifier, or itself if it has the given <code>metaid</code>, or <code>null</code> if no
155   * such object is found.
156   <p>
157   * @param metaid a string representing the metaid of the object to find.
158   <p>
159   * @return a pointer to the {@link SBase} element with the given <code>metaid</code>.
160   */ public
161 SBase getElementByMetaId(String metaid) {
162  return libsbml.DowncastSBase(libsbmlJNI.CompModelPlugin_getElementByMetaId(swigCPtr, this, metaid), false);
163}
164
165  
166/**
167  * Returns the {@link ListOfSubmodels} from this {@link CompModelPlugin}.
168  <p>
169  * @return the {@link ListOfSubmodels} from this {@link CompModelPlugin}.
170  <p>
171  * <p>
172 * The pointer that is returned by this function is not owned by the caller,
173 * but may be queried and modified.  Any changes made will be reflected in any
174 * resulting SBML document containing the pointer's parent.
175  <p>
176  * @see #addSubmodel(Submodel object)
177  * @see #createSubmodel()
178  * @see #getSubmodel(String sid)
179  * @see #getSubmodel(long n)
180  * @see #getNumSubmodels()
181  * @see #removeSubmodel(String sid)
182  * @see #removeSubmodel(long n)
183  */ public
184 ListOfSubmodels getListOfSubmodels() {
185    long cPtr = libsbmlJNI.CompModelPlugin_getListOfSubmodels__SWIG_0(swigCPtr, this);
186    return (cPtr == 0) ? null : new ListOfSubmodels(cPtr, false);
187  }
188
189  
190/**
191   * Returns the submodel with the given index.
192   * If the index is invalid, <code>null</code> is returned.
193   <p>
194   * @param n the index number of the {@link Submodel} to get.
195   <p>
196   * @return the nth {@link Submodel} in the {@link ListOfSubmodels}.
197   */ public
198 Submodel getSubmodel(long n) {
199    long cPtr = libsbmlJNI.CompModelPlugin_getSubmodel__SWIG_0(swigCPtr, this, n);
200    return (cPtr == 0) ? null : new Submodel(cPtr, false);
201  }
202
203  
204/**
205   * Returns the submodel with the given identifier.
206   <p>
207   * @param id the identifier of the {@link Submodel} to get.
208   <p>
209   * @return the {@link Submodel} in the {@link ListOfSubmodels} with the given identifier.
210   * If no such submodel with identifier <code>id</code> exists, <code>null</code> is returned.
211   */ public
212 Submodel getSubmodel(String id) {
213    long cPtr = libsbmlJNI.CompModelPlugin_getSubmodel__SWIG_2(swigCPtr, this, id);
214    return (cPtr == 0) ? null : new Submodel(cPtr, false);
215  }
216
217  
218/**
219   * Adds a copy of the given {@link Submodel} object to the list of submodels.
220   <p>
221   * Fails if the added submodel is <code>null</code>, does not match the
222   * level/version/package of the parent object, or cannot be added to the
223   * list of submodels.
224   <p>
225   * @param submodel the {@link Submodel} object to be added to the list of
226   * submodels.
227   <p>
228   * <p>
229 * @return integer value indicating success/failure of the
230 * function.   The possible values
231 * returned by this function are:
232   * <ul>
233   * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS}
234   * <li> {@link libsbmlConstants#LIBSBML_INVALID_OBJECT LIBSBML_INVALID_OBJECT}
235   * <li> {@link libsbmlConstants#LIBSBML_LEVEL_MISMATCH LIBSBML_LEVEL_MISMATCH}
236   * <li> {@link libsbmlConstants#LIBSBML_VERSION_MISMATCH LIBSBML_VERSION_MISMATCH}
237   * <li> {@link libsbmlConstants#LIBSBML_PKG_VERSION_MISMATCH LIBSBML_PKG_VERSION_MISMATCH}
238   * </ul>
239   */ public
240 int addSubmodel(Submodel submodel) {
241    return libsbmlJNI.CompModelPlugin_addSubmodel(swigCPtr, this, Submodel.getCPtr(submodel), submodel);
242  }
243
244  
245/**
246   * Returns the number of submodels for this {@link CompModelPlugin}.
247   <p>
248   * @return the number of submodels for this {@link CompModelPlugin}.
249   */ public
250 long getNumSubmodels() {
251    return libsbmlJNI.CompModelPlugin_getNumSubmodels(swigCPtr, this);
252  }
253
254  
255/**
256   * Creates a {@link Submodel} object, adds it to the end of the
257   * submodel objects list and returns a pointer to the newly
258   * created object.
259   <p>
260   * @return a newly created {@link Submodel} object.
261   */ public
262 Submodel createSubmodel() {
263    long cPtr = libsbmlJNI.CompModelPlugin_createSubmodel(swigCPtr, this);
264    return (cPtr == 0) ? null : new Submodel(cPtr, false);
265  }
266
267  
268/**
269   * Removes the submodel with the given index.
270   * A pointer to the submodel that was removed is returned.
271   * The caller owns the returned item and is responsible for deleting it.
272   <p>
273   * @param index the index of the {@link Submodel} object to remove.
274   <p>
275   * @return the {@link Submodel} object removed.  As mentioned above, the caller
276   * owns the returned object. <code>null</code> is returned if the given <code>index</code> is
277   * out of range and no submodel has been removed, <code>null</code> is returned.
278   */ public
279 Submodel removeSubmodel(long index) {
280    long cPtr = libsbmlJNI.CompModelPlugin_removeSubmodel(swigCPtr, this, index);
281    return (cPtr == 0) ? null : new Submodel(cPtr, false);
282  }
283
284  
285/**
286  * Returns the {@link ListOfPorts} from this {@link CompModelPlugin}.
287  <p>
288  * @return the {@link ListOfPorts} from this {@link CompModelPlugin}.
289  <p>
290  * <p>
291 * The pointer that is returned by this function is not owned by the caller,
292 * but may be queried and modified.  Any changes made will be reflected in any
293 * resulting SBML document containing the pointer's parent.
294  <p>
295  * @see #addPort(Port object)
296  * @see #createPort()
297  * @see #getPort(String sid)
298  * @see #getPort(long n)
299  * @see #getNumPorts()
300  * @see #removePort(String sid)
301  * @see #removePort(long n)
302  */ public
303 ListOfPorts getListOfPorts() {
304    long cPtr = libsbmlJNI.CompModelPlugin_getListOfPorts__SWIG_0(swigCPtr, this);
305    return (cPtr == 0) ? null : new ListOfPorts(cPtr, false);
306  }
307
308  
309/**
310   * Returns the port with the given index.
311   <p>
312   * @param n the index number of the {@link Port} to get.
313   <p>
314   * @return the nth {@link Port} in the {@link ListOfPorts}.  If the index <code>n</code> is invalid,
315   * <code>null</code> is returned.
316   */ public
317 Port getPort(long n) {
318    long cPtr = libsbmlJNI.CompModelPlugin_getPort__SWIG_0(swigCPtr, this, n);
319    return (cPtr == 0) ? null : new Port(cPtr, false);
320  }
321
322  
323/**
324   * Returns the port with the given identifier.
325   <p>
326   * @param id the id of the {@link Port} to get.
327   <p>
328   * @return the {@link Port} in the {@link ListOfPorts} with the given identifier.  If the
329   * identifier is invalid, <code>null</code> is returned.
330   */ public
331 Port getPort(String id) {
332    long cPtr = libsbmlJNI.CompModelPlugin_getPort__SWIG_2(swigCPtr, this, id);
333    return (cPtr == 0) ? null : new Port(cPtr, false);
334  }
335
336  
337/**
338   * Adds a copy of the given {@link Port} object to the list of ports.
339   <p>
340   * @param port the {@link Port} object to be added to the list of ports.  Fails if
341   * the added port is <code>null</code>, does not match the level/version/package of the
342   * parent object, or cannot be added to the list of ports.
343   <p>
344   * <p>
345 * @return integer value indicating success/failure of the
346 * function.   The possible values
347 * returned by this function are:
348   * <ul>
349   * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS}
350   * <li> {@link libsbmlConstants#LIBSBML_INVALID_OBJECT LIBSBML_INVALID_OBJECT}
351   * <li> {@link libsbmlConstants#LIBSBML_LEVEL_MISMATCH LIBSBML_LEVEL_MISMATCH}
352   * <li> {@link libsbmlConstants#LIBSBML_VERSION_MISMATCH LIBSBML_VERSION_MISMATCH}
353   * <li> {@link libsbmlConstants#LIBSBML_PKG_VERSION_MISMATCH LIBSBML_PKG_VERSION_MISMATCH}
354   * </ul>
355   */ public
356 int addPort(Port port) {
357    return libsbmlJNI.CompModelPlugin_addPort(swigCPtr, this, Port.getCPtr(port), port);
358  }
359
360  
361/**
362   * Returns the number of ports for this {@link CompModelPlugin}.
363   <p>
364   * @return the number of ports for this {@link CompModelPlugin}.
365   */ public
366 long getNumPorts() {
367    return libsbmlJNI.CompModelPlugin_getNumPorts(swigCPtr, this);
368  }
369
370  
371/**
372   * Creates a {@link Port} object, adds it to the end of the
373   * port objects list and returns a pointer to the newly
374   * created object.
375   <p>
376   * @return a newly created {@link Port} object.
377   */ public
378 Port createPort() {
379    long cPtr = libsbmlJNI.CompModelPlugin_createPort(swigCPtr, this);
380    return (cPtr == 0) ? null : new Port(cPtr, false);
381  }
382
383  
384/**
385   * Removes the port with the given index.
386   * The caller owns the returned item and is responsible for deleting it.
387   <p>
388   * @param index the index of the {@link Port} object to remove.
389   <p>
390   * @return the {@link Port} object removed.  As mentioned above, 
391   * the caller owns the returned object. <code>null</code> is returned if 
392   * the given index is out of range.
393   */ public
394 Port removePort(long index) {
395    long cPtr = libsbmlJNI.CompModelPlugin_removePort(swigCPtr, this, index);
396    return (cPtr == 0) ? null : new Port(cPtr, false);
397  }
398
399  
400/**
401   * Set the string used as the divider between names when renaming and
402   * flattening models.
403   <p>
404   * The divider string consists of two underscore characters
405   * (&quot;<code>__</code>&quot;) by default.  This method will fail if called
406   * with an empty <code>divider</code>, or a <code>divider</code> that cannot be used internally as part
407   * of a valid SBML SId.
408   <p>
409   * <p>
410 * @return integer value indicating success/failure of the
411 * function.   The possible values
412 * returned by this function are:
413   * <ul>
414   * <li> {@link libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS}
415   * <li> {@link libsbmlConstants#LIBSBML_OPERATION_FAILED LIBSBML_OPERATION_FAILED}
416   * </ul>
417   */ public
418 int setDivider(String divider) {
419    return libsbmlJNI.CompModelPlugin_setDivider(swigCPtr, this, divider);
420  }
421
422  
423/**
424   * Get the string used as the divider between names when renaming and
425   * flattening models.
426   <p>
427   * The divider string consists of two underscore characters
428   * (&quot;<code>__</code>&quot;) by default, and can be overridden
429   * with the setDivider() function.
430   <p>
431   * @return the divider that will be used by any call to flattenModel().
432   <p>
433   * @see #setDivider(String divider)
434   */ public
435 String getDivider() {
436    return libsbmlJNI.CompModelPlugin_getDivider(swigCPtr, this);
437  }
438
439  
440/** * @internal */ public
441 void connectToChild() {
442    libsbmlJNI.CompModelPlugin_connectToChild(swigCPtr, this);
443  }
444
445  
446/** * @internal */ public
447 void connectToParent(SBase parent) {
448    libsbmlJNI.CompModelPlugin_connectToParent(swigCPtr, this, SBase.getCPtr(parent), parent);
449  }
450
451  
452/** * @internal */ public
453 void enablePackageInternal(String pkgURI, String pkgPrefix, boolean flag) {
454    libsbmlJNI.CompModelPlugin_enablePackageInternal(swigCPtr, this, pkgURI, pkgPrefix, flag);
455  }
456
457  
458/**
459   * Sets the custom transformer that is to be used, instead of the standard
460   * prefixing with the given divider. This makes it possible to finely control
461   * how elements are altered. 
462   <p>
463   * If not set, only ids and meta ids will be prefixed. 
464   <p>
465   * NOTE: the model plugin only holds the pointer to the element it does not 
466   *       take ownership of it. Thus the calling program is responsible of 
467   *       freeing the transformer when no longer needed (i.e after the 
468   *       SBML document has been deleted)
469   <p>
470   * @param transformer the prefix transformer to use.
471   */ public
472 void setTransformer(SWIGTYPE_p_PrefixTransformer transformer) {
473    libsbmlJNI.CompModelPlugin_setTransformer(swigCPtr, this, SWIGTYPE_p_PrefixTransformer.getCPtr(transformer));
474  }
475
476  
477/**
478   * @return any custom transformer set for prefix operations, will be null by default.
479   */ public
480 SWIGTYPE_p_PrefixTransformer getTransformer() {
481    long cPtr = libsbmlJNI.CompModelPlugin_getTransformer(swigCPtr, this);
482    return (cPtr == 0) ? null : new SWIGTYPE_p_PrefixTransformer(cPtr, false);
483  }
484
485  
486/**
487   * @return an indicator, whether a custom transformer has been set.
488   */ public
489 boolean isSetTransformer() {
490    return libsbmlJNI.CompModelPlugin_isSetTransformer(swigCPtr, this);
491  }
492
493  
494/**
495   * Unsets any custom prefix transformers. 
496   */ public
497 void unsetTransformer() {
498    libsbmlJNI.CompModelPlugin_unsetTransformer(swigCPtr, this);
499  }
500
501}